I get these errors when visiting admin/build/path/pathauto:

# warning: Invalid argument supplied for foreach() in /homepages/18/d93080087/htdocs/drupal6/sites/scratch.cambre.biz/modules/pathauto/pathauto_user.inc on line 103.
# warning: Invalid argument supplied for foreach() in /homepages/18/d93080087/htdocs/drupal6/sites/scratch.cambre.biz/modules/pathauto/pathauto_user.inc on line 78.
# You are using the token [user-raw] which is not valid within the scope of tokens where you are using it.
# warning: Invalid argument supplied for foreach() in /homepages/18/d93080087/htdocs/drupal6/sites/scratch.cambre.biz/modules/pathauto/pathauto.admin.inc on line 233.
# You are using the token [title-raw] which is not valid within the scope of tokens where you are using it.
# You are using the token [title-raw] which is not valid within the scope of tokens where you are using it.
# You are using the token [title-raw] which is not valid within the scope of tokens where you are using it.
# You are using the token [title-raw] which is not valid within the scope of tokens where you are using it.
# You are using the token [vocab-raw] which is not valid within the scope of tokens where you are using it.
# You are using the token [user-raw] which is not valid within the scope of tokens where you are using it.
# warning: Invalid argument supplied for foreach() in /homepages/18/d93080087/htdocs/drupal6/sites/scratch.cambre.biz/modules/pathauto/pathauto.admin.inc on line 233.
# You are using the token [user-raw] which is not valid within the scope of tokens where you are using it.
# warning: Invalid argument supplied for foreach() in /homepages/18/d93080087/htdocs/drupal6/sites/scratch.cambre.biz/modules/pathauto/pathauto.admin.inc on line 233.

Note that the bad argument errors could be related to http://drupal.org/node/277398.

Relevant software/modules:

  • Drupal 6.x (July 5)
  • Pathauto 2.x-dev (2008-Jun-28)
  • Token 6.x-1.10
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Aren Cambre’s picture

I did just now per your suggestion, and it reads: "When given the choice, you should use a -raw version of a token." So that further buttresses the idea that there is a bug somewhere.

greggles’s picture

The problem is that you are using tokens which are not available for the places you are using them. In that same document it says:

For "Content Patterns"

[user] should be [author-name-raw]
[cat] should be [term-raw]
[catpath] should be [termpath-raw]

Also, 6.x-2.x-dev is the unstable development version. You are probably going to be better off using 6.x-1.1 (and any subsequent 6.x-1.* releases) unless and until 6.x-2.x becomes stable and gets a stable release.

Aren Cambre’s picture

My apologies. Is this not the correct place to report issues found in the dev versions?

greggles’s picture

FileSize
167.89 KB

This is the correct place, I was just making a suggestion about versions to use if you are just trying to get your site work.

However, as far as I can tell this is not an "issue found in the dev version" but a misconfiguration. The module is trying to give you advice on how to configure it properly and I am doing the same.

So, I've now attached a screenshot of a similar "error" on a site of mine that is running 6.x-2.x-dev. Note that there are two arrows I've added to the drawing - #1 shows the error message at the top of the page. #2 shows the place where the misconfiguration is located which is highlighted with the text "NOTE: This field contains potentially incorrect patterns. Problem token: user-raw"

If you feel that your site is configured properly then please provide

1) The label for the textbox which Pathauto is reporting to be in error
2) The error message (the "NOTE: ..." part)
3) The pattern which you are using in that textbox

Aren Cambre’s picture

Thanks. I reported this as a bug because I did not change anything in Pathauto for these errors to appear. These appeared in its default state.

greggles’s picture

Status: Active » Postponed (maintainer needs more info)

In that case this is needs more info because I can't repeat that behavior.

Could you capture/upload a screenshot of your entire settings page?

Aren Cambre’s picture

FileSize
151.56 KB

The only two values I remember changing are inserting a custom "Node path setting" for "Article" and "Definition" content types. They were based on the value already in "Default path pattern." I got the errors visible at top before and after I inserted them.

Note again that I am running Drupal 6.x-Dev (July 5). Not sure if that makes a difference.

greggles’s picture

Which version of token module are you using?

Aren Cambre’s picture

Token 6.x-1.10

Aren Cambre’s picture

FileSize
219.19 KB

Here's the entire module list for the site.

bforchhammer’s picture

I get the same error with version 6.x-2.x-dev and Token 6.x-1.10...

The reason for the error messages seems to be that e.g. token_user.inc isn't loaded when the token_list hook is invoked in line 103 in pathauto_user.inc... for a quick fix you can just add the following lines to the end of the _pathauto_include() function in pathauto.module:

  if (function_exists('token_include')) {
    token_include();
  }

I guess that in some way the pathauto module should make sure that the token module is properly loaded when using it...

greggles’s picture

If you upgrade to token 6.x-1.x-dev does that fix it?

bforchhammer’s picture

No.

greggles’s picture

Then I'm still stuck on why this occurs for some users and not others (i.e. it doesn't occur for me).

ar-jan’s picture

I was using PathAuto 6.x-2.x-dev successfully on my Drupal 6.2 install. I just upgraded to 6.3 and now PathAuto says:
# warning: Invalid argument supplied for foreach() in /sites/all/modules/pathauto/pathauto_user.inc on line 103.
# warning: Invalid argument supplied for foreach() in /sites/all/modules/pathauto/pathauto.admin.inc on line 233.
# warning: Invalid argument supplied for foreach() in /sites/all/modules/pathauto/pathauto.admin.inc on line 233.
# warning: Invalid argument supplied for foreach() in /sites/all/modules/pathauto/pathauto_user.inc on line 103.
# warning: Invalid argument supplied for foreach() in /sites/all/modules/pathauto/pathauto.admin.inc on line 233.

And all tokens I used now get a "You are using the token [title-raw] which is not valid within the scope of tokens where you are using it."

Also the replacement patterns are no longer explosed to PathAuto.
It does not seem to be a Token problem, I also use UploadPath and it functions properly with tokens. I use Token 6.x-1.x-dev.

This seems to be the same issue. Strange thing is it was happening to Aren on Drupal 6.2 (I assume), and for me it started only after upgrading to 6.3. Does this help anything?

Aren Cambre’s picture

I was using Drupal 6.x (July 5), which was prelease 6.3. But now that 6.3 final is out, I still get the errors.

ar-jan’s picture

Well, I was using 6.2 initial release, apparently something was changed towards Drupal 6.3. Maybe some "security fixes" are influencing something that PathAuto works? If that's not the case maybe someone could confirm that a 6.3 install can have PathAuto working without errors?

Anyway, workaround/fix in #12 is enough for me now ;)

Aren Cambre’s picture

Status: Postponed (maintainer needs more info) » Needs review

Seems like a patch is available then...

greggles’s picture

Status: Needs review » Postponed (maintainer needs more info)

Well, it's not a patch.

Also, a quick review of the token.module shows that in every function Pathauto calls there is also a call to token_include.

There are enough people experiencing this that it seems like a bug, but it's not reproducible. I don't want to make a fix in Pathauto if/when the problem is really somewhere else.

bforchhammer’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.19 KB

Hm, you're right greggles, the real problem is a different one...

The token module doesn't seem to be used properly in pathauto_user.inc: is used the following line to get the list of tokens for contact forms and trackers:

$patterns = module_invoke_all('token_list', 'user');

... where it should be:

$patterns = token_get_list('user');

Attached is a patch (against HEAD) that should fix the problems in pathauto_user.inc.

greggles’s picture

Thanks for digging into this issue and identifying the precise problem. I'm not sure why pathauto_user.inc calls those differently than the other pathauto_*.inc files do.

@ArjanLikesDrupal and @Aren Cambre - does this patch solve the problem for you?

Aren Cambre’s picture

The patch in #21 causes the errors described at the top to disappear.

ar-jan’s picture

Confirming. I applied the lines manually to 2.x-dev and everything works.

I now see that the reason I did not have errors before was I had not enabled my contact form. I never noticed PathAuto's errors in between enabling the contact form and upgrading to D6.3...

Aren Cambre’s picture

Can you clarify? I never enabled a contact form as far as I know.

ar-jan’s picture

Hm, I was just speculating: using Drupal 6.2 + PathAuto 6.x-2.x-dev + Token 6.x-1.x-dev, everything was working. At some point it stopped working and the change was either upgrading to 6.3 or enabling the contact form, because none of the other stuff changed. Maybe it's still the 6.3 upgrade that did it, I don't know how the code works so actually I just couldn't say, never mind my speculations ;) At least it's fixed now!

Aren Cambre’s picture

I think the 6.3 upgrade is the strongest case.

bforchhammer’s picture

You can reproduce the error by setting up a clean Drupal 6.3 and installing/enabling modules Token, Pathauto, Contact and Tracker. That's what I did and I didn't get an error before I enabled the Contact or Tracker module...

greggles’s picture

Status: Needs review » Fixed

@bforchammer - that works to reproduce the error for some people but not all (like, not for me). I do that pretty regularly (and just did it again) and I haven't ever seen these problems.

That said, thanks very much for providing the patch. I've committed it to 5.x-2.x, 6.x-1.x and 6.x-2.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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