Download & Extend

warning: array_merge() [function.array-merge]: Argument #2 is not an array in autocategorise.module on line 154

Project:autocategorise
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/topnet/public_html/drupal610/sites/all/modules/autocategorise/autocategorise.module on line 154.

any idea on what's wrong ?

Comments

#1

If this is the same error reported in http://drupal.org/node/466388 it has been
fixed in HEAD on June 9, but your report indicates that you are using 1.4 (May 15).

#2

sorry, what do you mean with "Fixed in HEAD" ?

also I don't see any further development beside 1.4 ?

#3

I believe it's fixed in the developer repository. I am not familiar with it, but I sometimes
checked releases out of it via cvs commands. See also:
http://drupal.org/node/133304
http://drupal.org/node/320

#4

why shall I have to look into CVS... I don't understand CVS things.

this module should be updated allready. anyway...

#5

Could someone post the solution?

Does the module work despite the error?

#6

I decided to use version 1.3 and its working fine! Love this module.
http://ftp.drupal.org/files/projects/autocategorise-6.x-1.3.tar.gz

#7

Title:The error I get» warning: array_merge() [function.array-merge]: Argument #2 is not an array in autocategorise.module on line 154
Category:support request» bug report

Fixed in HEAD? Looks like HEAD was not commited since
may 2009, so it cannot be fixed there.

But there is no error in DEV version from 2009-Aug-29.

Szy.

#8

Version:6.x-1.4» 6.x-1.x-dev
Status:active» needs review

It seems there has been an attempt to fix the problem in 6.x-1.x-dev but it doesn't fix it.

The problem is caused by an uninitialised variable.

Here is a patch against 6.x-1.x-dev that fixes the problem.

AttachmentSize
autocategorise-518258-8.patch 1011 bytes

#9

I think the problem stems from not testing if the $otherterms array is empty - if it is then Argument 2 ($otherterms) is not an array. By testing for this, I've overcome the problem. Here are the lines I added to the autocategorise.module in 6.x.1.4 from 154 to 158 which seem to have corrected the problem:

if ( empty( $otherterms )) {
} else {
$matches = array_merge($matches, $otherterms);
}

Never contributed code to someone else's Drupal module before so I'm not really sure how to get this included in a "dev" release.

#10

The patch I already made in #8 fixes this problem.

Array merge doesn't care if you pass it an empty array, only if you pass it something that is not an array.

Seeing as it is good coding practice to initialize variables anyway, that's all that needs to be done.

#11

Status:needs review» fixed

This is fixed in the latest -dev release.

#12

Status:fixed» closed (fixed)

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