Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
In 5.x the following code would redefine the comment "delete" link to point somewhere else:
function module_link($type, $object = NULL) {
if ($type == 'comment') {
$links['comment_delete'] = array(
'title' => t('delete'),
'href' => 'other/delete/something',
);
return $links;
}
}
In 6.x, it causes a WSOD after hanging for a few seconds. :(
This is because instead of a strings being passed into url() and check_plain(), they're instead arrays, as the link now looks like this:
array
'comment_delete' =>
array
'title' =>
array
0 => string 'delete' (length=6)
1 => string 'delete' (length=6)
'href' =>
array
0 => string 'comment/delete/1' (length=16)
1 => string 'module/comment/1' (length=16)
Trying to track this down to see where the change was introduced.
Comments
Comment #1
webchickOh, incidentally, the node equivalent for this works fine. Also, echo 'something'; at the top of index.php will remove the WSOD in favour of barfing out errors everywhere:
# notice: Array to string conversion in /Users/webchick/Sites/6x/includes/common.inc on line 1270.
# notice: Array to string conversion in /Users/webchick/Sites/6x/includes/bootstrap.inc on line 715.
# warning: preg_match() expects parameter 2 to be string, array given in /Users/webchick/Sites/6x/includes/bootstrap.inc on line 718.
These are all related to url() and check_plain() being passed arrays rather than strings.
Comment #2
dvessel CreditAttribution: dvessel commentedI don't know how to fix this but it looks like how the links are altered. We use drupal_alter now, it used to be HOOK_link_alter.
http://api.drupal.org/api/function/comment_render
Comment #3
vladimir.dolgopolov CreditAttribution: vladimir.dolgopolov commentedThis related with nodes too:
(1) Create 2 modules with only hook_link():
Module 1:
Module 2:
(2) Create any node (a 'Page' e.g.)
(3) View the node (node/{nid})
You can see the notices and warning.
It's because of:
Comment #4
vladimir.dolgopolov CreditAttribution: vladimir.dolgopolov commentedThis is a test for the issue:
Comment #5
catchMoving back to D6, hook_link() is dead in Drupal 7.
Comment #6
dpearcefl CreditAttribution: dpearcefl commentedIs this an issue in current D6?
Comment #7
dpearcefl CreditAttribution: dpearcefl commented