$rids is not an array
catch - May 15, 2009 - 12:17
| Project: | Restricted content |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Jump to:
Description
array_intersect is getting called every time - which results in a php warning when $rids === FALSE;
This removes the warning. Seems like it should be possible to keep it on one line, but it's still too early in the afternoon.
| Attachment | Size |
|---|---|
| rids.patch | 856 bytes |

#1
#2
That's really odd. The first condition !$rids in that case should be TRUE and the rest of the conditional should not be evaluated. :/
#3
Yeah that's what I thought too, but I definitely get the warning without the patch, and it definitely fixes them..
#4
Ok, I think it just needs to move the unserialize to the line above since it probably is a string like "N;" or "a:0:{}" or "b:0;" which all technically evaluate to TRUE.
I bet this will work:
Index: /home/dave/Projects/www/drupal6dev/sites/all/modules/restricted_content/restricted_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/restricted_content/restricted_content.module,v
retrieving revision 1.9
diff -u -p -r1.9 restricted_content.module
--- restricted_content.module 30 Apr 2009 15:56:19 -0000 1.9
+++ restricted_content.module 15 May 2009 17:55:12 -0000
@@ -89,8 +89,8 @@ function restricted_content_node_access(
if (!$account) {
$account = $user;
}
- $rids = db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $nid));
- return !$rids || array_intersect(unserialize($rids), array_keys($account->roles));
+ $rids = unserialize(db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $nid)));
+ return !$rids || array_intersect($rids, array_keys($account->roles));
}
function restricted_content_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
#5
Fixed in CVS.