[support] “Parameter expected to be reference, value given” error in menu page callback

Gordon Heydon gordon at heydon.com.au
Thu Mar 1 22:34:53 UTC 2012


Hi,

basically monographs_node_check() should not require a reference when it is being called from the menu.

change the function call to

function monographs_node_check($node, $type)

Also since you are most likely using php 5.x and $node is an object it gets passed by reference anyway.

Gordon.

On 02/03/2012, at 9:14 AM, Steve Edwards wrote:

> I have a custom module that adds a couple action links via menu items:
> function monographs_menu() {
>   $items['node/%node/clone_comment'] = array(
>     'access callback' => 'clone_access_cloning',
>     'access arguments' => array(1),
>     'page callback' => 'monographs_node_check',
>     'page arguments' => array(1, 2),
>     'title' => 'Create For Comment version',
>     'type' => MENU_LOCAL_ACTION,
>   );
> 
>   $items['node/%node/clone_authorized'] = array(
>     'access callback' => 'clone_access_cloning',
>     'access arguments' => array(1),
>     'page callback' => 'monographs_node_check',
>     'page arguments' => array(1, 2),
>     'title' => 'Create Final Authorized version',
>     'type' => MENU_LOCAL_ACTION,
>   );
> 
>   return $items; 
> }
> and the function signature for the page callback is
> 
>   function monographs_node_check(&$node, $type)
> 
> On my local machine and my dev server, this all works just peachy. However, on the client's server, with a clone of my db and the repo, whenever this link is clicked on, they get a WSOD and this error in watchdog:
> 
> Warning: Parameter 1 to monographs_node_check() expected to be a reference, value given in menu_execute_active_handler() (line 517 of ...\public_html\includes\menu.inc).
> 
> Since it's on a remote server that I don't have access to, I can't debug it, but the fact that it works without error on my own local machine and dev server makes it even weirder.
> 
> What could be different in the other environment that would cause this error?  I've found some info that it could be related to PHP 5.2 vs 5.3 (in my case, it's working on 5.2, and the client server is on 5.3.8), but I have a feeling there would be a lot more sites having problems if that was the case.
> 
> Thanks.
> 
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120302/5e3f9775/attachment.html 


More information about the support mailing list