Fatal error: Cannot use string offset as an array ...

erinc - December 10, 2006 - 05:44

I upgraded my website from 4.7 to 5.2 beta

1. I did the backup
2. Logged in as an admin
3. Removed all the old Drupal files and installed Drupal 5.2 beta.
4. Modified the new configuration file for database.
5. Run update.php and it went well.

However I get the following error while accessing any page:

Fatal error: Cannot use string offset as an array in /home/....I removed.../includes/theme.inc on line 532

Related thread?

glendac - December 10, 2006 - 06:36

This thread (http://drupal.org/node/68725) applied to previous Drupal versions but might shed light on the error you are getting with your upgrade to 5.2 beta.

thanks, according to your

erinc - December 10, 2006 - 06:57

thanks, according to your link, there was a problem in category.module . I don't think there is even a category.module in 5.0. Couldn't find it :)

You're right. The category

glendac - December 10, 2006 - 23:09

You're right. The category module that they're talking about in that thread is a contrib module. My 5.2 install is from scratch so the process was different from yours. Line 532 in includes/theme.inc is blank but the ff are the lines just before and after it. Perhaps somebody can take a look at what's wrong with the array offset:

function theme_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = '';

      // Automatically add a class to each link and also to each LI
      if (isset($link['attributes']) && isset($link['attributes']['class'])) {
        $link['attributes']['class'] .= ' ' . $key;
        $class = $key;
      }
      else {
        $link['attributes']['class'] = $key;
        $class = $key;
      }

      // Add first and last classes to the list of links to help out themers
      $extra_class = ($i == 1) ? 'first ' : (($i == $num_links) ? 'last ' : '');
      $output .= '<li class="'. $extra_class . $class .'">';

I have the same problem

xpete - February 21, 2007 - 00:39

... but on line 552.
Need help.

This appens when i try to see any article...
I can't find the problematic module.

Same problem

Eng.RamyMohie - March 20, 2007 - 14:26

I upgraded my website from 4.6 to 5.1

1. I did the backup
2. Removed all the old Drupal files and installed Drupal 5.1
3. Modified the new configuration file for database.
4. Run update.php and it went well.

PHP Fatal error: Cannot use string offset as an array in /var/www/html/includes/theme.inc on line 551

Need help.

This happens when i try to open the site

Change in hook_link

jvandyk - April 20, 2007 - 14:21

The solution to the error is to find out where hook_link() is implemented and update it. The error means that you have a module that is returning a simple array of links when it should be returning a structured array of links.

This is documented here.

Drupal 4.7 links messing up Drupal 5.0's theme_links function

mgifford - May 28, 2007 - 12:34

There is still the challenge of finding what module is sending along the bad links. Would be nice if this failed with something better than the white screen of death. In anycase, by inserting this:

echo "! l $link k $key a "; print_r($attributes);

above the fatal php error:

$link['attributes']['class'] = $key;

I figured that it was most likely the volunteer_timeslots module that was causing me grief (as the output had a reference to volunteer). I then just moved this out of the sites/all/module directory and everything worked as it should.

Mike
--
OpenConcept | WLP | ox.ca
OO | Jean Crowder, MP

which modules are causing this?

frog - June 6, 2007 - 16:34

I'm still getting this error, and I've followed the thread and all the links to and from it. But not of the suggested problem modules are even installed on my system. I've removed any of my modules which didn't have upgrades for 5.1.

I got it to go away temporarily, but now it's back on line 552.

Remove All Non-Core Modules

mgifford - June 6, 2007 - 20:57

You can try removing all non-core modules and then slowly introducing modules to see which one is resulting in the error. Wish there was an easier way.

Mike
--
OpenConcept | WLP | ox.ca
OO | Jean Crowder, MP

i don't understand this.

frog - June 7, 2007 - 01:34

I've deleted all non-core modules from the server, and I STILL get this error. What's more, is this is my second upgrade to 5.1, and my first on the same host, had no problem with this.

custom php in blocks, themes & pages

mgifford - June 7, 2007 - 14:21

Also worth looking to see if you've used any custom php that might have some outdated functions in it. Sometimes just fliping themes (or removing the default theme can help you eliminate if that is the problem or not. Blocks & pages are a bit more difficult to track down. Blocks can be turned off (even using phpMyAdmin).

Can you view admin pages? That would clarify if it is a page issue or not.

Mike
--
OpenConcept | WLP | poped
OO | Jean Crowder, MP

Some hook_link help

DesignWork - June 8, 2007 - 12:26

Hi mgifford,

I´m trying to make a hook_link for a module but i can not figure out how to display an image in a link.....

I made a hook_link witch calls a theme funktion. But in my theme_myfile_links function i´m not abble to call an image... Any solution? I could not found anything in the api.

<?php

/**
* Implementation of hook_link()
*/

function myfile_link($type, $node = NULL, $teaser = FALSE) {
   
$links = array();

  if (
$type == 'node' && isset($node->myfile) && $teaser == TRUE) {
   
$links[] =  theme('myfile_links', $node);     
    }
  return
$links;
}

function
theme_myfile_links($node) {

   
$link = '<img src="/' . drupal_get_path('module', 'premium') . '/lock.png" alt="[P]" />';
   
  return
$link;
}
?>

Warm regards from cologne

dirk

Duplicate Question

mgifford - June 11, 2007 - 01:57

Hi Dirk,

Just so that there's some consistency here, I'm going to try to follow up a bit here:
http://drupal.org/node/150334

Mike
--
OpenConcept | WLP | ox.ca
OO | Jean Crowder, MP

 
 

Drupal is a registered trademark of Dries Buytaert.