Add fallback to detect CiviRules#18
Open
ergonlogic wants to merge 2 commits into
Open
Conversation
|
Hi Ergon, A couple of points of feedback: The code that you've added, if statements without braces, isn't standards compliant. Before I'd merge this I need them to be of the form: Secondly, could you produce a unit test that reproduces the error and demonstrates that this patch fixes it? If you do that I will happily merge this change. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upon enabling the CiviPoint extension, I received the following warning twice:
I believe this warning is due to a couple managed entities (here and here. The intention appears to be that these entities are only loaded if CiviRules has been installed.
First off, the function that loads the managed entities assumes the included files will result in an array. If CiviRules is not installed, it should result in NULL, hence the warnings, as the code tries to iterate over the non-existent array. Returning an array in the "mgd.php" filess may result in mis-configured entities (since no settings will have been loaded. On the other hand, _civipoints_civix_civicrm_managed() is in an auto-generated file. So altering it may result in it being overwritten at some point.
I believe that the proper long-term fix here is to alter how Civix generates this function, to allow for empty return values, when dependent extensions are not present. In the short term, adding an
is_array()check should resolve the warnings.Secondly, I had enabled CiviRules previous to enabling this extension, as per the docs. So, the function that's checking for CiviRules being enabled is suspect, at this point, too. It appears that CiviRules isn't returned in the list of extensions from the API call.
Perhaps this is intentional on the part of CiviRules. But if not, it should be fixed upstream. For now, I've added a fallback method to query the database directly.