Closed (won't fix)
Project:
Secure Pages
Version:
6.x-1.7-beta1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Nov 2008 at 01:54 UTC
Updated:
31 Mar 2009 at 11:10 UTC
Hi
Is it possible to get a check on the links parsed by hook_link_alter? I'm getting some errors with other modules using $links in non-standard ways.
Thanks
From:
<?php
/**
* Implementation of hook_link_alter().
*/
function securepages_link_alter(&$node, &$links) {
if (!variable_get('securepages_enable', 0)) {
return;
}
foreach ($links as $module => $link) {
if ($link['href']) {
?>
To:
<?php
/**
* Implementation of hook_link_alter().
*/
function securepages_link_alter(&$node, &$links) {
if (!variable_get('securepages_enable', 0)) {
return;
}
foreach ($links as $module => $link) {
if (is_array($link) && !empty($link['href'])) {
?>
Comments
Comment #1
alexmarkley commentedThis is actually manifesting as a bug for me:
PHP Fatal error: Cannot use object of type stdClass as array in /home/web/malexmedia/malexmedia/modules/contrib/securepages/securepages.module on line 187, referer: https://malexmedia.net/node/add/forum/9I haven't really had time to chase down the exact combination of factors that's causing this. For now, I've rolled my site back to a previous 6.x-1.x-dev version.
Comment #2
alan d. commentedJust a minor correction to my code above, there should have been an is_array check
Comment #3
gordon commentedThis is actually a problem with another module which is returning an array of objects instead of an array of link arrays. If you look at http://api.drupal.org/api/function/hook_link/6 you will see that it is an array and not an object that should be returned.