<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HattaraTecLog &#187; php</title>
	<atom:link href="http://teclog.hattara.info/?feed=rss2&#038;tag=php" rel="self" type="application/rss+xml" />
	<link>http://teclog.hattara.info</link>
	<description>LinuxネタとかPHPネタとかの技術ログ</description>
	<lastBuildDate>Tue, 18 Nov 2014 12:15:20 +0000</lastBuildDate>
	<language>ja</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>[Memo]wordpressで「現在メンテナンス中のため、しばらくの間ご利用いただけません。」</title>
		<link>http://teclog.hattara.info/?p=362</link>
		<comments>http://teclog.hattara.info/?p=362#comments</comments>
		<pubDate>Tue, 29 Jan 2013 00:01:11 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=362</guid>
		<description><![CDATA[久しぶりのブログ更新が、比較的どうでもいいネタで、 かつwordpressなんで、少し微妙ではありますが、メモ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>久しぶりのブログ更新が、比較的どうでもいいネタで、<br />
かつwordpressなんで、少し微妙ではありますが、メモ程度に。</p>
<p>wordpressの更新(いわゆるバージョンアップ)をしてみたら、<br />
ブログページも、管理ページも以下のエラーが表示されて、何もできなくなったというお話です。</p>
<blockquote><p>現在メンテナンス中のため、しばらくの間ご利用いただけません。</p></blockquote>
<p>結論からいうと、処理中でなく、処理完了後もこのエラーがでているようなら、<br />
SSHやFTPや、レンタルサーバならファイルマネージャみたいので、<br />
サーバ上のwordpressを置いてあるディレクトリ(フォルダ)直下に<br />
「.maintenance」ファイルができてると思うので、これを削除するか、<br />
不安だったら、「.maintenance_org」など適当な名前にリネーム(変更)したら表示されます。</p>
<hr />
<p>具体的な内容としては、まあ、既に巷に溢れてるんだろうと思いますが、<br />
共有のレンタルサーバとかでwordpressを利用している場合に、FTPのポートが開いているので、<br />
wordpressのバージョンアップを自ずとFTPで行う場面が多くなりそうですが、<br />
バージョンアップ処理を開始して、実際に新しいバージョンのファイルをコピーする前に、<br />
「wp-admin/includes/update-core.php」ファイルの「update_core関数」によって、<br />
以下のようにメンテナンスにロックファイルが作成されます。(関係ないけど直前に古いロックファイルは消してるみたい)</p>
<blockquote><p>
$maintenance_string = &#8216;<!--?php $upgrading = ' . time() . '; ?-->&#8216;;<br />
$maintenance_file = $to . &#8216;.maintenance&#8217;;<br />
$wp_filesystem-&gt;delete($maintenance_file);<br />
$wp_filesystem-&gt;put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
</p></blockquote>
<p>で、ブログページ側の挙動を追っていくと、　（wordpressを置いているフォルダを起点に書きます）<br />
1. 「index.php」で「wp-blog-header.php」をrequire。</p>
<blockquote><p>require(&#8216;./wp-blog-header.php&#8217;);</p></blockquote>
<p>2. 「wp-blog-header.php」で「wp-load.php」をrequire。</p>
<blockquote><p>require_once( dirname(__FILE__) . &#8216;/wp-load.php&#8217; );</p></blockquote>
<p>3. 「wp-load.php」で、「wp-config.php」が存在すればrequire。</p>
<blockquote><p>
if ( file_exists( ABSPATH . &#8216;wp-config.php&#8217;) ) {<br />
/** The config file resides in ABSPATH */<br />
require_once( ABSPATH . &#8216;wp-config.php&#8217; );<br />
：
</p></blockquote>
<p>4. 「wp-config.php」で、「wp-settings.php」をrequire。</p>
<blockquote><p>require_once(ABSPATH . &#8216;wp-settings.php&#8217;);</p></blockquote>
<p>5. 「wp-settings.php」で、「wp_maintenance関数」を呼び出し。</p>
<blockquote><p>
// Check if we&#8217;re in maintenance mode.<br />
wp_maintenance();
</p></blockquote>
<p>6. 「wp-includes/load.php」の「wp_maintenance関数」が呼び出され、<br />
「.maintenance」ファイルがあり、かつファイル内に記載されているepoch値(エポック値)から<br />
600秒(10分)以内の場合には、「wp-content/maintenance.php」があれば、それを表示。<br />
それがなければ、「 _e( &#8216;Briefly unavailable for scheduled maintenance. Check back in a minute.&#8217; )」が<br />
表示される。</p>
<blockquote><p>
function wp_maintenance() {<br />
if ( !file_exists( ABSPATH . &#8216;.maintenance&#8217; ) || defined( &#8216;WP_INSTALLING&#8217; ) )<br />
return;</p>
<p>global $upgrading;</p>
<p>include( ABSPATH . &#8216;.maintenance&#8217; );<br />
// If the $upgrading timestamp is older than 10 minutes, don&#8217;t die.<br />
if ( ( time() &#8211; $upgrading ) &gt;= 600 )<br />
return;</p>
<p>if ( file_exists( WP_CONTENT_DIR . &#8216;/maintenance.php&#8217; ) ) {<br />
require_once( WP_CONTENT_DIR . &#8216;/maintenance.php&#8217; );<br />
die();<br />
}<br />
:</p>
<h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1>
</blockquote>
<p>7. 日本語設定になっている場合には、「 _e( &#8216;Briefly unavailable for scheduled maintenance. Check back in a minute.&#8217; )」が<br />
「wp-content/languages/ja.po」に基づいて「現在メンテナンス中のため、しばらくの間ご利用いただけません。」が表示される。</p>
<blockquote><p>
#: wp-includes/load.php:178<br />
msgid &#8220;Briefly unavailable for scheduled maintenance. Check back in a minute.&#8221;<br />
msgstr &#8220;現在メンテナンス中のため、しばらくの間ご利用いただけません。&#8221;
</p></blockquote>
<p>そして、管理者ページ側もほとんど同じですが、<br />
「wp-admin/index.php」で</p>
<blockquote><p>require_once(&#8216;./admin.php&#8217;);</p></blockquote>
<p>「wp-admin/admin.php」</p>
<blockquote><p>require_once(dirname(dirname(__FILE__)) . &#8216;/wp-load.php&#8217;);</p></blockquote>
<p>されているので、結果、ブログページの3番以降と同じフローにのります。</p>
<p>あとは、メンテナンスページとして自分の作成した内容を表示したい場合には、<br />
「wp-content/maintenance.php」という名前のファイルを作って、表示させればいいです。</p>
<p>サンプルテキストを置くとしたら、</p>
<blockquote><p>echo &#8220;メンテナンス中です。ご迷惑をお掛けしてすいません&#8221; &gt; ./wp-content/maintenance.php</p></blockquote>
<p>簡単にメンテナンスのテストするなら、コマンドラインから以下をたたいて今のepoch値でロックファイルを作ります。<br />
（※当たり前ですが、wordpressはメンテ中になりますので、ご注意ください）</p>
<blockquote><p>php -r &#8220;echo sprintf(&#8216;<!--?php \$upgrading = %d; ?-->&#8216;, time());&#8221; &gt; .maintenance</p></blockquote>
<p>ということで、エラーがでたので、久しぶりにphpのコードを読んで、中身を追って、<br />
どこにでもありそうな処理フローの解説をするという誰得っぽい記事を書いてみました。久しぶりの更新なのに。。</p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=362</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DB Error: mismatchがでたぞ!!</title>
		<link>http://teclog.hattara.info/?p=73</link>
		<comments>http://teclog.hattara.info/?p=73#comments</comments>
		<pubDate>Thu, 02 Apr 2009 09:17:38 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[エラー]]></category>
		<category><![CDATA[プレースホルダ]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=73</guid>
		<description><![CDATA[php経由でMysqlに接続して処理してたときに なんでか理由がわからないけどエラーがでた。 DB Error [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>php経由でMysqlに接続して処理してたときに<br />
なんでか理由がわからないけどエラーがでた。</p>
<blockquote><p>DB Error: mismatch</p></blockquote>
<p>試した感じからすると、where句の内容に問題があるようだ。</p>
<p>【エラーが出る例】</p>
<blockquote><p>select * from table where column != ? ;</p></blockquote>
<p>　  ※「?」はプレースホルダしてるから。<br />
　　　ちなみにSSH経由でmysqlコマンドで接続して実行するとエラーにならない。</p>
<p>【エラーが出ない例】</p>
<blockquote><p>　select * from table where column <> ? ;</p></blockquote>
<p>　  ※これだとエラーにならないわけです。</p>
<p>なんでですかね？<br />
　phpとの相性？<br />
　プレースホルダ絡み？<br />
　phpの書き方に問題があった？</p>
<p>ちょっとわからないけど、備忘録として残しておきます。<br />
知ってる人いたら、コメントください。</p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=73</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>phpで&#8221;Cannot use a scalar value as an array&#8221;</title>
		<link>http://teclog.hattara.info/?p=69</link>
		<comments>http://teclog.hattara.info/?p=69#comments</comments>
		<pubDate>Thu, 26 Mar 2009 13:07:39 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=69</guid>
		<description><![CDATA[phpで &#8220;Cannot use a scalar value as an array&#8221 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>phpで</p>
<blockquote><p>&#8220;Cannot use a scalar value as an array&#8221;</p></blockquote>
<p>が表示されて処理ができなかったときのお話です。</p>
<p>グーグル先生に質問をしてみたところ、<br />
配列を初期化している部分に問題があるのがわかりました。<br />
たとえば、</p>
<blockquote><p>// 初期化<br />
$test['abc'] = &#8221;;</p>
<p>// 配列に値を入れる<br />
$test['abc']['aaa'] = aaaa;
</p></blockquote>
<p>こんなことしたときにエラーになりました。</p>
<p>要するに、$test['abc']はスカラー変数なのに、$test['abc']['aaa']のように<br />
配列に値をいれようとしてるよ！<br />
という警告のようです。</p>
<p>ということで、初期化している部分をコメントアウトして対処しました。</p>
<p>多分初歩的な内容なんだろうな。。</p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=69</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Commitは命じゃ!!</title>
		<link>http://teclog.hattara.info/?p=63</link>
		<comments>http://teclog.hattara.info/?p=63#comments</comments>
		<pubDate>Wed, 03 Dec 2008 09:47:01 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=63</guid>
		<description><![CDATA[PhpでMysql(innodb)を利用している場合に、 すごくはずかしい失態をおかしたので、 繰り返さないよ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>PhpでMysql(innodb)を利用している場合に、<br />
すごくはずかしい失態をおかしたので、<br />
繰り返さないように、恥を公開しておこう。</p>
<blockquote><p>autoCommit(false);</p></blockquote>
<p>としてたわけですよ。<br />
で、id を auto_increment するようなテーブルが複数あり、<br />
それらを、insertとかしてたわけですよ。</p>
<p>でも、なぜかDBが更新されないわけですよ。</p>
<blockquote><p>mysql_insert_id();</p></blockquote>
<p>の関数を利用して直前のSQLのauto_incrementのIDを引っ張るわけですが、<br />
これが、ちゃんとに取得できるわけですよ。<br />
id が 100とかなってても、100のIDのレコードがテーブルに存在しないわけです。</p>
<p>もう全然わからないと思っていたところ、</p>
<blockquote><p>commit()</p></blockquote>
<p>部分を気持ちよく、綺麗さっぱりコメントアウトしてたわけです。<br />
そりゃー　動くわけないですがな。</p>
<p>中途半端にまともなIDなんて返してくれちゃうから、<br />
余計あせっちまいましたよ。</p>
<p>と、いったところで、自分のinnodbの扱いの認識不足と、<br />
注意力不足が招いた結果ですけどね。。</p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=63</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pearでSmarty &amp; ZendFrameworkインストールする。</title>
		<link>http://teclog.hattara.info/?p=45</link>
		<comments>http://teclog.hattara.info/?p=45#comments</comments>
		<pubDate>Wed, 22 Oct 2008 11:36:36 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Smarty]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=45</guid>
		<description><![CDATA[もともとSmartyは使ってたんですが、 Zend Frameworkも勉強を始めました。 ということで、面倒 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>もともとSmartyは使ってたんですが、<br />
Zend Frameworkも勉強を始めました。</p>
<p>ということで、面倒なくインストールする方法を書いておきます。<br />
やっぱりphpまわりは、pearでインストールできると楽ですよね。</p>
<p>ということで、SmartyとZend Frameworkのpearでの設置方法です。</p>
<p>## Smarty</p>
<blockquote><p>
    pear list<br />
    pear list-channels<br />
    pear channel-discover pearified.com<br />
    pear install pearified/Smarty<br />
    pear list-channels<br />
    pear list
</p></blockquote>
<p>## Zend Framework</p>
<blockquote><p>
    pear list-channels<br />
    pear channel-discover zend.googlecode.com/svn<br />
    pear install zend/zend<br />
    pear list-channels
</p></blockquote>
<p>ただ、これをやっても、pear list で一覧に出てきません。。<br />
どうしたらいいんでしょうね。。</p>
<p>この辺は、また何かわかったら、追記することにします。</p>
<p><a href="http://px.a8.net/svt/ejp?a8mat=U70LG+CVSQKI+5WS+BWVTD&#038;a8ejpredirect=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2FZend-Framework%25E5%25BE%25B9%25E5%25BA%2595%25E5%2585%25A5%25E9%2596%2580-%25E5%25B1%25B1%25E7%2594%25B0%25E7%25A5%25A5%25E5%25AF%259B-9784798117126%2Fitem%2F5852116%2F" target="_blank"></p>
<p style="text-align:center">ZendFrameworkのおすすめ書籍</p>
<p><img border="0" alt="" src="http://thumbnail.image.rakuten.co.jp/@0_mall/book/cabinet/7981/79811712.jpg?_ex=200x200&#038;s=2&#038;r=1"></a><br />
<img border="0" width="1" height="1" src="http://www10.a8.net/0.gif?a8mat=U70LG+CVSQKI+5WS+BWVTD" alt=""></p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=45</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>CGI版PHPについて</title>
		<link>http://teclog.hattara.info/?p=39</link>
		<comments>http://teclog.hattara.info/?p=39#comments</comments>
		<pubDate>Tue, 14 Oct 2008 11:48:49 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[CGI版]]></category>
		<category><![CDATA[ini_set]]></category>
		<category><![CDATA[php_value]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=39</guid>
		<description><![CDATA[モジュール版ではなく、CGI版のPhpを使う場合、 (レンタルサーバを利用中でCGI版になってる場合）には、  [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>モジュール版ではなく、CGI版のPhpを使う場合、<br />
(レンタルサーバを利用中でCGI版になってる場合）には、<br />
特に何も設定をしなかった場合には、<br />
phpの環境変数(php.iniで設定されてるもの)を変更できない。</p>
<p>モジュール版の場合には、.htaccessに「php_value」を書いてみたり<br />
phpのソース（たとえばtest.phpみたいな）ものの中で「ini_set」をして<br />
設定を上書きすることができる(1部の設定を除く)わけですが、<br />
CGI版ではできないようですね。</p>
<p>phpinfoでみても「local」の部分が書き変わってないので、<br />
効いてないってことですね。</p>
<p>実際に試してみましたが、できませんでした。</p>
<p>これを回避する一般的な方法としては、suPHPを利用する形っぽいですね。</p>
<p>詳細は以下のサイトにのってるようですぜ。</p>
<p><a href="http://matsui.homeunix.com/index.php?FreeBSD%2FsuPHP">FlatEight.com >> FreeBSD/suPHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=39</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cent4&amp;PHP5&amp;Trac&amp;Pythonの甘い罠</title>
		<link>http://teclog.hattara.info/?p=34</link>
		<comments>http://teclog.hattara.info/?p=34#comments</comments>
		<pubDate>Thu, 09 Oct 2008 12:23:43 +0000</pubDate>
		<dc:creator><![CDATA[hattara]]></dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cent]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Trac]]></category>
		<category><![CDATA[Apache2]]></category>
		<category><![CDATA[Cent4]]></category>
		<category><![CDATA[エラーメッセージ]]></category>

		<guid isPermaLink="false">http://teclog.hattara.info/?p=34</guid>
		<description><![CDATA[Cent4(CentOS4)系でTrac(Python&#038;Sqlite)を使う場合に、 PHP5を利用 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Cent4(CentOS4)系でTrac(Python&#038;Sqlite)を使う場合に、<br />
PHP5を利用していると、(pdo_sqlite)がconflict?するようで、<br />
TracかPhpかどちらかしか動作しなくなる。</p>
<p>具体的には、yum版のApache2とかだと、<br />
/etc/httpd/conf.d/php.conf とかで以下の記述がある場合、<br />
Tracが動かなくなる。</p>
<blockquote><p>LoadModule php5_module modules/libphp5.so</p></blockquote>
<p>具体的には、ブラウザ上では、500エラーになり、<br />
エラーログでは、以下のような出力がたくさんでる。</p>
<blockquote><p>PythonHandler trac.web.modpython_frontend: DatabaseError: unsupported file format</p></blockquote>
<p>で、上記のLoadModuleをコメントアウトすると、Phpは動かなくなるが、<br />
Tracは動くようになる。</p>
<p>ということで、PhpでSqliteを使う予定がなければ、<br />
以下のようにpdo_sqlite.iniを適当な名前にリネームしてあげればよし。</p>
<blockquote><p>mv -i /etc/php.d/pdo_sqlite.ini /etc/php.d/pdo_sqlite.ini_org</p></blockquote>
<p>その後、Apacheの再起動をお忘れなく。<br />
yum版(rpm)のApacheの場合には、</p>
<blockquote><p>/usr/sbin/apachectl restart</p></blockquote>
<p>とかでいいですね。</p>
<p>で、以下のサイトを参考にさせてもらいました。</p>
<p><a href="http://www.ryuzee.com/contents/blog/670<br />
">Ryuzee.com >> CentOS4でPHP4から5にするとTracが動かなくなる</a></p>
]]></content:encoded>
			<wfw:commentRss>http://teclog.hattara.info/?feed=rss2&#038;p=34</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
