Recent Topics

1 Oct 07, 2007 19:09    

In Backoffice toolbar when clicking the Posts / Comments, it generates on PHP5

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/htdocs/blogs/inc/items/model/_itemlistlight.class.php on line 194

Warning: Cannot modify header information - headers already sent by (output started at /var/www/htdocs/blogs/inc/items/model/_itemlistlight.class.php:194) in /var/www/htdocs/blogs/skins_adm/_html_header.inc.php on line 40

This is because behaviour of array_merge changed in PHP5, here is a patch against HEAD that fixing it.

Index: _itemlistlight.class.php
===================================================================
RCS file: /cvsroot/evocms/b2evolution/blogs/inc/items/model/_itemlistlight.class.php,v
retrieving revision 1.7
diff -u -r1.7 _itemlistlight.class.php
--- _itemlistlight.class.php	1 Oct 2007 01:06:31 -0000	1.7
+++ _itemlistlight.class.php	7 Oct 2007 16:38:14 -0000
@@ -190,6 +190,14 @@
 	 */
 	function set_filters( $filters, $memorize = true )
 	{
+
+		// For PHP5 compability
+		// The behavior of array_merge() was modified in PHP 5.
+		// Unlike PHP 4, array_merge()  now only accepts parameters of type array.
+		if( !is_array($filters) )
+		{
+			$filters = (array)$filters;
+		}
 		// Activate the filterset (fallback to default filter when a value is not set):
 		$this->filters = array_merge( $this->default_filters, $filters );

I haven't looked yet if this can happen in other places. As far as I can see th set_filters function always is passed an Array() as argument but it appears as if empty or a single element turns the local $filter into a simple var. I haven't investigated this further, I just did this change and confirmed it to work.

2 Nov 01, 2007 04:25

Thanks. Committed to CVS HEAD.

4 Nov 13, 2007 19:05

I just downloaded latest CVS and receive the same error in the backoffice post list:

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /blogs/inc/items/model/_item.class.php on line 1820

5 Nov 13, 2007 20:04

That's another one, isn't it?

Just add "echo debug_get_backtrace();" there and then you'll see where it comes from, e.g.:


if( ! is_array( $whatever_is_argument_2_here ) )
{
  echo debug_get_backtrace();
}

6 Nov 14, 2007 01:28

Backtrace:

   1. Item->get_edit_link( " ", " ", "<img src="http://www.blog.hemminga.net/rsc/icons/edit.gif" borde...", "#", "" )
      File: /home/hemmi3/public_html/blog/inc/items/views/_item_list_table.view.php on line 188


I post it here just as a riminder to myself. This is the debug from

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /blogs/inc/items/model/_item.class.php on line 1820

7 Nov 14, 2007 01:30

 get_edit_link  [line 1820]

  void get_edit_link( [string $before = ' '], [string $after = ' '], [string $text = '#'], [string $title = '#'], [string $class = ''], [string $actionurl = '#']  )

Provide link to edit a post if user has edit rights
Parameters:
string   	$before:  	to display before link
string   	$after:  	to display after link
string   	$text:  	link text
string   	$title:  	link title
string   	$class:  	class name
string   	$actionurl:  	page url for the delete action


The original function in inc/items/views/_itms_list_table.views.php lines 180-194 are;

/**
 * Edit Actions:
 *
 * @param Item
 */
function item_edit_actions( $Item )
{
	// Display edit button if current user has the rights:
	$r = $Item->get_edit_link( ' ', ' ', get_icon( 'edit' ), '#', '' );

	// Display delete button if current user has the rights:
	$r .= $Item->get_delete_link( ' ', ' ', get_icon( 'delete' ), '#', '', false );

	return $r;
}


But I'm stuck here. The HEAD docs only gives;

 get_edit_link  [line 1796]

  void get_edit_link( [ $params = array()]  )

Provide link to edit a post if user has edit rights
Parameters:
   	$params: 


so I'm having less $params than arguments from 1.10 and I don't know how to call them.

8 Nov 14, 2007 06:59

A few hours sleep does wonders.
In ../blogs/inc/items/views/_item_list_table.view.php change lines 180 - 194:

/**
 * Edit Actions:
 *
 * @param Item
 */
function item_edit_actions( $Item )
{
	// Display edit button if current user has the rights:
	$r = $Item->get_edit_link( ' ', ' ', get_icon( 'edit' ), '#', '' );

	// Display delete button if current user has the rights:
	$r .= $Item->get_delete_link( ' ', ' ', get_icon( 'delete' ), '#', '', false );

	return $r;
}


in

/**
 * Edit Actions:
 *
 * @param Item
 */
 function item_edit_actions( $Item )
{
	// Display edit button if current user has the rights:
	$r = $Item->get_edit_link( array( 
			'before'       => ' ',
			'after'        => ' ',
			'text'         => get_icon( 'edit' ),
			'title'        => '#',
			'class'        => '',
		)
		);

	// Display delete button if current user has the rights:
	$r .= $Item->get_delete_link( ' ', ' ', get_icon( 'delete' ), '#', '', false );

	return $r;
}


and solved.
As blueyed stated: the answer was in the code LOL

Good luck

9 Nov 14, 2007 11:38

Yes, thanks for that Afwas. What a relief )

10 Nov 14, 2007 16:03

Hi,

I have exactly the same problem when i hit "Post / Comments" - the warning look like this :


Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /inc/items/model/_item.class.php on line 1820

i'm using the latest beta, php5, apache2

11 Nov 15, 2007 00:39

hi buzzworkers,

This is exactly the error we are talking about, so the solution works for you also ;)

Good luck

13 Nov 16, 2007 00:57

Thanks, Afwas. Just committed to CVS.

(the same old API usage is in blogs/inc/items/views/_item_list_track.view.php, too - where I've applied the same patch)


Form is loading...