og_nodeapi('validate') warning: array_filter(): The first argument should be an array in og.module on line 1211

markus_petrux - September 19, 2009 - 01:08
Project:Organic groups
Version:6.x-2.x-dev
Component:og.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

This PHP notice happens when submitting a node edit form for content types not related to OG groups. The reason is the $form['og_groups'] element is not populated for this kind of content types. But the fix is pretty simple:

<?php
-      $og_groups_filtered = array_filter($node->og_groups);
+     
$og_groups_filtered = isset($node->og_groups) ? array_filter($node->og_groups) : array();
?>

#1

markus_petrux - September 23, 2009 - 21:49

Actually, there's a better way.

AttachmentSize
og_nodeapi_validate-581822-1.patch 1.56 KB

#2

markus_petrux - September 30, 2009 - 17:16

This PHP notice happens when OG is installed and a node of a type not related to OG is saved, which is a little bit annoying.

Is there any problem with the patch in #1? :-/

#3

WorldFallz - October 2, 2009 - 02:05
Status:needs review» reviewed & tested by the community

Seems to be working fine so far on my 2 og sites. It's a tiny change and matches the 'proper' way to avoid such notices. I say go for it.

#4

andypost - October 13, 2009 - 18:30

+1 to commit

#5

jcmarco - November 3, 2009 - 11:28

It works fine!
+1 to commit

#6

bloggybusiness - November 5, 2009 - 11:30

OK for me
+1

#7

SocialNicheGuru - November 14, 2009 - 04:44

This does not work for me :(

#8

moshe weitzman - November 17, 2009 - 03:34
Status:reviewed & tested by the community» fixed

committed. thx.

#9

System Message - December 1, 2009 - 03:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.