Menus not visible and array_merge warnings - PHP5 Install

dggreenberg - June 27, 2005 - 23:24
Project:PHPTemplate
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

I've just downloaded CivicSpace RC081 from SVN and run through the install. My
environment is:
Mac OSX 10.3
Apache2
MySQL 4.1
PHP 5

The install seemed to go well - but I got a few warnings from
array_merge function and then a warning during configure - "Invalid
argument supplied for foreach() in /Users/..."

At this point, I have an admin user (user 1) that I can login with - but when I go to http://localhost/dgg/cs/?q=admin, all I get is the watchdog table display - there are no admin menu links.

On all pages, I get the following array_merge function error across the top:

warning: array_merge() [function.array-merge]: Argument #2 is not an
array in /Users/dgg/htdocs/civicspace081rc/themes/engines/phptemplate/phptemplate.engine
on line 42.

AttachmentSize
Cspace_081_PHP5.gif94.82 KB

#1

cypherpunk - June 28, 2005 - 15:04

PHP 5.04
Apache/2.0.53 (mpm/prefork)
MySQL 4.023
Ubuntu Hoary (amd64)

I also found these array_merge warnings in the CivicSpace configuration wizard using PHP5.

warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in /home/charles/civicspace/modules/configure/wizard.inc on line 59.
warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in /home/charles/civicspace/themes/engines/phptemplate/phptemplate.engine on line 42.

#2

cypherpunk - June 28, 2005 - 18:14

PHP5 changed the calling syntax for array_merge -- array_merge() will only accept arguments of type (array).

A solution to this particular bug is to manually cast all array_merge() arguments as type(array)...

Change:
$vars = array_merge($vars, _phptemplate_variables($hook, $vars));

To:
$vars = array_merge($vars, (array)_phptemplate_variables($hook, $vars));

Manually changing every array_merge call might not be the best solution - as it is ultimately the task of the calling theme to ensure that variables of the correct type are passed back to the template engine, imho.

#3

Zack Rosen - July 2, 2005 - 00:57
Priority:normal» critical

#4

factoryjoe - July 2, 2005 - 03:11
Project:CivicSpace Theme» PHPTemplate
Version:HEAD» <none>
Priority:critical» normal

This is not a CivicSpace theme issue but a PHPTemplate problem.

#5

stevryn - September 20, 2005 - 13:09

I get these array_merge errors when using any of the Civicspace themes, but not with any other PHPTemplate themes. So is the fix to this to change the PHPTemplate engine, and how or what does one do to it to fix it?

#6

stevryn - September 21, 2005 - 18:28

Fix in #2 worked for the array errors, thanks!

#7

venkat-rk - October 5, 2005 - 16:08

Stuck with the same problem. Any suggestions *exactly* where to change that line?

Interestingly, I thought this was a problem with XAMPP which I had installed locally. It uses PHP5. But, I uploaded the same set of files to my hosting server which runs php4> and never got this error.

#8

stevryn - October 5, 2005 - 19:53

I also use XAMPP.

In phptemplate engine file look here:

*   A suggested template file to use.
* @return
*  The HTML generated by the template system.
*/
function _phptemplate_callback($hook, $vars = array(), $file = null) {
  $vars = array_merge($vars, (array)_phptemplate_default_variables($hook, $vars));
  // Allow specified variables to be overridden
  if (function_exists('(array)_phptemplate_variables')) {
    $vars = array_merge($vars, (array)_phptemplate_variables($hook, $vars));

This is what mine looks like now, and I do not get array errors anymore.

#9

Morbus Iff - November 22, 2005 - 18:07
Status:active» won't fix

Won't fix. This is a Civicspace theme issue (in 81rc, they were not returning an array through _phptemplate_variables, which caused the errors). In 82rc5, however, they ARE returning an array, so this error should go away. Regardless, forcing an array inside PHPTemplate isn't the answer: the template itself should take care to just follow the IO that PHPTemplate expects.

 
 

Drupal is a registered trademark of Dries Buytaert.