Fix Schema calculation of usePrefix to cope with rpow: #20471
Merged
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.
Overview
This fixes the code in the logging schema to calculate $usePrefix based on whether the logging database name matches the civicrm database name, not the whole string.
$usePrefix is used to determine whether to prepend the database name in the triggers - ie
Before
database name is prepended into the string when rpow is in play
This would also happen if different db users were used for the 2 databases (I can't think of any reason why they would be) - but the user difference would not flow through in any way.
After
Technical Details
Getting usePrefix right helps with portability as we avoid hard-coding the database name unless it is necessary.
The previous code was comparing the whole DSN - which will not match when (rpow)[https://github.com/totten/rpow] is in use. However, we are only using it to determine if the db name is the same (we don't write user or db host into the trigger anyway) & comparing just database gives a better result
Comments
I don't think a reviewer needs to test this in the rpow context - I think that as long as a reviewer experiences this as no change it's fine