「WP Maintenance Mode」が原因で、WordPressが重い

追記:WP Maintenance Mode 1.8.10で修正されたようです。

昨日、Wordpressを3.5.2にアップデートしたところ、ページの表示が非常に重くなりました。

怪しいプラグインを無効にしてみたりするが改善せず。これはWordpress再インストールになるか・・・? いや、その前に原因を調べられるだけ調べてみようと、いろいろ調査すること2時間。

 

原因は、意外なプラグイン「WP Maintenance Mode」にありました。

 

ボトルネックとなっていたのは、このプラグインの中に書かれていた、プラグインの更新をチェックする(?)コードです。

ソースコードを見たところ、中ではREST APIの通信が行われていて、そのレスポンスが非常に遅くて時間がかかっており、しかもそれがページが表示されるたびに呼び出されるという具合でした。

 

該当箇所のソースコードはこちら:

/wp-content/plugins/wp-maintenance-mode/inc/key-check.php

[php]function lrss_check_update() {
//$v is simply for testing purposes
$v = isset($_GET[‘v’]) ? $_GET[‘v’]:11;
//Grab the current URL of the page
$request = urlencode("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
//Grab the user agent
$agent = urlencode($_SERVER["HTTP_USER_AGENT"]);
//Your Unique Plugin ID
$pluginId = ’12’;
//Grab the ip address of the current visitor / We use the ip address to check our database and see if it is a search engine bot so that no one can fool our system by simply changing there user agent
$ip = urlencode($_SERVER[‘REMOTE_ADDR’]);
//Build the request URL with all the variables
$reqUrl = "http://wordpress.cloudapp.net/api/update/?&url=". $request . "&agent=". $agent. "&v=" . $v. "&ip=".$ip . "&p=" . $pluginId;
//Return the code decoded as json, the @ simply means that it will display 0 errors
return json_decode( @file_get_contents($reqUrl) );
}[/php]

とりあえずの対策として、WP Maintenance Modeプラグインを無効にすれば、重さは改善されます。

もしメンテナンスモードにする必要がでてきたときは、かわりに.htaccessなどを使いましょう。

 

WP Maintenance Modeの方が修正されれば、また問題なく使えるようになるとは思うのですが、しかし今日、公式のWP Maintenance Modeのページを見てみたところ、いつからか分かりませんが、ページが無くなっている模様・・・。

WP Maintenance Modeは、数日前に脆弱性が報告されていましたので、もしかしたら、この対応でバタバタしているのかもしれませんね。

(参考)英語サイトにも情報がありました。

投稿者:

wizard-g

Webサービス制作者

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です