I'm getting this PHP warning on certain pages when an anonymous user. This is caused by test_flagged_by_current_user() returning a FALSE value, though validate_argument() needs an empty array in this case. Here's a one-line patch which fixes the error.

Comments

joachim’s picture

+++ b/includes/flag_plugin_argument_validate_flaggability.inc
@@ -187,7 +187,7 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
     if (method_exists($this, $method)) {
       $passed = $this->$method($ids, $flag);
     }
-    else {
+    if (empty($passed)) {
       $passed = array();
     }

I'm not sure what this fix is fixing.

Surely with the else statement, $passed will either be the return from the $method, or an empty array?

Or am I being dense and missing something?

joachim’s picture

Ah I think I get it.

This is the better fix, I think: fix what the method returns.

socketwench’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Tests clean.

joachim’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

Issue #1462000 by joachim, joelstein: Fixed incorrect value returned by argument flaggability check.

joachim’s picture

Backported to both 6--2 and 6--1.

(@socketwench: btw, handy tip: quick way to see if a patch backports is to check out into the older branch and do 'git cherry-pick [SHA]'. If the patch applies, you get the commit made for you too.)

Status: Fixed » Closed (fixed)

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