pukiwiki1.4.7のインストール

http://www.adminweb.jp/pukiwiki/install/
 
これを参考に行う
 

Apacheのインストール

終わっていた
 

PHPのインストール

ダウンロードとインストール
PATHの設定
  • システム変数に「C:\php;」を追記

 

c:\php>php -v
このアプリケーションのサイド バイ サイド構成が正しくないため、アプリケーションを
開始できませんでした。詳細については、アプリケーションのイベント ログを参照する
か、コマンド ライン ツール sxstrace.exe を使用してください。

 
64bitOSに32bitコンパイルのPHPを入れているのが問題らしい

c:\php>php -v
PHP 5.4.3 (cli) (built: May  8 2012 00:51:31)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

 

php.iniファイルの作成

開発環境用設定ファイルをコピって使いまわす

c:\php>copy php.ini-development php.ini
phpinfo関数による設定内容の確認

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\phpinfo.phpを作成

<?php
phpinfo();
?>


C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.confを編集

(末尾に追記)
# 
LoadModule php5_module "c:/php/php5apache2_2.dll"

<FilesMatch \.php$>
      SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch \.phps$>
      SetHandler application/x-httpd-php-source
</FilesMatch>

# php.ini へのパス
PHPIniDir "C:/php"

 
ブラウザで「http://localhost:8000/phpinfo.php」で設定ファイルが表示される
 

拡張モジュールディレクトリ(extension_dir)の設定

C:\php\php.iniを編集

; extension_dir = "ext"(コイツの下に追記する)
extension_dir = "c:\php\ext"

apacheを再起動させて「http://localhost:8000/phpinfo.php」にて確認

extension_dir c:\php (前)
extension_dir c:\php\ext (後)
インクルードパス(include_path)の設定

(必要なのかどうかわからん)
C:\php\php.iniを編集

; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://php.net/include-path(コイツの下に記述する)
include_path = ".;c:\php\includes;c:\php\pear"

apacheを再起動させて「http://localhost:8000/phpinfo.php」にて確認

include_path .;c:\php\pear (前)
include_path .;c:\php\includes;c:\php\pear (後)
日本語利用の設定

C:\php\php.iniを編集

;拡張モジュールを有効
;extension=php_mbstring.dll(コイツの下に記述する)
extension=php_mbstring.dll

;mbstring.language = Japanese(コイツの下に記述する)
mbstring.language = Japanese

;マルチバイト文字列関数(mbstring)のデフォルトエンコード
;mbstring.internal_encoding = EUC-JP(コイツの下に記述する)
mbstring.internal_encoding = UTF8

;HTTP通信の時のインプットとアウトプットの文字コード変換
;mbstring.http_input = auto(コイツの下に記述する)
mbstring.http_input = pass
;mbstring.http_output = SJIS(コイツの下に記述する)
mbstring.http_output = pass

;文字コードの自動判別を行う時にどの文字コードから順に確認していく?
;mbstring.encoding_translation = Off(コイツの下に記述する)
mbstring.encoding_translation = Off

;mbstring.detect_order = auto(コイツの下に記述する)
mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII

;変換に失敗した場合に代わりに表示する文字
;mbstring.substitute_character = none;
mbstring.substitute_character = none;

;文字コードの自動判別を厳密に行う?
;mbstring.strict_detection = Off
mbstring.strict_detection = Off

PukiWikiのインストール

ダウンロード
問題発生!

http://localhost:8000/pukiwiki/index.php にアクセスすると真っ白!!
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\index.phpを編集

(変更前)
error_reporting(E_ERROR | E_PARSE); // Avoid E_WARNING, E_NOTICE, etc
//error_reporting(E_ALL); // Debug purpose
(変更後)
//error_reporting(E_ERROR | E_PARSE); // Avoid E_WARNING, E_NOTICE, etc
error_reporting(E_ALL); // Debug purpose

http://localhost:8000/pukiwiki/index.php にアクセス

Fatal error: Cannot redeclare hex2bin() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\func.php on line 317

よくあることらしい。BugTrack2/349
 
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\func.phpを編集

(変更前)
// Decode page name
function decode($key)
{
	return hex2bin($key);
}
(変更後)
// Decode page name
function decode($key)
{
        if (function_exists('hex2bin')) {
                return hex2bin($key);
        } else {
                return internal_hex2bin($key);
        }
}
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
        return preg_match('/^[0-9a-f]+$/i', $hex_string) ?
                pack('H*', (string)$hex_string) : $hex_string;
}

だめだ。膨大なエラーが出る!元に戻してやり直し。
 
PHP5.4 と PukiWiki(/.j)を発見!
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\func.phpを編集
hex2bin()が組み込み関数になったので衝突回避の為にコメントアウト

/*
// Inversion of bin2hex()
function hex2bin($hex_string)
{
	// preg_match : Avoid warning : pack(): Type H: illegal hex digit ...
	// (string)   : Always treat as string (not int etc). See BugTrack2/31
	return preg_match('/^[0-9a-f]+$/i', $hex_string) ?
		pack('H*', (string)$hex_string) : $hex_string;
}
*/
newの返り値のキャスト変更

func.phpを修正

//	$config = &new Config('AutoLink');
	$config = new Config('AutoLink');

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\convert_html.phpを編集

//	$body = & new Body(++$contents_id);(22行目ぐらい)
	$body = new Body(++$contents_id);

//	$obj = & new Paragraph('', $class);(195行目ぐらい)
	$obj = new Paragraph('', $class);

 

困ったエラー

Strict Standards: Declaration of Heading::canContain() should be compatible with Element::canContain($obj) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\convert_html.php on line 265

BugTrack2/349 php-5.4.0で動作させる対応

アンパサンドで思い出しましたが,lib/convert_html.phpで警告が出ます.以下のようなもので
> php ./index.php
PHP Strict Standards: Declaration of Heading::canContain() should be compatible with Element::canContain($obj) in /(some where)/pukiwiki/lib/convert_html.php on line 264
「引数の型は同じにせよ」ということのようです.なので,
function canContain(& $obj)
{
return FALSE;
}
の引数を参照型にしているのは親クラスの宣言と異なるので止めたほうが良いのでは,と. -- よっちい 2011-11-23 (水) 11:56:25

 
試行錯誤の結果、以下のクラスの中の関数を修正

  • class Heading extends Element
  • class HRule extends Element
  • class ListContainer extends Element
  • class ListElement extends Element
  • class BQuote extends Element
  • class Table extends Element
  • class YTable extends Element
  • class Pre extends Element
  • class Div extends Element
  • class Align extends Element
//	function canContain(& $obj)
	function canContain($obj)

 
まだまだあるよ!

  • class Table extends Element
//$row[] = & new TableCell($cell, $is_template);
$row[] = new TableCell($cell, $is_template);
  • class Body extends Element
//$this->contents      = & new Element();
$this->contents      = new Element();
<<
 
こんどは
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\config.phpを修正

>||
//	$obj        = & new ConfigTable('');
	$obj        = new ConfigTable('');

//	$obj = & new ConfigTable($line);
	$obj = new ConfigTable($line);

//	$obj = & new ConfigTable_Direct('', $obj);
	$obj = new ConfigTable_Direct('', $obj);

//	$obj = & new ConfigTable_Direct('', $obj);
	$obj = new ConfigTable_Direct('', $obj);

//	$obj = & new ConfigTable_Sequential('', $obj);
	$obj = new ConfigTable_Sequential('', $obj);

//	$this->objs[$title] = & new ConfigTable('*' . trim($title) . "\n");
	$this->objs[$title] = new ConfigTable('*' . trim($title) . "\n");

つかれてきたぞ
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\link.phpを修正

//	$obj = & new InlineConverter(NULL, array('note'));
	$obj = new InlineConverter(NULL, array('note'));


今までとは異なるエラーが出た

Notice: Undefined variable: HTTP_SERVER_VARS in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\init.php on line 29

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\init.phpを修正

<?php
	global $HTTP_SERVER_VARS;
//2行目に追記する

 
また違うエラーが出た

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\init.php on line 42

PHP5.4 と PukiWiki(/.j)の(4)かな?
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\init.phpを修正

<?php
	global $HTTP_SERVER_VARS;
	date_default_timezone_set('Asia/Tokyo');
//3行目に追記する

またちがうよ

Notice: Only variable references should be returned by reference in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\lib\convert_html.php on line 146

/.j PHP5.4 と PukiWikiで見つけた記述

3)返り値が参照値の関数で newの返り値を返している部分の 変更  return &new HogeHoge; -> $ret=new Hogehoge; retrurn $ret; (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 = new Paragraph(' ' . substr($text, 1));
	} else {
//		return new Inline($text);
		$ret = new Inline($text);
	}
	return $ret;
}

//function & Factory_DList(& $root, $text)
//	return new DList($out);
	$ret = new DList($out);
	return $ret;

//function & Factory_Table(& $root, $text)
//	return new Table($out);
	$ret = new Table($out);
	return $ret;

//function & Factory_YTable(& $root, $text)
//	return new YTable(csv_explode(',', substr($text, 1)));
	$ret = new YTable(csv_explode(',', substr($text, 1)));
	return $ret;

//function & Factory_Div(& $root, $text)
//	return new Div($matches);
	$ret = new Div($matches);
	return $ret;

if ($len == 0) {
//	return new Div($matches); // Seems legacy block plugin
	$ret= new Div($matches); // Seems legacy block plugin
} 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 = new Div($matches); // Seems multiline-enabled block plugin
}
return $ret;


 
こんどはなんだ?

Deprecated: Assigning the return value of new by reference is deprecated in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\plugin\attach.inc.php on line 68

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\plugin\attach.inc.php

//function plugin_attach_convert()
//	$obj  = & new AttachPages($page);
	$obj  = new AttachPages($page);

//function attach_filelist()
//	$obj = & new AttachPages($page, 0);
	$obj = new AttachPages($page, 0);

//function attach_upload($file, $page, $pass = NULL)
//	$obj = & new AttachFile($page, $file['name']);
	$obj = new AttachFile($page, $file['name']);

//function attach_info($err = '')
//	$obj = & new AttachFile($refer, $file, $age);
	$obj = new AttachFile($refer, $file, $age);

//function attach_delete()
//	$obj = & new AttachFile($refer, $file, $age);
	$obj = new AttachFile($refer, $file, $age);

//function attach_freeze($freeze)
//	$obj = & new AttachFile($refer, $file, $age);
	$obj = new AttachFile($refer, $file, $age);

//function attach_rename()
//	$obj = & new AttachFile($refer, $file, $age);
	$obj = new AttachFile($refer, $file, $age);

//function attach_open()
//	$obj = & new AttachFile($refer, $file, $age);
	$obj = new AttachFile($refer, $file, $age);

//function attach_list()
//	$obj = & new AttachPages($refer);
	$obj = new AttachPages($refer);

//class AttachFiles
//	$this->files[$file][$age] = & new AttachFile($this->page, $file, $age);
	$this->files[$file][$age] = new AttachFile($this->page, $file, $age);

//class AttachPages
//	$this->pages[$_page] = & new AttachFiles($_page);
	$this->pages[$_page] = new AttachFiles($_page);

やっとエラーが消えたけど、文字化けしている!単純なエンコードだけでした。
 
あっちこっちクリックするとエラーが出る

Fatal error: Call-time pass-by-reference has been removed in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\plugin\ls2.inc.php on line 69

編集する

//	array_walk($args, 'plugin_ls2_check_arg', & $params);
	array_walk($args, 'plugin_ls2_check_arg', $params);

あとはエラーが表示されたら、その都度修正かな?

添付したらエラーがでた

Strict Standards: uasort() expects parameter 2 to be a valid callback, non-static method AttachFile::datecomp() should not be called statically in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\pukiwiki\plugin\attach.inc.php on line 800

こればっかりは解決策がわからないので、わかった人がいたら教えてほしいです。