Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Continuing the quest to a cleaner upgrade path.
Quite a few issues with this one:
- It uses some API functions that it shouldn't. The most worrisome one is user_role_grant_permissions() which relies on user_permission_get_modules() in Drupal 7.
- filter_update_7003() creates the new filter table based on field_schema(), which it shouldn't do because field_schema() can change, but the update function shouldn't
- We rename the 'filters' table twice
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff.txt | 724 bytes | snehi |
#21 | 898546-cleanup-upgrade-filter-21.patch | 3.77 KB | snehi |
#18 | 898546-cleanup-upgrade-filter-18.patch | 3.76 KB | Sivaji_Ganesh_Jojodae |
#16 | 898546-cleanup-upgrade-filter-16.patch | 4.73 KB | David_Rothstein |
#7 | 898546-cleanup-upgrade-filter.patch | 13.76 KB | Damien Tournoud |
Comments
Comment #1
sunComment #2
Damien Tournoud CreditAttribution: Damien Tournoud commentedFirst shot at this. This patch:
The rest of the upgrade path (filter_update_7005() and filter_update_7008()) is somewhat trickier, so I hope to get this trivial part first.
Comment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedNow with patch.
Comment #4
sunDamien, is it really worth to fiddle with this? The filter* tables cannot contain much data either way, so those updates may not be perfect, but who cares, as long as they work?
I'm just trying to make sense of this - my gut feeling tells me that especially both your and my time would be much better spent on critical and major issues instead of beautifying unattractive functions that are invoked only once...? If I'm missing something important, please let me know.
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commented@sun, as I said in #2, this first part is rather easy. The harder part is filter_update_7005() and filter_update_7008(). I published that first step so that all the other crap can be out of the way.
I want all the core update functions to be so clean you can eat of them.
This version should actually pass.
Comment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedNow complete with filter_update_7005() and filter_update_7008() fixed to not use API functions.
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedCritical because of the use of user_role_grant_permissions() which depends on the list of modules currently loaded.
Comment #9
sunCan we move this function into includes/update.inc?
Powered by Dreditor.
Comment #10
Damien Tournoud CreditAttribution: Damien Tournoud commented@sun: I'm not convinced it makes more sense in update.inc then in user.install, because we will require several of those utility functions to fix the upgrade path of Drupal 7:
Comment #11
David_Rothstein CreditAttribution: David_Rothstein commentedAs far as I know there is nothing immediately broken here, so I'm downgrading from critical. Because filter.module is a required core module, it is always guaranteed to be enabled, and it is therefore safe to use user_role_grant_permissions() and other API functions.
That said, it is probably better not to (for the sake of setting a good example for other modules)...
And I also remember seeing a patch from @chx somewhere that would force all modules to act as disabled during the upgrade; if that gets in, then I guess we would absolutely need to do this.
Comment #12
chx CreditAttribution: chx commenteduser_role_grant_permissions call user_permission_get_modules(). We do not call modules as they can be disabled.
Comment #13
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #14
Eric_A CreditAttribution: Eric_A commentedIt appears that first comment needs updating...?
Comment #15
David_Rothstein CreditAttribution: David_Rothstein commentedYes, there is that, plus a couple other small things I noticed. I'll see if I can whip up a quick patch.
But in terms of the larger changes, I think this could still use a little more discussion:
First of all, again, this is NOT a critical issue. user_role_grant_permissions() is broken when called for a disabled module's permissions, but the filter module can never be disabled, so there isn't a problem with it. Nevertheless, it does make sense to use the separate helper function here for consistency, since most other modules have to anyway.
But I am much less sure about this idea of never using any API functions at all - that I don't understand. Some we can't use, but lower-level ones such as filter_formats() and filter_permission_name(), I don't understand why the patch removed them? I think we should consider putting them back.
Comment #16
David_Rothstein CreditAttribution: David_Rothstein commentedHere is a quick patch for the smaller issues. It should be mostly self-explanatory, except maybe for the cache clearing in _update_user_role_grant_permissions()... that is introduced simply because user_role_grant_permissions() has it, and if we are going to have two separate functions, we need to keep the behavior of those two as closely in sync as possible.
I think we should still discuss adding back filter_formats() and filter_permission_name() in the update functions, but I haven't done that in this patch.
Comment #17
thedavidmeister CreditAttribution: thedavidmeister commentedlooks RTBC to me if someone can do a re-roll.
However, I'm bumping down to minor as the latest patch is almost purely code sniffs on once-off code, which as @sun said in #4, is a low priority here.
Comment #18
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedPatch #16 re-rolled.
Comment #19
owenpm3 CreditAttribution: owenpm3 as a volunteer commentedComment #20
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedDoesn't look like the latest patch was tested manually... this won't work at all since the _update_user_role_grant_permissions() function no longer exists (it was changed to _update_7000_user_role_grant_permissions() a long time ago...)
Frankly I'm shocked that the automated tests didn't catch this; I guess we don't have any tests that deal with the Contact module update path :(
Comment #21
snehi CreditAttribution: snehi as a volunteer and at Publicis Sapient for Publicis Sapient commentedDone as suggested by @David.
Comment #26
amit0212 CreditAttribution: amit0212 as a volunteer and at Iksula commentedSee the Patch
Patch
Comment #28
apaderno