Type php
Date Sunday, August 12, 2007 - 12:22pm
User Earth & Economy
Location http://earthandeconomy.com/admin/settings/pathauto
Referrer http://earthandeconomy.com/admin/settings/pathauto
Message Invalid argument supplied for foreach() in /public_html/sites/all/modules/pathauto/pathauto_node.inc on line 22.
Severity error

Steps to reproduce:

Installed August 11th build of pathauto after receiving update from Update Status module (5.x-2.0-rc2).

Configured pathauto in conjunction with Token 5.x-1.x-dev (2007-Aug-04).

Click on save configuration (/admin/settings/pathauto). After saving configuration visit watchdog (admin/logs/watchdog) for error.

Refer to attached PDF for pathauto configuration (using tokens).

Comments

greggles’s picture

Status: Active » Postponed (maintainer needs more info)

Can you try again with the 5.x-2.0-BETA and the token 5.x-1.8 ?

Thanks.

entendu’s picture

Confirmed, pathauto 2.0 beta 1 (aug 13 build) on Drupal 5.2

entendu’s picture

Whoops, forgot to note -- was using Token 5.x-1.8

earthandeconomy’s picture

StatusFileSize
new71.42 KB

I received the same error for 5.x-2.0-BETA and the token 5.x-1.8:

Type php
Date Monday, August 13, 2007 - 9:22pm
User Earth & Economy
Location http://earthandeconomy.com/admin/settings/pathauto
Referrer http://earthandeconomy.com/admin/settings/pathauto
Message Invalid argument supplied for foreach() in /public_html/sites/all/modules/pathauto/pathauto_node.inc on line 22.
Severity error

Saving the configuration one time actually causes multiple errors in watchdog (refer to attached).

rootwork’s picture

I'm getting this too -- also with most up-to-date versions of pathauto and token.

entendu’s picture

StatusFileSize
new14.47 KB

It would appear that $patterns[$pattern_type] isn't always an array, which is obviously a problem for foreach(). I've attached a stopgap that will prevent the warning condition from occurring.

entendu’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new14.47 KB

It would appear that $patterns[$pattern_type] isn't always an array, which is obviously a problem for foreach(). I've attached a stopgap that will prevent the warning condition from occurring.

entendu’s picture

StatusFileSize
new1.5 KB

So, I diff'd my fix against an old 1.1 version I was using. By bad -- it's later than I thought. Here's the legit code, sorry!

greggles’s picture

Status: Needs review » Needs work

Well, I'd rather find/fix the problem than silence the error.

Did you all run update.php ?

There are two things in there that need to run. I'll be available most of today in #drupal if you can join me there to debug this live.

tony_addyman’s picture

Just to confirm that I am seeing this error on several sites. The number of error messages varies between the sites. I am using pathauto-5.x-2.0-beta1 and token-5.x-1.8. I definitely ran update.php on the sites.

greggles’s picture

So, just in case it isn't clear, the easy workaround is to simply move back to Pathauto5.x-1.2.

I'll try yet another fresh install and see if I can reproduce the problem. Otherwise I'm really going to need someone with the problem to show up in #drupal and find me so we can debug interactively. If you don't like IRC then send me a contact message with some IM information.

entendu’s picture

I can get with you on this later this afternoon (pacific time).

Question however, is $patterns[$pattern_type] always supposed to be an array? I admit I didn't dig in too deeply, so I'm not sure.

entendu’s picture

Greggles, have you tried reproducing on a php 4 system?

mr.andrey’s picture

I'm getting the same error with Aug-13 release of 2.0-beta1 with Token 1.8.

mr.andrey’s picture

Besides this error, the Category module tokens have disappeared:
[categorypath]
[categorypathfirst]
and others.

Any ideas?

tony_addyman’s picture

StatusFileSize
new740 bytes

I have been doing a bit of digging using devel and dpr(). Please forgive any stupidity on my part. I have a lot of experience with computers, but very little (yet) with PHP and Drupal. The problem appears to be related to the expectations associated with this line of code:
$pattern_types = array('node', 'book', 'CCK text', 'CCK node reference', 'CCK number', 'CCK user reference', 'CCK link');
I have examined several of my sites and none of the arrays returned by the call of token_get_list() have all these as indices. On one site the only indices are: 'book', 'node' and 'global'; on the other two the indices are 'book', 'node', 'CCK text', 'CCK image', 'CCK number', 'CCK node reference' and 'global'. I don't know if it matters that these have 'CCK image' which is not being selected by the foreach loop - I suspect it does. However none of these have either 'CCK user reference', or 'CCK link'. The attempt to select the missing array element is causing the error. I have attempted to fix things by using array_keys to obtain the keys of the array. I don't know if this does that does what is required, because I don't understand the code. However, it prevents the error from occurring, which is a step forward. I have attached a patch file. I hope it is OK.
Tony

greggles’s picture

Project: Pathauto » Yoruba
Version: 5.x-2.x-dev »
Status: Needs work » Fixed

@tony_addyman - thanks for your help! While your solution isn't the one I ultimately am going to use, at least you hit on the exact problem. As did dsantangelo though his patch didn't kick me in the head in quite the same way ;)

Anyway, I've just committed a patch which fixes this.

Thanks you guys for testing this out and reporting the problem. I know that it takes a leap of faith to try out the Beta software and I appreciate your patience on this. I'll tag and release a new version tomorrow or so in case there are some other big issues like this.

greggles’s picture

Project: Yoruba » Pathauto
Version: » 5.x-2.x-dev

How did I move this to the wrong project so horribly?

earthandeconomy’s picture

Tested the patch and it works for now. Thanks for being such a supportive community, really appreciate it. We are doing thorough testing in production before we officially start promoting the site so we can afford to take risks at this stage. Happy to test more new functionality anytime...

PS, pathauto helped to achieve a few SERPs for pages created from three posts using "borrowed" (Wiki) content. When combined with metatags there is potential to do some great SEM. Can't wait to start producing original content and launch the site.

Regards,

E&E

jsimonis’s picture

Which patch should we use? We're using the newest versions of both modules (downloaded today), but are getting this error.

Thanks!

greggles’s picture

Should be no need to worry about a patch - just get the beta2 or the -dev version.

earthandeconomy’s picture

Tested 5.x-2.0-beta2 and works good, thanks.

mr.andrey’s picture

Beta2 works good, thanks!

Andrey.

mr.andrey’s picture

Spoken a little too soon.

The [categorypath] and [categorypathfirst] patterns that are part o the Category module do not show up in the list and do not work if entered. This used to work prior to beta1 release. Should I file a separate issue on this?

Thanks,
Andrey.

greggles’s picture

@mr.andrey It would be a new issue except that I filed this with the category module back in April when I started this work: http://drupal.org/node/139649 Perhaps now they'll be more motivated to implement it ;)

Anonymous’s picture

Status: Fixed » Closed (fixed)