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.
Problem/Motivation
Many moons ago we made the field module not required. This subtlety broke an assumption made by \Drupal\Core\Installer\Form\SiteConfigureForm
. It does
$this->moduleInstaller->install(['file', 'update'], FALSE);
under the impression that all of these modules dependencies are required. This is no longer true.
So if you install the testing profile via Drush core.extension:module looks like:
module:
dynamic_page_cache: 0
file: 0
page_cache: 0
system: 0
update: 0
user: 0
testing: 1000
Proposed resolution
Add field to the list of modules to install.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#22 | 3033494-20.8_6_x.patch | 2.1 KB | alexpott |
#20 | 3033494-20.8_7_x.patch | 67.68 KB | dww |
#20 | 3033494-20.8_7_x.test-only.patch | 1.25 KB | dww |
#20 | 3033494.16_20.8_6_x.interdiff.txt | 921 bytes | dww |
#20 | 3033494-20.8_6_x.patch | 2.1 KB | dww |
Comments
Comment #2
alexpottComment #3
alexpottFixing some code comments.
Comment #4
jibranWe need to fix the DB dump introduced in #3020718: system_post_update_add_expand_all_items_key_in_system_menu_block fails if blocks module is disabled.
Comment #5
alexpottSure - it's fixed in #2863652: Do not allow files with "php|pl|py|cgi|asp|js" extensions to be renamed to *.txt and be uploaded if *.txt is not allowed by the field widget because that's where this breaks but we can re-roll the one that get's in last.
Comment #7
alexpottThis comment uploads the patch for 8.7.x and the one for 8.6.x as well.
Comment #8
jibranThanks, for addressing the feedback. Code changes and test looks good so marking it RTBC.
Comment #9
dwwSpeaking of DrupalWTF, why does update.module care about file.module or field.module? ;) I don't remember writing any such code years ago when I added update.module to core. I'm not sure this patch is moving in the right direction. Seems we should only enable update.module if that's what they want. What's this "non-required dependencies" business mentioned in the comment for
testUpdateModuleInstall()
?Okay, a little more grepping, and I see
./src/Form/UpdateManagerInstall.php
is callingfile_save_upload()
which indeed lives in file.module. Weird. Maybe that's my fault, I don't remember. ;) But, that doesn't require a file field, right?Is this not "works as designed"?
Seems the better fix is to have a less weird file API so that update module can have a file upload form element that doesn't require file.module itself?
Tentatively -1 to this patch.
Comment #10
alexpott@dww back in the day filed module was required so you didn’t have to care. Personally I think we should do the quick fix here and resolve this differently in a follow up if we want to. The case where field module is not installed is extremely rare. Both minimal and standard install it.
Comment #11
dwwBut then why is this a bug? If a site is truly bare-bones, and is only installing file.module to help update.module, then what's the harm in having only file.module enabled without field.module?
I don't mean to hold up progress, I'm just trying to understand.
Sorry/thanks,
-Derek
Comment #12
tim.plunkettQuestion along similar lines. Why is this not
$this->moduleInstaller->install(['update']);
and rely on the default value of$enable_dependencies
?If there is a really good reason to bypass that, I think it deserves a comment.
(The new test added by this issue passes with the above change, but not uploading a new patch in case that derails this)
Comment #13
alexpott@dww The file module is dependent on the field module. That's the way it is. It we want to disentangle that. Then so be it. But I think that that should happen in a followup. This bug only occurred because someone when on a mission to try to remove all required modules are field was one they were successful with.
@tim.plunkett I've no idea why we call that with FALSE for dependencies. I agree with you it's wrong. The system at this point is fully working - I'll have a look in git history and see if I can work out why.
Comment #14
catchAgreed with #12, let's either make that change or add a comment explaining why not.
Comment #15
alexpottThe patch that added this was the original ability to install modules without checking dependencies - #399642-92: Replace drupal_install_modules() with an improved module_enable() (note the issue is confusing because there are followup commits on it). At this point update had no dependencies. It should have because it was using file_save_upload(). That was fixed in #1468328: Move file entity info, managed file, and file usage functionality into File module by adding the file module to this and this also added the missing dependency.
So as far as I can work it out the only possible reasons we used the no dependency module install is (a) at the time update has no dependencies (b) to copy the other early module installs done in the installer.
(a) is no longer true and (b) is irrelevant because the system is fully installed at this point.
So let's do #12. And then if we every untangle update / file / field then this will do the right thing automatically.
Comment #16
alexpottComment #17
alexpottWith the patch in #16 I've manually tested drush install of minimal and the testing profile. It works and here's the enabled modules after an install of the testing profile.
Package Name Type Version
Core Field (field) Module 8.7.0-dev
Core Internal Dynamic Page Cache (dynamic_page_cache) Module 8.7.0-dev
Core Internal Page Cache (page_cache) Module 8.7.0-dev
Core System (system) Module 8.7.0-dev
Core Update Manager (update) Module 8.7.0-dev
Core User (user) Module 8.7.0-dev
Field types File (file) Module 8.7.0-dev
Core Classy (classy) Theme 8.7.0-dev
Comment #18
tim.plunkettGreat, I'm glad this worked! It is much clearer and much less brittle.
Comment #19
alexpott@tim.plunkett yep totally. Thanks for spotting this, I don't know why I just continued adding modules.
Comment #20
dwwOkay, fair enough. I definitely agree that untangling all the file upload API stuff is out of scope for the bug at hand.
I still don't like this comment/assertion:
WTF is a "non-required dependency"? ;) Oxymoron alert.
s/non-required//
(both in the assertion and in the comment).
New set of patches for both branches.
Comment #21
alexpott@dww indeed that's totally an oxymoron - thanks for fixing.
Comment #22
alexpottRe-upping the 8.6.x patch from #20 so rtbc retester doesn't come along and set this to needs work.
Comment #26
dww#3035320: Random fails in TimestampAgoFormatterTest and DateTimeTimeAgoFormatterTest strikes again. :/
Comment #28
alexpottComment #31
larowlanCommitted 5d2bc24 and pushed to 8.7.x. Thanks!
c/p 6f3f6fb3ba as and pushed to 8.6.x
This commit was brought to you by 'Qualified' by 'Dr John' 🎶
Comment #32
jibranI think we should have committed https://www.drupal.org/files/issues/2019-02-19/3033494-20.8_7_x.patch to 8.7.x but we can do that in #2863652: Do not allow files with "php|pl|py|cgi|asp|js" extensions to be renamed to *.txt and be uploaded if *.txt is not allowed by the field widget now.
Comment #35
larowlan@alexpott let me know there was an 8.7 specific patch here so reverted the previous commit and applied and pushed that as 3b32b1e
Comment #36
jibranFWIW, we updated the DB dump after my feedback in #4. :)
Comment #37
alexpottI ticked the credit box for @jibran for #4.
Comment #38
jibranThanks!