日記/2012-10-22
2012-10-22 (月) 18:43:08
pukiwiki for PHP5.4.x†
Ubuntu12.10 Quantal Quetzalがリリースになった。
ORCA 簡単 インストールのHPはUbuntu12.04上のpukiwikiで作成しているが、
Ubuntu12.10にupgradeしてみたところ動かなくなった。
php5.3からphp5.4へupgradeされたことが原因らしい。
何とかなったので備忘録
こちらより
http://pukiwiki.sourceforge.jp/dev/?CVS%C8%C7
PukiWiki 1.4.xのスナップショットをダウンロードして解凍する。
pukiwiki/libとpukiwiki/pluginの中身を取り出して上書きする。
こちら
http://imapsoopy.ddo.jp/tarusoopy/wordpress/2012/05/03/pukiwiki-for-php5-4-x/
を参考にして
pukiwikiディレクトリに
henkan.shを作成
#!/bin/bash filelist=`grep -rl htmlspecialchars *` for i in $filelist do # echo $i cp $i $i.org touch $i.new awk '!/htmlspecialchars/{print $0}/htmlspecialchars/{gsub(/htmlspecialchars/,"hx");print $0}' $i >> $i.new mv $i.new $i done
$ cd pukiwiki $ sh henkan.sh
pukiwiki/lib/convert_html.php
pukiwiki/lib/func.php
pukiwiki/lib/init.php
pukiwiki/lib/link.php
を下記の通り変更する。
diff -urPN pukiwiki.org/lib/convert_html.php pukiwiki/lib/convert_html.php --- pukiwiki.org/lib/convert_html.php 2005-07-20 00:38:35.000000000 +0900 +++ pukiwiki/lib/convert_html.php 2012-05-03 14:57:31.000000000 +0900 @@ -19,7 +19,7 @@ if (! is_array($lines)) $lines = explode("\n", $lines); - $body = & new Body(++$contents_id); + $body = new Body(++$contents_id); $body->parse($lines); return $body->toString(); @@ -190,7 +190,7 @@ function & toPara($class = '') { - $obj = & new Paragraph('', $class); + $obj = new Paragraph('', $class); $obj->insert($this); return $obj; } @@ -574,7 +574,7 @@ $is_template = ($this->type == 'c'); $row = array(); foreach ($cells as $cell) - $row[] = & new TableCell($cell, $is_template); + $row[] = new TableCell($cell, $is_template); $this->elements[] = $row; } @@ -814,7 +814,7 @@ function Body($id) { $this->id = $id; - $this->contents = & new Element(); + $this->contents = new Element(); $this->contents_last = & $this->contents; parent::Element(); } diff -urPN pukiwiki.org/lib/func.php pukiwiki/lib/func.php --- pukiwiki.org/lib/func.php 2005-07-04 00:09:27.000000000 +0900 +++ pukiwiki/lib/func.php 2012-05-03 15:04:10.000000000 +0900 @@ -260,11 +260,11 @@ // Decode page name function decode($key) { - return hex2bin($key); + return internal_hex2bin($key); } // Inversion of bin2hex() -function hex2bin($hex_string) +function internal_hex2bin($hex_string) { // preg_match : Avoid warning : pack(): Type H: illegal hex digit ... // (string) : Always treat as string (not int etc). See BugTrack2/31 @@ -484,7 +484,7 @@ { global $WikiName, $autolink, $nowikiname; - $config = &new Config('AutoLink'); + $config = new Config('AutoLink'); $config->read(); $ignorepages = $config->get('IgnoreList'); $forceignorepages = $config->get('ForceIgnoreList'); @@ -657,6 +657,11 @@ return join($glue, $arr); } +// for htmlspecialchars of PHP5.4.x +function hx($str, $flags = ENT_COMPAT, $charset = 'EUC-JP') { + return htmlspecialchars($str, $flags, $charset); +} + //// Compat //// // is_a -- Returns TRUE if the object is of this class or has this class as one of its parents diff -urPN pukiwiki.org/lib/init.php pukiwiki/lib/init.php --- pukiwiki.org/lib/init.php 2005-09-11 14:58:33.000000000 +0900 +++ pukiwiki/lib/init.php 2012-05-03 14:59:09.000000000 +0900 @@ -41,6 +41,7 @@ define('LOCALZONE', date('Z')); define('UTIME', time() - LOCALZONE); define('MUTIME', getmicrotime()); +date_default_timezone_set('Asia/Tokyo'); ///////////////////////////////////////////////// // Require INI_FILE diff -urPN pukiwiki.org/lib/link.php pukiwiki/lib/link.php --- pukiwiki.org/lib/link.php 2005-04-29 20:24:20.000000000 +0900 +++ pukiwiki/lib/link.php 2012-05-03 14:58:02.000000000 +0900 @@ -248,7 +248,7 @@ static $obj; if (! isset($obj) || $refresh) - $obj = & new InlineConverter(NULL, array('note')); + $obj = new InlineConverter(NULL, array('note')); return $obj->get_objects(join('', preg_grep('/^(?!\/\/|\s)./', get_source($page))), $page); }