-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
[REF] Use OO when determining what to suggest for settings.php prefixes for drupal/backdrop views, instead of scattered "if cms ==" #21042
Conversation
(Standard links)
|
See also eileenmcnaughton/civicrm_entity#312 (comment) which was just merged recently. I'm not sure at the moment whether that makes this unnecessary or is separate. @jackrabbithanna @KarinG |
Oh yeah - I saw @KarinG pasted that link on the original but I didn't actually click through on it - I see what you mean |
I haven't looked too closely but I recall us having an issue with civi integration with views in Backdrop but it was because of a new support for latest MySQL. @laryn do you know if there's an issue someplace? |
Recently Matt made a PR where it is no longer necessary to add the "views integration" database prefix settings in the Drupal's settings.local.php Also, the PR you referenced did fix a bug that caused an SQL that is that error or a similar error as posted for this issue. Perhaps test Civi without your PR with the latest of the 8.x-3.x branch in the github repo, for Drupal 8/9 I'm not sure any fixes are necessary in Civi Core, but I could be wrong. |
I'm gonna close this out if people don't think it's needed |
As far as Backdrop is concerned this PR is still an improvement by moving the logic to the userframework class. It might not address the official bug but it's still good. I found: backdrop/backdrop-issues#4745. I believe that we'll still need the separate logic between Drupal 7 and Backdrop. Can we revive this PR @eileenmcnaughton or does it need a new issue? |
@herbdool - tada - it's back - actually you are right - I didn't include any actual change as far as I can tell - so no reason not to merge this |
CRM/Utils/System/Base.php
Outdated
*/ | ||
public function getCMSDatabasePrefix(): string { | ||
$crmDatabase = DB::parseDSN(CRM_Core_Config::singleton()->dsn)['database']; | ||
$cmsDatabase = DB::parseDSN(CRM_Core_Config::singleton()->dsn)['database']; |
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.
??? This looks wrong.
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.
does doesn't it....
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.
and yet, like magic....
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.
Looks better now
I haven't tested but looks like it'll work the same as before. LGTM |
What is the issue that is being fixed here? Drupal 9 / Views with latest CiviCRM entity PR 312 is working with Drupal and CiviCRM tables in a single database as well as with Drupal and CiviCRM tables in two separate databases ->without<- (as this has been deprecated) specifying $databases['default']['default']['prefix']= array( in the settings.php file And it’s working for very complicated Views involving Views relationships joining both Drupal and CiviCRM tables. And we have added a first Views automated test in CiviCRM Entity now. I thought all things Views should live in CiviCRM Entity - that’s why I had Matt help me make this possible via CiviCRM Entity. @pradpnayak - who first posted referenced an SE issue w/ database prefixes - but those are deprecated - so what’s the issue that needs fixing post CiviCRM Entity PR 312? |
@KarinG I mentioned above why I asked to reopen this PR. This is not so much about d9 as about just putting existing logic in the right place. The prefix setting is better in the class. Maybe the PR could be renamed? |
Some thoughts:
|
CRM/Utils/System/Base.php
Outdated
if ($crmDatabase === $cmsDatabase) { | ||
return ''; | ||
} | ||
return "`$cmsDatabase`."; |
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.
I was just testing this (drupal 7) - this is backwards - you need the crmdatabase.
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.
@demeritcowboy do you want to push in the changes that this PR needs?
There was a larger question raised:
Would it make sense to just take this section of the form completely out of core and let civicrm_entity provide a page to tell the user whatever it thinks is right? |
@demeritcowboy wouldn't your proposal mean that all sites regardless of CMS would need to install that module? I don't think that would work. Not all D7 sites would need the full |
As of D8 / D9 all views integration is supported by CiviCRM entity D7 views integration should stay as is - CiviCRM entity is not and should not be required. Still not at all clear to me what ‘Drupal 9 views fix’ is being fixed here. We have a lot of Drupal 9 views that are working fine especially after we sorted out civicrm entity to handle single vs separate database scenarios. If the title of this PR is wrong can someone please suggest a better one with steps to reproduce? |
@KarinG I've changed the title. @herbdool Good to know civicrm_entity doesn't work with backdrop. And yes right even drupal 7 doesn't require it for views. To recap then:
Side note: Line 76 references a non-existent variable. |
Thanks Dave 👍 @jackrabbithanna -> can you please queue up a release for CiviCRM Entity? Then >= D8 views will -no longer- require prefixes regardless of whether people use a single or separate db-s - until then people are going to hit ‘something not working’ and will look in CiviCRM core to fix it. |
So my other question is that does D7 still work with Backticks or not, given that Backdrop effectively ported the recent D7 patches for MySQL 8 which is what caused the backticks to no longer work on Backdrop, does D7 still need them. As for composer if you just use drupal/civicrm_entity then it depends on what is in the drupal releases / git repo in drupal's world but if you specify to use the github then it will be what ever is in the Eileen repo setup. |
@demeritcowboy my reason for adding an empty d9 class is that say in future we Do have a function that differs between 8 & 9. Then we could have upgrading fun - ie you can't set d9 on your pre-upgraded DB because it isn't there until the code base supports it but you really want to set it before you put the new code base there (I'm remembering this being tricky with d6->d7) - of course in writing this I realised we'd need to add a permissions stub too |
@KarinG still having some consequences of the activity and event entity types having bundles based on the event type and activity type .. that layout builder issue I mentioned .. but maybe this Views stuff is more important and worth a release. |
@jackrabbithanna - if it doesn't break anything then release it :-) |
Its a different feature, but got to choose the lesser of two evils sometimes |
@demeritcowboy I think this is mergeable but there has been a lot of tangential conversation - is that your take? |
Hi, |
civicrm_entity is a separate issue at this point. Doesn't affect the merits of this. Other than fixing that one error I think it's mergable |
civicrm_entity is relevant in the sense that if we can drop any code related to drupal 8+ then that has more merit, and as noted in the comments possibly even the drupal 7 part can go. This PR takes non-trivial time to test - obviously nobody tested it - I'd rather not spend more of my time on this version if it's going to be changing anyway - I stopped when the crm/cms thing came up, so there's still more to test. |
@demeritcowboy ok - I'll close |
@demeritcowboy How can the D7 part be removed? Is civicrm_entity going to be required for all Drupal sites? Regarding the empty D9 class I thought that was already explained above. It's not just related to Views. I haven't had a chance yet to test it but I figured it was good on the principle of better refactoring. |
D7 removed in the sense it might now be the same as backdrop. |
I just took a quick look & fixed the crm vs cms & re-opened based on @herbdool - but this does require testing on at minimum backdrop & at least one other cms I guess I don't have strong opinions about push through vs abandon but I do think this is cleaner & will make it easier to add d9 overrides if & when the time comes |
I'll try to test it tomorrow. Or after my time off in a couple weeks. |
* However, this string should contain backticks, or not, in accordance with the | ||
* CMS's drupal views expectations, if any. | ||
*/ | ||
public function getCRMDatabasePrefix(): string { |
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.
I think that this should just return '' and this code should actually sit in the DrupalBase.php class which is shared by the Drupal 7 (Drupal.php), Backdrop and Drupal 8 classes as appropriately
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.
@seamuslee001 do you mean the default is returning an empty string and then in the Drupal 7 class and Backdrop class add a check if $crmDatabase === $cmsDatabase?
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.
@seamuslee001 the reason I landed on the base class is that it is still a valid db prefix beyond drupal - even if it isn't used
$dsn = CRM_Utils_SQL::autoSwitchDSN($config->dsn); | ||
$dsnArray = DB::parseDSN($dsn); | ||
|
||
$dsnArray = DB::parseDSN(CRM_Utils_SQL::autoSwitchDSN($config->dsn)); | ||
$tableNames = CRM_Core_DAO::getTableNames(); | ||
asort($tableNames); | ||
$tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= ['; |
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.
Unfortunately we still have a $config->userFramework === 'Backdrop'
just below this. Do we need another method for $tablePrefixes
? Though I see other references above as well to WordPress, Drupal 8, etc so maybe the whole buildForm should be passed in from the classes? Or leave that for a future 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.
Let's leave out of scope of this given how stalled it is
I've tested in Backdrop and the PR looks fine. I won't have time to test Drupal7 for a couple weeks. |
@demeritcowboy I'm not sure if Drupal 7 is now the same as Backdrop. I recall that they took a slightly different approach and not sure if Drupal 7 took away the backticks. I'm assuming it's backwards compatible? |
@demeritcowboy @seamuslee001 where do you think this is at given @herbdool's testing (above) I just re-read through the code & I believe that for d7 (untested) & d8 (tested) the db would have backticks before and after this change |
@eileenmcnaughton I've now tested in d7 as well. Before and after, the format looks the same. Like
So I believe this meets the goal of refactoring here. Code is better, output is the same. |
CRM/Utils/System/Drupal9.php
Outdated
/** | ||
* Drupal specific stuff goes here. | ||
*/ | ||
class CRM_Utils_System_Drupal9 extends CRM_Utils_System_Drupal8 {} |
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.
@eileenmcnaughton I genuinely don't see a need for this at all given that we are not changing the UF between Drupal 8 -> Drupal 9
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.
@seamuslee001 yeah - it feels 'right' to me to put this here because it seems inevitable there will be some variance at some point - but TBH my involvement in this one is just that I was trying to resolve an old stalled PR. (I've already tried to close it twice :-))
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.
I would merge it if this was not included
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.
OK - I've removed it - I guess putting this to bed is more important than my feeling it should be added
I would also just add that I think I tested this on d7 but without the backticks and that seem to work as well (maybe some compatibility layer exists there somewhere) |
I took a look at civicrm#20682 and it seemed clear that in it's current state it would fix one CMS (d9) & break another (d7). This is an alternate that will hopefully be non-breaky
e601d46
to
6440c50
Compare
Overview
I took a look at #20682 and it seemed clear that
in it's current state it would fix one CMS (d9) & break another (d7). This is
an alternate that will hopefully be non-breaky
Before
See #20682
After
fixed - hopefully without breaking anything else
Technical Details
The discussion by @demeritcowboy @homotechsual @demeritcowboy @seamuslee001 seems to indicate this would be a be a safer approach
Comments
ping @pradpnayak