No diagnostics, simply does not display anything.

Big inconvenience for me, as I make massive use of Link Node, and have moved a client site from a development machine with PHP5.2.x to a production server with PHP 5.3.0.

Grateful for feedback/fix.

Comments

webel’s picture

Possibly related:

warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in ... /includes/theme.inc on line 617.
function theme_link_node_thumbnail(&$node) {

  $main = TRUE;
  
  if ($node->type == "image") {
    
    // offer theme developers and module developers to override this
    if (function_exists("image_link_node_thumbnail")) {
      return image_link_node_thumbnail($node);
    }
  }
  
  $output = l($node->title, drupal_get_path_alias('node/'. $node->nid));
 
  return $output;
}

webel’s picture

function link_node_filter_process($text, $show_error_msgs=1) {

...


        if ($node) {
...
          if (preg_match_all($meta_tag_params_regexp, $match[2][$key], $parm_match)) {
            $allowed_vars = explode(',', variable_get("link_node_allowed_vars_$node->type", ""));
            for ($i=0; $i<count($parm_match[1]); $i++) {  
              //$parm_match[1] contains the param names, $parm_match[2] contains values
              $parm = $parm_match[1][$i];
              $val = $parm_match[2][$i];
              
              // check the name ($parm) to make sure it's an allowable value (like "align" or "border" or something)
              if (in_array($parm, $allowed_vars)) {
                $node->$parm = $val;
              }
              else {
                if ($show_error_msgs) {
...
                }
              }
            }      
          }

          $matches_html[$key] = theme("link_node_thumbnail", $node);
        }
...

}
TomChiverton’s picture

Assigned: Unassigned » TomChiverton

Works for me with "php-5.3.2-1.fc12.x86_64" (my live server).
Could you have an invalid node ID or something ?

webel’s picture

> Works for me with "php-5.3.2-1.fc12.x86_64" (my live server).
Then maybe something else has changed when moving to my production server, if it is not a PHP5.3.0 specific problem [Edit: it almost certainly is, see below]

> Could you have an invalid node ID or something ?
No. I have the exact same site (same database) running on 2 other machines, both with PHP5.2.x, one remote, one local on Mac OS X, and both have Link Node references displayed correctly, for hundreds of nodes.

webel’s picture

vs Drupal-6.15

includes/theme.inc: 617

    $output = call_user_func_array($info['function'], $args);

I switched on Devel module and using dpm($var,name=null) I stepped through link_node_filter_process($text, $show_error_msgs=1). The nid is extracted correctly from [node:nid], however (with warning message given above) theme_link_node_thumbnail(&$node) is never entered at:

          $matches_html[$key] = theme("link_node_thumbnail", $node)

so $matches_html[$key] ends up empty.

Then [node:nid] gets replaced with empty at:

      foreach ($match[1] as $key => $value) {
        $mtch[] = $match[0][$key];
        $repl[] = $matches_html[$key];
      }
      $text = str_replace($mtch, $repl, $text);

It is broken vs PHP5.3.0 [Edit: almost certainly specifically, and also PHP5.3.1, see below]

webel’s picture

@TomChiverton

It may be due to a bug in PHP5.3.1 (and presumably also PHP5.3.0), whereas you are using "php-5.3.2". Relevant links:

From http://stackoverflow.com/questions/2045875/pass-by-reference-problem-with-php-5-3-1:

ctually, be aware that there is a bug with PHP 5.3.1 concerning references and all call family of functions:

PHP Bugs #50394: Reference argument converted to value in __call

The behavior you are seeing might be a result of this bug and any attempt to fix it code wise may cause problems in the long run.

The problem has been fixed in the SVN version of PHP. Until 5.3.2 is released, you may compile a new version for use, or downgrade to an earlier version.

Sorry to take your time with this, I don't have the option of upgrading PHP on my production server right now. Could you please investigate the above and consider whether you can implement the interim solution.

This will likely affect a lot of people using Mac OS X Leopard server.

webel’s picture

Now I'm really confused (and frustrated). According to http://bugs.php.net/bug.php?id=50394:

Bug #50394 Reference argument converted to value in __call

Description:
------------
This is a regression in the PHP 5.3.1 release. When you call a __call() function with a reference parameter, it is silently converted to a value, by the time it reaches the second argument to __call().

This breaks MediaWiki and has no obvious workaround.

Reproduce code:
---------------
function foo( &$x ) {}

class Proxy {
	function __call( $name, $args ) {
		debug_zval_dump( $args );
		call_user_func_array( 'foo', $args );
	}
}

$arg = 1;
$args = array( &$arg );
$proxy = new Proxy;
call_user_func_array( array( &$proxy, 'bar' ), $args );


Expected result:
----------------
PHP 5.3.0 produces:

array(1) refcount(4){
  [0]=>
  &long(1) refcount(5)
}


Actual result:
--------------
array(1) refcount(4){
  [0]=>
  long(1) refcount(3)
}

Warning: Parameter 1 to foo() expected to be a reference, value given in /home/tstarling/src/php/stuff/test-reference-call.php on line 8

But I am getting the error with PHP5.3.0, not PHP5.3.1 !

webel’s picture

I tried above test on my production server with PHP5.3.0 and got for the mini test:

array(1) refcount(4){ [0]=> &long(1) refcount(5) }

So I now don't understand how in includes/theme.inc: 617:

    $output = call_user_func_array($info['function'], $args);

This could be failing to correctly pass $args to:

$matches_html[$key] = theme("link_node_thumbnail", $node);
webel’s picture

From Drupal-6-15 theme.inc (adapted to debug):

function theme() {
  $args = func_get_args();
  $hook = array_shift($args);

  static $hooks = NULL;
  if (!isset($hooks)) {
    init_theme();
    $hooks = theme_get_registry();
  }

  if (is_array($hook)) {
    foreach ($hook as $candidate) {
      if (isset($hooks[$candidate])) {
        break;
      }
    }
    $hook = $candidate;
  }

  if (!isset($hooks[$hook])) {
    return;
  }

  $info = $hooks[$hook];
  global $theme_path;
  $temp = $theme_path;
  // point path_to_theme() to the currently used theme path:
  $theme_path = $hooks[$hook]['theme path'];

  // Include a file if the theme function or preprocess function is held elsewhere.
  if (!empty($info['file'])) {
    $include_file = $info['file'];
    if (isset($info['path'])) {
      $include_file = $info['path'] .'/'. $include_file;
    }
    include_once($include_file);
  }
  if (isset($info['function'])) {
    // The theme call is a function.
	if ($info['function'] == 'theme_link_node_thumbnail') dpm($args,'theme_link_node_thumbnail.$args'); ///DEBUG
    $output = call_user_func_array($info['function'], $args);
TomChiverton’s picture

Status: Active » Closed (fixed)

My suggestion would be to upgrade PHP on your servers, this looks like a big bug in earlier 5.3 releases.
No one else appears to have run into it, which makes you lucky I guess.

webel’s picture

@TomChiverton

I wrote:
> I don't have the option of upgrading PHP on my production server right now.

Well for now on the one production server I'm simply hacking out the themed call, so that:

$matches_html[$key] = theme("link_node_thumbnail", $node);

Becomes:

$matches_html[$key] = theme_link_node_thumbnail($node);

And then $output = call_user_func_array($info['function'], $args); is avoided (at least by Link Node) - although I fully expect to hit this problem again in similar form later this saturday afternoon, as I work through a dozen more contributed modules breaking against PHP5.3.0.

Thanks for your input.

umina’s picture

Version: 6.x-1.2-beta1 » 6.x-1.x-dev

I'm running PHP version 5.3.2-2 and I get the following errors, about 20 of them:

# warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /var/www/html/drupal/includes/theme.inc on line 656.
# warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /var/www/html/drupal/includes/theme.inc on line 656.
# warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /var/www/html/drupal/includes/theme.inc on line 656.
# warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /var/www/html/drupal/includes/theme.inc on line 656.
# warning: Parameter 1 to theme_link_node_thumbnail() expected to be a reference, value given in /var/www/html/drupal/includes/theme.inc on line 656.

The site works on another older system with no trouble.

/Len

TomChiverton’s picture

WFM, sorry.
Please carry on digging- if you get to the bottom of it I'll certainly look at it.

If they are only warnings, and Link Node otherwise works fine, I suggest you just turn down the logging.

$ rpm -q php
php-5.3.2-2.fc12.x86_64

TomChiverton’s picture

OK, it looks like from #808250 this might be real.
Sorry guys, not sure what is up, but there is a work around at http://drupal.org/node/772894#comment-3015910
Please watch that bug.

TomChiverton’s picture

1.3 BETA1 released, contains patch for this issue http://drupal.org/node/182812/release