Fatal error: on /admin/build/modules/list/ page

kenorb - July 5, 2008 - 14:17
Project:Drupal
Version:5.10
Component:system.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

When going to /admin/build/modules/list/ you receiving following fatal error:
Fatal error: Cannot use string offset as an array in /modules/system/system.module on line 1439
I know that isn't correct url, but there shouldn't be any fatal error, you can't handle it with default error page.

$form_values = string 'list' (length=4)
--
      if (!$module->status && $form_values['status'][$name] && isset($module->info['dependencies'])) {

So it mean that you can't use $form_values['status'][$name] when $form_values is a string.

#1

Damien Tournoud - July 5, 2008 - 18:14

Interesting.

I verified that it does not affect D6.x nor D7.x.

#2

teezee - September 2, 2008 - 12:10
Version:5.x-dev» 5.10
Status:active» needs review

This problem occurs when you visit the admin/build/modules/uninstall page before returning to the overview of installed modules in admin/build/modules/list. The *list* part is the problem here because it is passed as extra argument to the calling function (system_modules).

The system_modules function calls the confirmation form, which then calls the system_module_build_dependencies() where it all goes wrong.

Attached patch adds an extra check to the if statement, in the original situation only isset($form_values) is called, I've added an is_array($form_values) and another check inside the loop.

Please check the attached patch...

<?php
function system_module_build_dependencies($modules, $form_values) {
  static
$dependencies;

  if (!isset(
$dependencies) && isset($form_values) && is_array($form_values)) {
   
$dependencies = array();
    foreach (
$modules as $name => $module) {
     
// If the module is disabled, will be switched on and it has dependencies.
     
if (!$module->status && isset($form_values['status'][$name]) && $form_values['status'][$name] && isset($module->info['dependencies'])) {
        foreach (
$module->info['dependencies'] as $dependency) {
          if (!
$form_values['status'][$dependency] && isset($modules[$dependency])) {
            if (!isset(
$dependencies[$name])) {
             
$dependencies[$name] = array();
            }
           
$dependencies[$name][] = $dependency;
          }
        }
      }
    }
  }
  return
$dependencies;
}
?>

AttachmentSize
system.module.patch 1.03 KB

#3

tomsolo - October 21, 2008 - 08:07

i'm tested patch ok.

#4

earnie - October 21, 2008 - 12:14
Status:needs review» reviewed & tested by the community

Based on #3.

#5

drumm - November 13, 2008 - 02:11
Status:reviewed & tested by the community» fixed

Committed to 5.x. I wasn't able to reproduce the original issue, but more isset() and other checking is always good.

#6

System Message - November 27, 2008 - 02:13
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#7

dharmanerd - March 26, 2009 - 04:08

FYI. Same problem here. D-5.3. Patch works.

 
 

Drupal is a registered trademark of Dries Buytaert.