update.php only invokes system_requirements(), but not any other hook_requirements() implementation.

This prevents modules from ensuring custom update requirements.

Comments

pwolanin’s picture

Is there any documentation or history as to why it's this way? Or just someone forgot to fix it in D5->D6?

sun’s picture

It doesn't look like hook_requirements() was ever invoked for all modules. I just searched in D5's update.php, and the term "requirements" does not even appear once in there.

Note that with the patch, System module's requirements are checked twice on update.php -- once for the initial update.php bootstrap, which loads system.module only to check fundamental system requirements prior to attempting to update anything; and then once again on update.php's 'info' task/step, in which all modules are loaded for the first time.

I tested this patch by temporarily adding:

function example_requirements($phase = 'runtime') {
  $requirements = array();
  if ($phase == 'update') {
    $requirements['example'] = array(
      'title' => 'Error title',
      'value' => 'Error value',
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

...which successfully prevented me from updating.

sun’s picture

Title: update.php does not invoke hook_requirements() » update.php does not invoke hook_requirements('update') in all modules
Priority: Normal » Major

Given that module requirements can heavily change when upgrading to or updating within D7, this is a pretty major bug.

Stevel’s picture

Status: Needs review » Needs work
+++ update.php	25 Sep 2010 20:36:35 -0000
@@ -309,7 +309,7 @@ function update_extra_requirements($requ
   // Check the system module and update.php requirements only.

The comment says explicitly that only system.module requirements are checked, so that should be changed as well.

As there was a comment, I went back to see where the code was introduced (#200674: Update requires PHP memory limit warning if below recommended minimum) and it seems the initial reason was just to check for the memory limit, which just happened to be in system_requirements, so no compelling reason not to check other requirements here.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

Thanks, fixed that comment.

mattyoung’s picture

Status: Needs review » Needs work

The documentation of hook_requirement() http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

only mention $phase == 'runtime' and 'install'. It does not have 'update'.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new3.71 KB

Good catch, thanks!

Stevel’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to go.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.