The documentation for hook_requirements http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct... pretty clearly states for the 'value' key in the returned array:

value: The current value (e.g., version, time, level, etc). During install phase, this should only be used for version numbers, do not set it if not applicable.

Well, I didn't set it because displaying the value I'm checking would be a security issue and now the status report page is throwing a notice at me so either the code or the documentation is wrong.

Comments

thedavidmeister’s picture

Status: Active » Needs review
StatusFileSize
new789 bytes

Presuming the documentation outlines the intended behaviour, patch is attached.

thedavidmeister’s picture

Hmm, just re-read the documentation and realised that it could mean that "'value' is only optional during the install phase", as well as "this is what it means during install and also it is optional".

The former interpretation still seems weird to me, that it would be optional for only one value of $phase ie. The value of the variable passed to the hook subtly modifies the required structure of the return value.

Weren't all those D6 $op style shenanigans weeded out in Drupal 7?

rooby’s picture

It is valid to not have a value for 'value' (the docs even say do not set if not applicable), so I think it's existence should be checked first.
It is in other places like drupal_check_module().

thedavidmeister’s picture

so, RTBC?

rooby’s picture

Status: Needs review » Reviewed & tested by the community

Yep. Solves the issue and applies cleanly.

rooby’s picture

Version: 7.x-dev » 8.x-dev
StatusFileSize
new671 bytes

Oops, wrong version. Here is a drupal 8 one that is the same.

deanflory’s picture

Applied patch in #1 onto D7.23 and the error went away.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/system.admin.incundefined
@@ -587,6 +587,8 @@ function theme_status_report($variables) {
+    $requirement['value'] = isset($requirement['value']) ? $requirement['value'] : '';

Hmmm using a ternary operator here seems unnecessary bearing in mind http://fabien.potencier.org/article/48/the-php-ternary-operator-fast-or-not and we're just assigning the same value to itself which seems clunky.

How about we just change

    $output .= '<td class="status-value">' . $requirement['value'];

to

    $output .= '<td class="status-value">';
    if (!empty($requirement['value'])) {
      $output .=  $requirement['value'];
    }
validoll’s picture

Version: 8.x-dev » 7.23
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new791 bytes

IMHO this is small economy. With the first option code more readable.
At this time, right patch for 7.23

thedavidmeister’s picture

Version: 7.23 » 8.x-dev
Status: Needs review » Needs work

Thanks for that, unfortunately bugs have to be fixed against latest version then backported.

arruk’s picture

I added this at like 2583 of system.admin.inc. There is a reason why this solution wont work? I mean besides the fact that is a core hack?

if(!isset($requirement['value'])){
		array_push($requirement, "value");
		$requirement['value']="";
	 }
deanflory’s picture

Current error in Drupal 7.26:

Notice: Undefined index: value in theme_status_report() (line 2588 of /.../modules/system/system.admin.inc

HAPPY BELATED BIRTHDAY to this issue! ;)

I'll try applying #1 again and if it has issues I'll try #9. Not sure why there's another patch for the same version of Drupal (D.7.23).

deanflory’s picture

The two patches on this issue have a variance where a line is commented or not.

1880224-fix-notice-for-missing-value-on-status-report-page-1.patch

$requirement['value'] = isset($requirement['value']) ? $requirement['value'] : '';

drupal-status_report_undefined_index_value-1880224-9.patch

//$requirement['value'] = isset($requirement['value']) ? $requirement['value'] : '';

Which is correct?

The patch without commenting (//) works for D7.26.

validoll’s picture

Oh, this is right, i'm not delete comment :(

deanflory’s picture

Status: Needs work » Reviewed & tested by the community

Patch in #1 works for D7.28 and has worked for almost a year and half but is still not committed to Drupal 7 as of D7.28.

Marking this as RTBC to get some attention since this is lingering.

I cannot verify whether the patch in #6 works for D8. Someone?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: drupal-status_report_undefined_index_value-1880224-9.patch, failed testing.

alexpott’s picture

Version: 8.x-dev » 7.x-dev
Issue tags: +Needs tests

Usually we fix the latest dev version first however since #2151101: Convert theme_status_report() to Twig has converted theme_status_report() to twig we no longer have this problem since Twig handles the problem if requirements.value does not exist.

But regardless of this version the patch is not rtbc since it has no test.

alexpott’s picture

Oh and the patch in #9 is not right - patch #1 would fix the issue for D7 - but to prove this you'll need a test.

bluecobalt’s picture

Patch in #1 works for Drupal 7.34.

capfive’s picture

#1 fixed it here 7.34 build :)

Anonymous’s picture

#1 fixed it here 7.39

monta’s picture

joelpittet’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new858 bytes
new1.91 KB
new2.69 KB

Re-posting the previously RTBC'd #1. With a copy change on the comment. Hope that works well?

@alexpott, tried to make a test for this, but I'm shit at tests... so lmk how I can improve this?

The last submitted patch, 25: 1880224-25-test-only-fail.patch, failed testing.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix

I'm setting this to RTBC because I didn't actually write the fix, I only changed the comment for clarity and wrote the test to prove it fixes the problem.

stefan.r’s picture

Issue tags: +Pending Drupal 7 commit

Patch looks good, thanks!

ashwinsh’s picture

Patch works for me, thank you..!

stefan.r’s picture

Assigned: Unassigned » fabianx

Per #17 this is not needed for D8, just want to double check with Fabianx whether we still want to address #8.

fabianx’s picture

Assigned: fabianx » Unassigned

RTBC + 1

Looks great to me, the ternary operator thing is not a problem for me and theme_status_report is not in the critical path at all ...

  • stefan.r committed 29bc731 on 7.x
    Issue #1880224 by joelpittet, thedavidmeister, rooby, validoll, monta:...
stefan.r’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit

Committed and pushed to 7.x, thanks!

Status: Fixed » Closed (fixed)

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