Opened 8 years ago

Closed 8 years ago

#1583 closed defect (bug) (fixed)

WP 1.6 and PHP 5 (call-time pass-by-reference is depreciated)

Reported by: ch0de Owned by: markjaquith
Priority: high Milestone:
Component: General Version: 1.6
Severity: blocker Keywords: bg|dev-feedback bg|2nd-opinion
Cc:

Description

After installing WP 1.6 on a PHP 5 server, The errors are:

"Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of do_action(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in D:\WEBSITES_APACHE\xxxxx\wp16\wp-includes\comment-functions.php on line 450"

It has to do with & and the functions. I heard from a friend that this is being talked about in IRC, but this is just a reminder.

Change History (12)

  • Priority changed from high to normal
  • Version changed from 1.2 to 1.6

This is not an issue with wordpress but rather with server configuration. I had the same bug earlier.

See: #1547

You need to modify your php.ini and do what the error says.

allow_call_time_pass_reference = True

This must be put in php.ini.

So I guess the only way is to tell my host to change it/add it or whatever? How about the code that was in the link you mentioned above?

<?php
function varargs_by_ref($arg_list = null) {

if (is_array($arg_list)) {

foreach ($arg_list as &$arg) {

# do whatever you want with $arg...

}

}

}

$by_ref = 'to_be_midified_inside_func';
$by_val = 'to_be_passed_by_value';

varargs_by_ref(array('baba', &$by_ref, $by_value));

?>

Exept it would need to be modified but i wish i knew how too do it.

Yeah I couldn't figure out how to use the code above so I went ahead and just modified my php.ini

  • Keywords bg|dev-feedback bg|2nd-opinion added
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

This part worries me:


If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer.


That rather suggests that it won't be a "server problem" for long, and that we're going to have to change our practices.

  • Keywords bg|dev-feedback bg|2nd-opinion removed

Contrary to what EvilBeAr said, this is a WordPress issue and not a PHP server configuration issue. The setting is off by default and WordPress should adhere to that, especially considering that the feature will be completely removed later on. A temporary fix may be to ini_set it for what we need in the case this can't be fixed for 1.6.

  • Keywords bg|dev-feedback bg|2nd-opinion added
  • Summary changed from Wordpress 1.6 not supporting PHP 5 to WP 1.6 and PHP 5 (call-time pass-by-reference is depreciated)

It should be noted that this is not just a PHP5 issue, the warning comes up in PHP4 using the recommended php.ini. I'm still looking through the code, but an initial glance looks like it would be better to fix the comment-functions.php file (line 450) than changing the way do_action() works.

Brief research at php.net uncovered this tidbit: you CAN pass by an array of references. The do_action declaration already handles this beautifully so I have simply changed line 450 to pass an array:
do_action('pre_ping', array(&$post_links, &$pung));
The warning is gone. The pings need testing.

  • Priority changed from normal to high
  • Resolution set to fixed
  • Status changed from assigned to closed

(In [2798]) Call time pass by reference not allowed. Use the array trick. fixes #1583

Note: See TracTickets for help on using tickets.