PHP Version 5.1.1 の環境で、error_reporting(E_ALL) にして PukiWiki-1.4.6 を動作させると Notice が大量に出ます。
Notice: Only variable references should be returned by reference in ***/lib/convert_html.php on line 144
直接の原因は参照返しの関数でnewしたオブジェクトをそのままreturnしている ことにあります。とりあえずバッファ変数に入れてあげることで対応するしかな いです。
Fatal error: Call to a member function on a non-object in /var/www/trunk/lib/convert_html.php on line 51です。PHP5.1.1では問題なく動きました*1 -- okkez 2005-12-29 (木) 15:50:44
function & Factory_DList(& $root, $text) { $out = explode('|', ltrim($text), 2); if (count($out) < 2) { - return Factory_Inline($text); + $_ret_object = Factory_Inline($text); } else { - return new DList($out); + $_ret_object = new DList($out); } + return $_ret_object; }
Notice: Only variable references should be returned by reference in lib/convert_html.php on line 102 Notice: Only variable references should be returned by reference in lib/convert_html.php on line 154上記と同じ問題のようです。
lib/convert_html.php(100): return new Paragraph(' ' . substr($text, 1)); lib/convert_html.php(102): return new Inline($text); lib/convert_html.php(112): return new DList($out); lib/convert_html.php(122): return new Table($out); lib/convert_html.php(132): return new YTable(csv_explode(',', substr($text, 1))); lib/convert_html.php(145): return new Div($matches); lib/convert_html.php(154): return new Div($matches); // Seems legacy block plugin lib/convert_html.php(157): return new Div($matches); // Seems multiline-enabled block plugin lib/convert_html.php(162): return new Paragraph($text);lib/convert_html.php以外は大丈夫そうです。
// Returns inline-related object function & Factory_Inline($text) { // Check the first letter of the line if (substr($text, 0, 1) == '~') { - return new Paragraph(' ' . substr($text, 1)); + $_ret_object = & new Paragraph(' ' . substr($text, 1)); } else { - return new Inline($text); + $_ret_object = & new Inline($text); } + return $_ret_object; } function & Factory_DList(& $root, $text) { $out = explode('|', ltrim($text), 2); if (count($out) < 2) { - return Factory_Inline($text); + $_ret_object = & Factory_Inline($text); } else { - return new DList($out); + $_ret_object = & new DList($out); } + return $_ret_object; } // '|'-separated table function & Factory_Table(& $root, $text) { if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $out)) { - return Factory_Inline($text); + $_ret_object = & Factory_Inline($text); } else { - return new Table($out); + $_ret_object = & new Table($out); } + return $_ret_object; } // Comma-separated table function & Factory_YTable(& $root, $text) { if ($text == ',') { - return Factory_Inline($text); + $_ret_object = & Factory_Inline($text); } else { - return new YTable(csv_explode(',', substr($text, 1))); + $_ret_object = & new YTable(csv_explode(',', substr($text, 1))); } + return $_ret_object; } function & Factory_Div(& $root, $text) { $matches = array(); // Seems block plugin? if (PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) { // Usual code if (preg_match('/^\#([^\(]+)(?:\((.*)\))?/', $text, $matches) && exist_plugin_convert($matches[1])) { - return new Div($matches); + $_ret_object = & new Div($matches); + return $_ret_object; } } else { // Hack code if(preg_match('/^#([^\(\{]+)(?:\(([^\r]*)\))?(\{*)/', $text, $matches) && exist_plugin_convert($matches[1])) { $len = strlen($matches[3]); $body = array(); if ($len == 0) { - return new Div($matches); // Seems legacy block plugin + $_ret_object = & new Div($matches); // Seems legacy block plugin + return $_ret_object; } else if (preg_match('/\{{' . $len . '}\s*\r(.*)\r\}{' . $len . '}/', $text, $body)) { $matches[2] .= "\r" . $body[1] . "\r"; - return new Div($matches); // Seems multiline-enabled block plugin + $_ret_object = & new Div($matches); // Seems multiline-enabled block plugin + return $_ret_object; } } } - return new Paragraph($text); + $_ret_object = & new Paragraph($text); + return $_ret_object; }teanan さんの対応案との違いは、参照渡しでバッファ変数に代入したかどうか、だけなんですけど。
// Returns inline-related object function & Factory_Inline($text) { // Check the first letter of the line if (substr($text, 0, 1) == '~') { - return new Paragraph(' ' . substr($text, 1)); + $_ret_object = & new Paragraph(' ' . substr($text, 1)); } else { - return new Inline($text); + $_ret_object = & new Inline($text); } + return $_ret_object; }