Has anyone else used acidfree on php 5.3.0? I updated to Fedora 12 which has php 5.3.0 and none of my acidfree albums display the pictures. When I'm viewing an album, the pager displays and any text, but not the images.

Comments

bkat’s picture

I should mention that this occurs for 6.x and 5.x.

rhylos’s picture

If I recall this module is currently incompatible due to a feature that has been depricated in 5.3.x

bkat’s picture

Do you have any idea what that feature is? I'm happy to dig into the code and come up with fix but it would be helpful to get a headstart.

bkat’s picture

I've pretty much figured out what its going on. In D5, we have the following in class_album.inc

function theme_views_view_album_grid_view($view, $type, $nodes, $teasers = false, $links = true) {
    $term = taxonomy_get_term($view->args[0]);
    drupal_set_breadcrumb(acidfree_make_breadcrumbs($term));
    $offset = _acidfree_get_pager_offset_from_path(ALBUM_PAGER);
    if ($offset) {
        $offset = " - ".t('Page !page', array('!page' => "".($offset+1)));
    }
    drupal_set_title($term->name.$offset);
    if (count($nodes) == 0) {
        return "<p>".t('This album is empty')."</p>";
    }
    $output = "\n<p class=\"acidfree-center\">".check_markup($term->description)."</p>\n";
    $output .= theme('pager', NULL, 1, ALBUM_PAGER);
    $output .= '<div class="clear-block acidfree">' . "\n";
    foreach ($nodes as $node) {
        $node = node_load(array('nid' => $node->nid));
	$function = "acidfree_print_thumb_{$node->type}";
        $output .= theme($function, $node, $term)."\n";
    }
    $output .= "</div>\n";
    return $output;
}

For whatever reason the theme call is not invoking theme_acidfree_print_thumb_acidfree or theme_acidfree_print_thumb_image for example. if I change it so that we invoke it as

$function = "theme_acidfree_print_thumb_{$node->type}";
$output .= $function($node, $term)."\n";

Then the method gets invoked and everything displays like I'd expect. I poked around inside of theme() and it looks like it uses call_user_func_array() to invoke the appropriate function. So I replaced the above code with

$function = "theme_acidfree_print_thumb_{$node->type}";
$output .= call_user_func_array($function, array($node, $term))."\n";

and the function is not invoked. What gives? Why is call_user_func_array behaving differently when running under php 5.3.0?

berdir’s picture

Theme function *must not* recieve params by reference. That did never work (it was simply forced to be by value) and since 5.3, it shows a warning and sets the problematic parameter to NULL.

To fix it, simply remove all "&" from theme function definitions.

mwheinz’s picture

Assigned: Unassigned » mwheinz
mwheinz’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta2
Status: Active » Fixed

Fixed in Beta2

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

texas-bronius’s picture

Fyi, @Berdir means that, for instance, in ./acidfree/class_image.inc

function theme_acidfree_print_thumb_image(&$node, $parent=null) {
  ...

in the D5 dev version should become

function theme_acidfree_print_thumb_image($node, $parent=null) {
  ...

Just cmd-F for "function theme" and see if there are any preceding &'s. Same for class_album.inc.

Symptoms on my end: I had upgraded a vps from PHP 5.2 to 5.3, quick-scanned all sites, but failed to notice (or maybe cache-clear hadn't occurred..??) that this old D5 website's Projects gallery was totally blank! Content was still there. Googling error led me to this issue queue. Resolution is as @Berdir wrote.

Cheers
-Bronius