I use php5, mysql 4.0.24 and drupal 4.6.8

This error occurs when using weekly.modules listing. But it does show the nodes.

Placering	/week/2006/06/04
Besked	
array_merge() [function.array-merge]: Argument #1 is not an array i /customers/denmarkonline.dk/denmarkonline.dk/httpd.www/includes/menu.inc on line 351.

Menu.inc version:
menu.inc,v 1.79.2.5 2006/03/14 15:26:04 unconed Exp $

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Prometheus6’s picture

Project: Week Field » Drupal core
Version: 4.6.x-1.x-dev » 4.6.8
Component: Code » menu system
Assigned: Unassigned » Prometheus6
Status: Active » Needs review
FileSize
514 bytes

This is what I found, which makes me refile it as a bug vs. menu.inc.

The menu item in week.module that causes the problem:

function week_menu() {
  $items[] = array('path' => 'week', 'title' => t('weekly archives'),
    'callback' => '_week_page', 'type' => MENU_CALLBACK,
    'access' => user_access('access content'));
  return $items;
}

And the section of menu.inc the error message is complaining about:

  // We found one, and are allowed to execute it.
  $arguments = array_key_exists('callback arguments', $menu['items'][$mid]) ? $menu['items'][$mid]['callback arguments'] : array();
  $arg = substr($_GET['q'], strlen($menu['items'][$mid]['path']) + 1);
  if (strlen($arg)) {
    $arguments = array_merge($arguments, explode('/', $arg)); // line 351
  }

I'm not passing callback arguments. This section of code assumes I am, and PHP5 is a lot more sensitive about that sort of thing.

I offer the attached patch.

Dries’s picture

Will commit if someone can reproduce the problem, and confirm that this fixes the issue.

jvandyk’s picture

There should only be an error happening if the value for 'callback arguments' is not an array. The relevant code from HEAD:

 // We found one, and are allowed to execute it.
  $arguments = isset($menu['callbacks'][$path]['callback arguments']) ? $menu['callbacks'][$path]['callback arguments'] : array();
  $arg = substr($_GET['q'], strlen($path) + 1);
  if (strlen($arg)) {
    $arguments = array_merge($arguments, explode('/', $arg));
  }

So the patch just hides the error. We might check if it's an array and produce a helpful error message. But it should never be the case that 'callback arguments' is NOT set and an error occurs here.

Prometheus6’s picture

FileSize
593 bytes

Okay. This should be acceptable

  // We found one, and are allowed to execute it.
  $arguments = isset($menu['items'][$mid]['callback arguments']) ? $menu['items'][$mid]['callback arguments'] : array();
  $arg = substr($_GET['q'], strlen($menu['items'][$mid]['path']) + 1);
  if (strlen($arg)) {
    $arguments = array_merge($arguments, explode('/', $arg));
  }

I use isset() because the only way the original code could fail is if $menu['items'][$mid]['callback arguments'] is set but equals NULL.

I have no clue how that might have happened.

beginner’s picture

Version: 4.6.8 » x.y.z

How to reproduce?
Also, if it's a bug, it should be fixed in cvs first, and backported soon after.

Dries’s picture

Promotheus: how does that fix the problem? Or how would that affect the offending module?

The problem is that a module is incorrectly using the callback mechanism. Could you post the code of the offending module, so we can grok the problem a little bit better?

Dries’s picture

Nevermind, I figured it out by looking a bit closer to the previous comments.

Dries’s picture

Patch does not apply against CVS HEAD.

drumm’s picture

Status: Needs review » Needs work
Prometheus6’s picture

Version: x.y.z » 4.6.8
Status: Needs work » Needs review

The patch was submitted against 4.6.8, not CVS, and should still apply.

beginner’s picture

Version: 4.6.8 » x.y.z
Status: Needs review » Needs work

Precisely: as I said in #5!

Prometheus6’s picture

The bug exists in 4.6.8. It does not exist in cvs. Check #3, please.

Or don't fix the bug.

beginner’s picture

Version: x.y.z » 4.6.8
Status: Needs work » Needs review

You say the bug doesn't exist in 4.7 and HEAD?
Please accept my apologies.

Prometheus6’s picture

Done, of course

beginner’s picture

Version: 4.6.8 » 4.6.9
Status: Needs review » Reviewed & tested by the community
FileSize
840 bytes

Dries already commented on this one.
Also, I checked, this would indeed be a backport of a bug that is already fixed in 4.7 and cvs.

beginner’s picture

the patch I attached, is basically the same as the previous one, but conforms better to the patch guidelines.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Patch no longer applies.

beginner’s picture

Status: Needs work » Reviewed & tested by the community

I just checked, it does apply.
This must be applied to the 4-6 branch!

Dries’s picture

Oops, you're right. Committed to CVS HEAD. Thanks.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Erm, committed to DRUPAL-4-6.

beginner’s picture

:) thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)