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
Currently, installation profiles cannot implement hook_requirements(). Well, technically, they can, but it's not invoked during an install - it is only invoked after an install during updates or visiting the status report. This can be problematic for distributions, which may want to specify requirements that transcend the scope of any one module or feature of the distribution.
Proposed resolution
drupal_check_profile(), which verifies the requirements of all modules listed by an install profile, should also verify the requirements of the profile itself.
Remaining tasks
User interface changes
None.
API changes
Installation profiles support hook_requirements().
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#23 | 2309731-23.patch | 2.71 KB | bendeguz.csirmaz |
#23 | 2309731-23-testonly.patch | 2.26 KB | bendeguz.csirmaz |
#23 | interdiff-2309731-18-23.txt | 604 bytes | bendeguz.csirmaz |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #8
alexpottRepeating a comment from a duplicate issue - #3005965: Allow installation profiles to have requirements.
One thing I ponder is a distribution requirements already checked during update.php - my bet is they are. Let's look...
Yep they are! So if an install profile implements this at the moment there is the chance that they'll be installable but not updatable :) nice. I think whilst install profiles are module (not the biggest fan fwiw) having differences like this introduces cognitive load that we shouldn't have. So +1 to implementing and testing and since we check them once everything is installed just not before that makes this a bug.
Comment #9
alexpottBorrowed issue summary from the duplicate issue.
Comment #11
alexpottCrediting @phenaproxima who wrote the issue summary that I copied over here.
Comment #12
phenaproximaTargeting 8.7.x.
Comment #13
bendeguz.csirmaz CreditAttribution: bendeguz.csirmaz at Cheppers commentedRerolled the old patch.
Comment #14
bendeguz.csirmaz CreditAttribution: bendeguz.csirmaz at Cheppers commentedAdded test.
Comment #16
phenaproximaI love it! Fail patch and everything. Makes perfect sense to me. Thanks, @bendeguz.csirmaz!
One suggestion I have, if possible, is not to have the test create a profile in the site directory. Instead, let's just add a new testing profile to core, called testing_requirements or something like that, and try to install it.
Comment #17
bendeguz.csirmaz CreditAttribution: bendeguz.csirmaz at Cheppers commentedOkay, I created a testing profile for this - on one hand the code is cleaner, on the other hand the test is 3 files.
Comment #18
bendeguz.csirmaz CreditAttribution: bendeguz.csirmaz at Cheppers commentedI realized the test probably should stay in the
Drupal\FunctionalTests\Installer
namespace.Comment #21
phenaproximaNitpick: I've never seen a Yoda condition in core, and I'm not sure the coding standards allow it. Can we make this $phase === 'install'?
Other than that, it's perfect. Please send this directly to RTBC once the nitpick is fixed.
Comment #22
phenaproximaI meant to set that back to "Needs work".
Comment #23
bendeguz.csirmaz CreditAttribution: bendeguz.csirmaz at Cheppers commentedSure. Actually, I copied that part from
Drupal\Tests\system\Functional\Module\HookRequirementsTest
, so I think it's allowed.Comment #25
alexpottWe could do with a change record for this one. http://drupal.org/list-changes/drupal
Comment #26
phenaproximaDone. https://www.drupal.org/node/3007330
Comment #27
alexpottCommitted and pushed 04a706f63d to 8.7.x and c70cc7ee40 to 8.6.x. Thanks!
Since this is a bugfix backported to 8.6.x - see #8 for why this is a bugfix.