Clone Access Alter API Error

v1nce - July 30, 2008 - 21:01
Project:Node clone
Version:5.x-2.5
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

Modules that wish to extend clone access with the clone_access_alter hook are not implemented due to the $access variable not being updated. The attached patch fixes this issue.

AttachmentSize
clone_access-patch.txt464 bytes

#1

pwolanin - July 31, 2008 - 02:26
Status:needs review» postponed (maintainer needs more info)

The function signature for _alter hooks is that the first param is passed by reference. Did you implement your hook as such?

#2

v1nce - August 11, 2008 - 13:30
Status:postponed (maintainer needs more info)» needs review

Yes, but your code is not updating the $access variable within the clone_access() function. See the node.module example code:

<?php
foreach (module_implements('nodeapi') as $name) {
   
$function = $name .'_nodeapi';
   
$result = $function($node, $op, $a3, $a4);
?>

$result variable is updated with the return value from hook_nodeapi.

#3

pwolanin - August 11, 2008 - 17:14
Status:needs review» by design

This is an _alter hook like hook_form_alter - there is not expected to be a return value. You need to declare the first parameter as passed by reference.

compare function clone_access($node):

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/node_clone/...

with:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/node_clone/...

where I use the 6.x drupal_alter() API function.

#4

v1nce - August 14, 2008 - 14:18
Status:by design» closed

Understood. Thank you.

 
 

Drupal is a registered trademark of Dries Buytaert.