bookpathalias token broken

mikeque - May 6, 2008 - 14:19
Project:Pathauto
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:greggles
Status:closed
Description

I am trying to use pathauto to generate custom paths based on the top parent of a book. I have tried several different options including [menupath-raw], [book-raw] , and many others as the pattern for Book page paths. When I create a sub-page of a book, they all fail silently, except for [nid] and [title-raw].

Have I made an error in the pathauto admin or is this a bug?

#1

mikeryan - May 6, 2008 - 16:08
Project:Pathauto» Token
Version:6.x-1.0» 6.x-1.10
Component:Miscellaneous» Code
Status:active» duplicate

Duplicate of token issue http://drupal.org/node/223458, fixed in the 6.x-1.x-dev release.

#2

greggles - June 19, 2008 - 04:34
Title:[bookpathalias] and other node variables fail» [bookpathalias] not replaced
Project:Token» Pathauto
Version:6.x-1.10» 6.x-1.x-dev
Status:duplicate» active

Actually, bookpathalias is the responsibility of Pathauto so we need to fix that.

#3

greggles - June 20, 2008 - 16:35
Status:active» needs review

And here's a patch which does this.

I wish there were an API for getting the menu data but all of the menu API functions I could find expected me to have the menu router or path and then it would return the other data.

I also re-ordered the code so that the book stuff is separated from the term/cat stuff, but if we do that then maybe we need to do just that re-organization for 5.x as well.

AttachmentSize
255286_pathauto_bookpathalias_update_for_6x.patch 2.27 KB

#4

Freso - June 20, 2008 - 18:53
Status:needs review» reviewed & tested by the community

Default node pattern: [title-raw]
Book page pattern: [bookpathalias]/[title-raw]

Making a "book page" on the top level triggers a couple of notices:

  • notice: Undefined offset: 0 in /srv/http/localhost/htdocs/drupal6/sites/all/modules/token/token_node.inc on line 228.
  • notice: Undefined offset: 0 in /srv/http/localhost/htdocs/drupal6/sites/all/modules/token/token_node.inc on line 237.
  • notice: Undefined property: stdClass::$parent in /srv/http/localhost/htdocs/drupal6/sites/all/modules/pathauto/pathauto.module on line 107.

The last one goes away with the patch applied.

Making a node "Super" as the top-level book entry creates a node with the alias "super". Pre-patch, making a node "Sub" as a child node of "Super" creates alias "sub". Post-patch, making child node "Sub 2" creates the alias "super/sub-2".

Marking RTBC.

#5

Freso - June 20, 2008 - 18:56

Eh. Oh, one more thing though. The SQL query is surrounding by superfluous double quotes. The attached patch is the one I tested - it is basically identical to the one in #13, it's just got a pair of double quotes changed to a pair of single quotes. :)

#6

Freso - June 20, 2008 - 18:57

Or... not attached. Let's try again.

#7

Freso - June 20, 2008 - 18:57

That bug is really annoying.

#8

Freso - June 20, 2008 - 18:58

#9

Freso - June 20, 2008 - 18:58

#10

Freso - June 20, 2008 - 19:00

Bloody hell. I give up.

I changed
+                $parent_node = db_result(db_query("SELECT link_path FROM {menu_links} WHERE mlid = %d", $object->book["p$i"]));
to
+                $parent_node = db_result(db_query('SELECT link_path FROM {menu_links} WHERE mlid = %d', $object->book["p$i"]));

#11

greggles - June 20, 2008 - 20:04
Title:[bookpathalias] not replaced» bookpathalias token broken
Version:6.x-1.x-dev» 5.x-2.x-dev
Assigned to:Anonymous» greggles
Status:reviewed & tested by the community» patch (to be ported)

Fixed. Now to make the code structures a little more consistent...

AttachmentSize
255286_5x_code_flow_sync.patch 2.03 KB

#12

greggles - June 20, 2008 - 20:50
Status:patch (to be ported)» fixed

I didn't commit that last patch...if this lack of similarity becomes a problem in the future we can worry about it then.

#13

greggles - June 21, 2008 - 18:32

Well, now I accidentally committed the patch from #11 as part of http://drupal.org/cvs?commit=122748

So, yay synchronization!

#14

Anonymous (not verified) - July 5, 2008 - 18:33
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.