-
-
Notifications
You must be signed in to change notification settings - Fork 829
Throw exception when baoName is not found #20696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(Standard links)
|
Civi/Api4/Generic/DAOGetAction.php
Outdated
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a space after the entity name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This can be merged when @colemanw 's comment / issue is resolved |
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.
This is a valuable step forward - issues relating to The mechanisms are outside my current understanding but am happy to test future PRs now that we've started to isolate the issue. |
Overview
Throw exception when baoName is not found in v4 api get requests
Before
If a race condition arises where the entity is called before it is registered a fatal error results
After
In same situation an exception is thrown.
Technical Details
An exception is more recoverable than a fatal error.
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 via entityTypes hook. Interestingly my call to apiv4.getEntities
does find it to be available.
Historically I have hit this fatal in other scenarios but I can't recall the details.
Comments