No child nodes are created

Martin Mayer - January 13, 2009 - 22:59
Project:Skeleton outlines
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed
Description

When I try to create a new instance of a book with the skeleton I receive the following warning: "warning: Invalid argument supplied for foreach() in ...\htdocs\drupal68\sites\all\modules\skeleton\skeleton_token.inc on line 210.". The book is created but without child nodes. I tried this with a very simple skeleton which has only two templates assigned which consit of simple pages.

#1

deviantintegral - January 14, 2009 - 01:12
Status:active» needs review

Thanks for the bug report. It looks to happen when no custom tokens are defined. Can you try this patch and see if it fixes it?

Thanks,
--Andrew

AttachmentSize
358436_no_custom_tokens.patch 2.46 KB

#2

Martin Mayer - January 14, 2009 - 11:03

Thank you for your quick reaction. I tried the patch but it does not seem to make a difference. I still get the same message and no child nodes are created.

#3

deviantintegral - January 20, 2009 - 19:41
Status:needs review» needs work

Does that at least solve the token error messages for you? For me it does, but doesn't address the issue with the child nodes.

I believe there are actually two problems here - I'm going to open a new issue for the token messages.

The other issue is related to creating any nodes which are not of the "Book page" type. I think this might be an issue in core, which I've filed over at #360377: book_get_books() cache becomes stale when batch-inserting book pages. It looks like the problem is that the drupal_execute() ends up calling book_get_books(), which has a stale copy of the list of books which doesn't include the newly created book. It may be that Skeleton is doing something wrong though.

I will investigate and either post a patch dependent on #360377: book_get_books() cache becomes stale when batch-inserting book pages or something else :)

#4

Martin Mayer - January 21, 2009 - 23:43

Hi,
I tested the different variations. Here is the result:

1. If I create an instance of a skeleton with book pages as child nodes and use skeleton replacement tokens it works. That means the book is created and there are no error messages.

2. If I create an instance of a skeleton with book pages as child nodes but use no skeleton replacement tokens the book is created but the message "warning: Invalid argument supplied for foreach() in ...\htdocs\drupal68\sites\all\modules\skeleton\skeleton_token.inc on line 210." is displayed.

3. If I create an instance of a skeleton with normal pages (no book pages) as child nodes and use skeleton replacement tokens there is no book created. An error message is displayed: "An illegal choice has been detected. Please contact the site administrator."

4. If I create an instance of a skeleton with normal pages (no book pages) as child nodes and use no skeleton replacement tokens there is no book created. Two messages are displayed: "warning: Invalid argument supplied for foreach() in ...\htdocs\drupal68\sites\all\modules\skeleton\skeleton_token.inc on line 210." and "An illegal choice has been detected. Please contact the site administrator."

I hope the confusion is complete now :-)

Cheers
Martin

#5

deviantintegral - January 22, 2009 - 17:56

Thanks Martin for your testing. It's appreciated!

I believe the patch over at #361658: Warnings if no custom tokens have been defined will remove all errors related to skeleton_token.inc. Please try it out if you can.

As for the illegal choice errors in #3 and #4, at the core it's related to #360377: book_get_books() cache becomes stale when batch-inserting book pages. I will post a patch / instructions soon.

#6

Martin Mayer - January 23, 2009 - 22:32

Hi Andrew, I had the patch already installed when I did the tests I described in post #4. The warnings came anyway. Cheers, Martin

#7

deviantintegral - January 26, 2009 - 18:50

Strange... will have to keep looking into that.

I ran into another core static cache which was breaking things :(. It causes problems when you have child of child pages which aren't book pages. Issue is over at #364529: menu_tree_all_data() static cache can become stale.

#8

deviantintegral - January 27, 2009 - 18:37
Status:needs work» needs review

Here's an update:

Applying #360377: book_get_books() cache becomes stale when batch-inserting book pages allows the book parent page to be any content type with properly attached children, not just a book page.

Applying #364529: menu_tree_all_data() static cache can become stale plus the attached patch allows "children of children" to be of any content type. The attached patch may not be needed when the core issue is resolved - it's a design decision that hasn't been made yet.

Can you verify that doing the above solves any "illegal choice" errors for you?

AttachmentSize
358436_rebuild_menu_cache.patch 1.27 KB

#9

deviantintegral - January 27, 2009 - 18:49

#10

Martin Mayer - January 29, 2009 - 19:34

I tested all versions like in post #4. It seems to work now. The same is true for "358436Warnings if no custom tokens have been defined"

#11

deviantintegral - January 31, 2009 - 22:40
Status:needs review» postponed

Thanks for the testing. I've committed the last patch to CVS so it hits the -dev release, and will be updating the module page with information about those core issues. When they are dealt with, this issue can be looked at to see if it's still needed.

 
 

Drupal is a registered trademark of Dries Buytaert.