Hi,
I've just moved my current drupal 5.1 database (phpmyadmin export/import) and all the files, including the files directory above the root using ftp. Everything seems to function and there are no substantial differences between the two hosts but my domain switched from domain.com to domain.net.

I am using a modified pushbutton theme and have added template.php, field.tpl.php, user_profile.tpl.php files. These are working just fine in my current domain.com but at the domain.net I'm getting the following error:

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /home/user/public_html/themes/engines/phptemplate/phptemplate.engine on line 365

Warning: Invalid argument supplied for foreach() in /home/user/public_html/themes/engines/phptemplate/phptemplate.engine on line 366

referring to this part in the phptemplate.engine

  // Loop through any suggestions in FIFO order.
  $suggestions = array_reverse($suggestions);
  foreach ($suggestions as $suggestion) {
    if (!empty($suggestion) && file_exists(path_to_theme() .'/'. $suggestion . $extension)) {
      $file = path_to_theme() .'/'. $suggestion . $extension;
      break;
    }

I did read another topic and switched to the garland theme and the errors disappeared. But I'm wondering why it would work on one site and not the other. Someone else mentioned something about changing any instances of the .com in the new domain database. Is this something I should do? But if so, why wouldn't that affect the garland theme?

The other thing that's strange is that these errors show up but when they end the site page displays correctly.

What does this error mean?
Thanks.
Lsabug

Comments

vm’s picture

have you cleared your cache tables in the database ?

lias’s picture

What does the error mean about Warning: array_reverse() [function.array-reverse]

I've deleted the template.php file and that removed the error. I'm going to reupload it again but without certain parts that I've added to see what causes the error. I'd like to know what array_reverse does or means though, I think it'd help troubleshooting.

Thanks for the suggestion.

vm’s picture

information about array-reverse can be found on php.net see: http://us2.php.net/manual/en/function.array-reverse.php

stewzy’s picture

not a pro, but I added the following to phptemplate.engine, and it seems to work...

// Loop through any suggestions in FIFO order.
if (is_array($suggestions)){

	  $suggestions = array_reverse($suggestions);
	  foreach ($suggestions as $suggestion) {
	    if (!empty($suggestion) && file_exists(path_to_theme() .'/'. $suggestion . $extension)) {
	      $file = path_to_theme() .'/'. $suggestion . $extension;
	      break;
	    }
	  }

}

juanfe’s picture

That fixes the problem, but you really don't want to do that yourself since then you'd be forking your drupal install, and could lose that fix if you upgrade. It's probably not so much a problem in phptemplate.engine as it is in the sample code that comes with CCK.

You can fix this with a change to the callback at the bottom of your phptemplate_field() function in your theme's template.php file.

Change

  return _phptemplate_callback('field_devices', $variables, 'field-'. $field['field_name']);

to

  return _phptemplate_callback('field_devices', $variables, array('field-'. $field['field_name']));

and your problem should go away. This happens because the phptemplate engine expects the third parameter of the callback to be an array, and the sample code in CCK suggests you pass in a scalar.

I spent a good day trying to figure this one out. Just submitted the bug report, should be an easy fix in HEAD.

JFR

lias’s picture

It worked for my change to a new host using drupal 5.x