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.

CommentFileSizeAuthor
Cspace_081_PHP5.gif94.82 KBdggreenberg

Comments

cypherpunk’s picture

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.

cypherpunk’s picture

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.

Zack Rosen’s picture

Priority: Normal » Critical
factoryjoe’s picture

Project: CivicSpace Theme » PHPTemplate
Version: master »
Priority: Critical » Normal

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

stevryn’s picture

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?

stevryn’s picture

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

venkat-rk’s picture

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.

stevryn’s picture

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.

morbus iff’s picture

Status: Active » Closed (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.