I just got the following warning:
"Warning: Parameter 1 to book_made_simple_node_insert() expected to be a reference, value given in module_invoke_all() (line 817 of /var/www/includes/module.inc)."

Not exactly sure why, but my setup is fairly straightforward: I have a single content type that I have all book-related settings locked down to, i.e. this content type is the only one that can be a main book page as well as the only one that can be a child book page.
Not sure if that's relevant or not.

If you want more info let me know.

Comments

MarcElbichon’s picture

Node parameter wouldn't be passed by reference. Will correct it. To do this replace line in book_made_simple.module

function book_made_simple_node_insert(&$node) {
by
function book_made_simple_node_insert($node) {

But this will not correct your problem cause node parameter need to be a node object, not at value.
I don't know why a value is passed.
Can you have a look to lastest error report ?
Can you list other used modules ?
In these module, can you search a line like '_node_insert(' ?

spineless’s picture

I am getting the same error as Shadlington.

Warning: Parameter 1 to book_made_simple_node_insert() expected to be a reference, value given in module_invoke_all() (line 817 of /home/www/site/includes/module.inc).

I am using a fresh install of Drupal 7 on a Ubuntu 10.10 server. The only module installed is book_made_simple.

There is no error report generated inside of my Drupal 7 website.
I checked the system log in /var/log/apache2 and it did not show an error related to this.

I also checked the book_made_simple.module and I see you already corrected the (&node) line. I also checked the module.inc file and noticed line 817 is half way through the function module_invoke_all(). I am not sure what this is doing.

Have you been able to troubleshoot this error yet?
Where would I find the error report that would capture this issue?

Can you give me a little help as to why this error is generated?

MarcElbichon’s picture

Can you add this line echo "===>$node" just after node_insert() function declaration in book_made_simple.module to see value given to the function ?
which version of Drupal do you use ?
According to Drupal API, first parameter must be the node to be inserted. I could test if parameter is an object and if not , load the node with the given value, but hope the given value is the node number !!
To do this, add this lines just after node_insert() function


if (! is_object($node)) { 
   $node = node_load($node);
}
spineless’s picture

I am using Drupal 7.

I attempted to add the line echo "===>$node" to the book_made_simple.module but it caused the site to crash. Here is the code snippet. Can you please give me some detail as to how to code this.

function book_made_simple_node_insert(&$node) {
if (empty($node->book["bid"])) {
$type = $node->type;
$max_depth = variable_get('book_made_simple_limit_depth', 99);
$isDepthAllowed = true;
if (array_key_exists('depth', $node->book)) {
$isDepthAllowed = ($node->book['depth'] < $max_depth);
}
if ((user_access('add content to books') || user_access('administer book outlines')) &&
node_access('create', $type) && $isDepthAllowed) {
$bookTypes = variable_get('book_made_simple_auto_main_page', array());
$bookType = (array_key_exists($type, $bookTypes) ? $bookTypes[$type] : null);
$toCreate = false;
if (null != $bookType && $bookType != "0") {
$toCreate = true;
}
if ($toCreate && ! isset($_GET['parent'])) {
$node->book["bid"] = $node->nid;
$node->book['nid'] = $node->nid;
$node->book['module'] = 'book';
$node->book['menu_name'] = book_menu_name($node->book['bid']);
_book_update_outline($node);
}
}
}
}

echo "===>$node"
if (! is_object($node)) {
$node = node_load($node);
}

/*

function book_made_simple_node_prepare_translation($node)
{
// Hack for translation module. Adding parent property to automatically select parent book.
$translation = $node->translation_source;
if (isset($translation->book) && (! isset($_GET["parent"])))
{

MarcElbichon’s picture


function book_made_simple_node_insert($node) {
   echo "===>$node"; //To remove after debug
   if (! is_object($node)) {
     $node = node_load($node);
   }
   .....
}

Echo line will print a value at top of page. Please give me this value and remove the line.
Don't forget to replace &$node by $node in parameters of the function

spineless’s picture

Ok So I was able to make the changes you asked for. Here is the error I encountered when I attempted to create a new page.

Recoverable fatal error: Object of class stdClass could not be converted to string in book_made_simple_node_insert() (line 616 of /home/www/site/sites/all/modules/BookMadeSimple/book_made_simple.module).

Maybe a little more information could be helpful.....

I have created a new "content type" which contains a number of questions using "fields" so it looks like a form the user needs to fill out. I provided a link in the "user menu" to point to this new content type. So when a user clicks on the link they will fill out the form and the form should then be posted in the book navigation.

Hope this helps,

spineless.

MarcElbichon’s picture

Given value seems to be a correct node. Can you try this

function book_made_simple_node_insert($node) {
   if (! is_object($node)) {
     drupal_set_message("===>$node"); //To remove after debug
     $node = node_load($node);
   }
   .....
}

This will only print message if $node is not a node object.

spineless’s picture

I removed the previous test code and changed it to the test code you mentioned last.

This time I did not get an error message... In fact there is no error. The module looks like it works. I tried retesting 6 times with this new code added and it worked.

I also removed the code and even rebooted my server to see if that would generate the error.

I will leave the code in place and keep working with the website. If an error gets generated again I will post it.

spineless’s picture

I did a couple more tests and found that the following code tends to not show any errors.

function book_made_simple_node_insert($node) {
   .....
}

When I remove the '&' symbol from the ($node) the error goes away. I am wondering if the php version I have might be different then your version and doing something different. I am running the following:

Linux server Ubuntu 10.10 on a DELL PowerEDGE-830 server
Apache/2.2.16(Ubuntu)
MySQL Client API version 5.1.49
Drupal 7 with only one modules (BookMadeSimple)

I do not know enough about php to be much more help. As I mentioned the error looks like it has gone away for now. If I have more information I will post it.

Spineless

MarcElbichon’s picture

What is your PHP version ?

spineless’s picture

Sorry about that.

PHP Version 5.3.3-1ubuntu9.3

I am guessing that there is a special version of PHP 5.3.3 for Ubuntu Linux. When I bring up the phpinfo page the "Core" is listed as PHP version: 5.3.3-1ubuntu9.3.

MarcElbichon’s picture

This may be a PHP 5.3 bug. See http://bugs.php.net/bug.php?id=50394
In all cases, &$node would be changed to $node to be in phase with Drupal API

MarcElbichon’s picture

Status: Active » Closed (fixed)
bcn’s picture

Status: Closed (fixed) » Active

Was a fix for this ever was committed? It looks like the latest dev version includes the following code:

function book_made_simple_node_insert(&$node) {

http://api.drupal.org/api/drupal/modules--node--node.api.php/function/ho... says it should be:

function hook_node_insert($node) {
....
}
MarcElbichon’s picture

Status: Active » Closed (fixed)

Commited in dev version.

scottrigby’s picture

Project: Book made simple (Obsolete) » Book made simple