Bitten by PHP 4’s pass by value semantics
For those of you who know a bit about PHP and WordPress internals and are interested, here is a brief technical overview of the details behind the bug in the original version of Comment Timeout.
I was originally tweaking the comment status of the posts at the start of the loop. The way I was doing it was admittedly a hack, but it worked — in PHP 5 at any rate, which has pass-by-reference semantics. However, it fell over in PHP 4, where variables are all passed by value rather than by reference.
It actually turns out that there is a non-hack way of achieving this. This evening I discovered that WordPress provides a filter, the_posts, which gives you a much better way of doing it. It passes an array containing all the posts returned by a query to your filter; your plugin modifies the array as appropriate — in this case, setting the comment status on some of the posts to “closed” — and returns it. The latest version (1.3 alpha 2) now adopts this approach.
Unfortunately, a lot of the WordPress API documentation is somewhat incomplete and sketchy, especially on the more technical side, which is probably why I missed this the first time round. Perhaps as plugin authors we ought to chip in and spend a bit of time polishing it up as we go? It is a wiki after all, so we’ve only ourselves to blame if it’s not up to scratch.

RSS feed
Posted at 23:05 in 

19:58
Ran into a problem with alpha 2 with a brand new WP2.1.1 install on a server running PHP 4.3.10 which throws this error:
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 preg_match_all(). 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 /usr/www/users/…/wp-content/plugins/CommentTimeout/CommentTimeout.php on line 235
setting ‘php_flag allow_call_time_pass_reference on’ in the .htaccess file bypassed the problem, but look like another PHP 4 bug for you to play with.
18:02
I have the same issue with wp 2.0.9in the admin section when I activate ct1.3a2 thiis message comes out:
Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of preg_match_all(). 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. in /home/nazioneindiana.com/wp-content/plugins/CommentTimeout.php on line 235
18:09
forgot to mention: PHP 5.2.1 on Dreamhost
22:06
This issue has been fixed, along with one or two others, in version 1.3 beta 1. Thanks for all the feedback