LegacySpecScanner - Degrade gracefully if we have temporary rebuilds during installation
authorTim Otten <totten@civicrm.org>
Tue, 1 Nov 2022 09:01:04 +0000 (02:01 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 1 Nov 2022 09:01:04 +0000 (02:01 -0700)
commitdfbd198186fdd6159cd7442d630b60afb37c0430
tree24208c22ba8dcd264a6c1114bc5c9792e2e0792b
parent14c5d3f9fc51432067730bf76321f285fc1d3919
LegacySpecScanner - Degrade gracefully if we have temporary rebuilds during installation

During the process of installing an extension, there are various flushes/rebuilds. Each of these flushes can lead to a (temporary) rebuild of the container.

In 5.54.0, a caching bug prevents these flushes from rebuilding the container promptly.

In 5.54.1 and 5.55.beta, the caching bug goes away -- and now it tries to rebuild the container (multiple times).
However, during the an early attempt, it fails: there is a mismatch between `getActiveModuleFiles()` (which is used by
`CRM_Api4_Services`/`LegacySpecScanner` to discover classes like `ImportSpecProvider`) and the active class-loader
(which is not available yet -- but it's supposed to load the source for `ImportSpecProvider`). This
means that `CRM_Api4_Services`/`LegacySpecScanner` may raise a class-not-found exception.

This patch basically makes `LegacySpecScanner` behave more like `ClassScanner` during the early parts
of bootstrap -- if a class is not loadable yet, then ignore it.

This should still work out in the end -- because there are multiple rebuilds, and the final disposition is based on the
final build.
Civi/Api4/Service/LegacySpecScanner.php