It seems like when an annonymous user is visiting a Drupal site, dumping $node, returns an empty $node->path. When logged in, however, $node->path is effectively setup. The SQL runs fine, can't find out what's wrong with $node->path.

Any ideas?

Comments

budda’s picture

The problem is that the path_nodeapi() call that inserts the path attribute ($op = 'load') will never get called for anon users UNLESS they have been granted either 'create url aliases' || 'administer url aliases' permissions!

damien tournoud’s picture

Version: 5.x-dev » 6.x-dev

It feels like we could load the path attribute no matter what permissions the user have. This "bug" is also present in 6.x, so reassigning.

robloach’s picture

Component: node system » path.module
Status: Active » Needs review
StatusFileSize
new2.89 KB

This patch removes the check for the 'create url aliases' || 'administer url aliases' permissions.

damien tournoud’s picture

The user_access() check is still needed for every operation that is not "load". Please only remove it for that operation.

Damien

webchick’s picture

Status: Needs review » Needs work
robloach’s picture

Status: Needs work » Needs review
StatusFileSize
new2.51 KB

This patch uses user_access on everything except 'load'.

robloach’s picture

StatusFileSize
new787 bytes

A bit more elegant.

Christefano-oldaccount’s picture

This is my favorite issue of the month. And February just started!

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
Christefano-oldaccount’s picture

Whoops, I meant to mark it RTBC. Thanks, Moshe.

damien tournoud’s picture

+1, seems good to go.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Ugh, committed.

damien tournoud’s picture

Version: 6.x-dev » 5.x-dev
Status: Fixed » Patch (to be ported)

We need a backport for 5.x.

robloach’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new730 bytes

Moved to the DRUPAL-5 branch.

damien tournoud’s picture

Status: Needs review » Reviewed & tested by the community

Not much to say: applies cleanly, does what advertised :)

cburschka’s picture

Thank you ever so much for this! I've grown extremely tired of manually loading the alias from the database when I needed it in a node object.

mzafer’s picture

Subscribing

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

tommo’s picture

Title: Different $node->path for authenticated vs anonymous users » Isn't fixed in 5.x
Status: Closed (fixed) » Active

Hi, this is a bug I was interested in back in January, I put a site live having to use drupal_get_path_alias('node/'.nid) to set the path for anon users. I'm just developing a new site and noticed that this issue should be fixed.

I'm using Drupal 5.7 and pathauto 5.x-2.2 and am doing a node_load()

The path is there for me as administrator but not there for anonymous users. I haven't set any permissions for anonymous users but reading through this issue I'm assuming I shouldn't have to.

robloach’s picture

Status: Active » Fixed

Correction, this isn't fixed in Drupal 5.7. It will, however, be fixed in Drupal 5.8.... If you look at http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/path/path.module?r... , you'll see that the DRUPAL-5 branch has the fix, while the DRUPAL-5-7 tag (http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/path/path.module?r...) doesn't.

webchick’s picture

Title: Isn't fixed in 5.x » Different $node->path for authenticated vs anonymous users

Resetting title.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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