It the BAO name is not found at this point we currently get a fatal error. This makes it more
recoverable. The specific case I'm hitting at the moment relates to monolog - the
caching of the symfony container means it persists between builds and is
accessed before the extension is installed. However the entity is not
yet registered. Historically I have hit this fatal in other
scenarios but I can't recall the details.
*/
protected $having = [];
+ /**
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ */
public function _run(Result $result) {
// Early return if table doesn't exist yet due to pending upgrade
$baoName = $this->getBaoName();
+ if (!$baoName) {
+ // In some cases (eg. site spin-up) the code may attempt to call the api before the entity name is registered.
+ throw new \API_Exception("BAO for {$this->getEntityName()} is not available. This could be a load-order issue");
+ }
if (!$baoName::tableHasBeenAdded()) {
\Civi::log()->warning("Could not read from {$this->getEntityName()} before table has been added. Upgrade required.", ['civi.tag' => 'upgrade_needed']);
return;