お問い合わせはコチラから

wp cliで変なエラーでアボートする時の対策

サイト運営

wp cliで一括処理するととても便利なのですが、処理が途中で止まってしまうことがありました。

何度かやっても同じようなところで止まってしまい、wp cliのファイルからエラーを吐いているので、原因はよくわからず。

wp cliアボートの原因はプラグイン?

よくよく見てみて見るとプラグインのファイル名があったので、XML sitemapのプラグインがギブアップしている可能性が高いと考えました。

記事の更新を連続して行っている処理だったので、更新の通知の影響でXML sitemapプラグインが動いているのかもしれません。

PHP Warning:  include(phar:///home/xxxx/bin/wp/vendor/composer/../rmccue/requests/library/Requests/Exception.php): failed to open stream: phar error: Cannot open phar archive "/home/xxxx/bin/wp" for reading in phar:///home/xxxx/bin/wp/vendor/composer/ClassLoader.php on line 571
Warning: include(phar:///home/xxxx/bin/wp/vendor/composer/../rmccue/requests/library/Requests/Exception.php): failed to open stream: phar error: Cannot open phar archive "/home/xxxx/bin/wp" for reading in phar:///home/xxxx/bin/wp/vendor/composer/ClassLoader.php on line 571
PHP Warning:  include(): Failed opening 'phar:///home/xxxx/bin/wp/vendor/composer/../rmccue/requests/library/Requests/Exception.php' for inclusion (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in phar:///home/xxxx/bin/wp/vendor/composer/ClassLoader.php on line 571
Warning: include(): Failed opening 'phar:///home/xxxx/bin/wp/vendor/composer/../rmccue/requests/library/Requests/Exception.php' for inclusion (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in phar:///home/xxxx/bin/wp/vendor/composer/ClassLoader.php on line 571
PHP Fatal error:  Uncaught Error: Class 'Requests_Exception' not found in phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests/Transport/cURL.php:443
Stack trace:
#0 phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests/Transport/cURL.php(179): Requests_Transport_cURL->process_response('', Array)
#1 phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests.php(381): Requests_Transport_cURL->request('https://www.bin...', Array, NULL, Array)
#2 /home/xxxx/public_html/yyyy/wp-includes/class-wp-http.php(395): Requests::request('https://www.bin...', Array, NULL, 'GET', Array)
#3 /home/xxxx/public_html/yyyy/wp-includes/http.php(145): WP_Http->request('https://www.bin...', Array)
#4 /home/xxxx/public_html/yyyy/wp-content/plugins/xml-sitemap-feed/models/functions.shared.php(125): wp_remote_request('https://www.bin...')
#5 /home/xxxx/public_html/yyyy/wp-content/plugins/xml-sitemap-feed/controller in phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests/Transport/cURL.php on line 443
Fatal error: Uncaught Error: Class 'Requests_Exception' not found in phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests/Transport/cURL.php:443
Stack trace:
#0 phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests/Transport/cURL.php(179): Requests_Transport_cURL->process_response('', Array)
#1 phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests.php(381): Requests_Transport_cURL->request('https://www.bin...', Array, NULL, Array)
#2 /home/xxxx/public_html/yyyy/wp-includes/class-wp-http.php(395): Requests::request('https://www.bin...', Array, NULL, 'GET', Array)
#3 /home/xxxx/public_html/yyyy/wp-includes/http.php(145): WP_Http->request('https://www.bin...', Array)
#4 /home/xxxx/public_html/yyyy/wp-content/plugins/xml-sitemap-feed/models/functions.shared.php(125): wp_remote_request('https://www.bin...')
#5 /home/xxxx/public_html/yyyy/wp-content/plugins/xml-sitemap-feed/controller in phar:///home/xxxx/bin/wp/vendor/rmccue/requests/library/Requests/Transport/cURL.php on line 443
PHP Warning:  opendir(/home/xxxx/public_html/yyyy/wp-content/uploads/wpcf7_uploads/): failed to open dir: Too many open files in /home/xxxx/public_html/yyyy/wp-content/plugins/contact-form-7/includes/file.php on line 359
Warning: opendir(/home/xxxx/public_html/yyyy/wp-content/uploads/wpcf7_uploads/): failed to open dir: Too many open files in /home/xxxx/public_html/yyyy/wp-content/plugins/contact-form-7/includes/file.php on line 359

臭いプラグインを読み込まないようにしてwp cliを実行する

wp cliはthemeやpluginを読み込まないオプションがあります。

特定のプラグインだけ読み込まないこともできますので、それで対応します。

wp eval-file xxxx.php --skip-plugins=xml-sitemap-feed

ファイルの開きすぎでアボートする

Too many open files

というエラーでアボートする場合は、ファイルを開ける制限の上限を上げて回避します。

exec('ulimit -S -n 2048');
Fatal Error - Too many open files
I try to run PHPUnit Tests in my new machine and I get this error: PHP Fatal error: Uncaught exception 'UnexpectedValueE...

Goutteなどのライブラリを使っている

Goutteなどのhttpクライアントライブラリなどを使っている場合、ファイル数が多すぎますというエラーが出やすいようでした。

PHPのnative DOMを使うと問題が解決します。

まとめ

wp cliで異常終了したときは、原因がよくわからないことが多いですが、wp cliのバグの可能性は低いです。

ほとんどの場合はコアの機能とは関係ない部分が原因だと思いますので、テーマやプラグインを読み込まないようにすることで対応できると思います。

ただ、処理に必要なものまで読み込まなくしてしまうと処理が成立しなくなりますので、そこは切り分けが必要になるでしょう。

この記事を書いた人
ブーン

はるばる日本よりオランダ王国へやってまいりました。
自分の経験が少しでも参考になれば嬉しいです。
お問い合わせは、『こちら』からお願い致します。

\ブーンをフォロー/
スポンサーリンク
サイト運営
\シェアお願いします!/
\ブーンをフォロー/
こんな記事も読まれています

失敗しないレンタルサーバーランキング

mixhost

不正アクセスに強くて使いやすいおススメサーバー
\本サイトで利用中/
メリット①:自動ウィルス駆除対応
メリット②:サイトの表示速度が速い!
メリット③:転送量の上限が多い!
メリット④:自由にプラン変更ができ、アクセス増にも対応できる!
メリット⑤:バックアップデータが無料で復元できる!
メリット⑥:Wordpressが簡単にインストールできる!
メリット⑦:どのプランでも初期費用が無料!
メリット⑧:10日間の無料お試し期間と30日の返金保証!

Conoha Wing

国内Wordpress最速の最強サーバー
メリット①:圧倒的な表示速度
メリット②:レンタルサーバーと独自ドメインがセットでお得◎
メリット③:プラン変更はすべてのプランで自由自在
メリット④:一か月の利用転送量の制限が緩い(9TB~)
メリット⑤:WordPresサイトの移行が簡単

エックスサーバー

国内シェアNo1の安定性と実績が魅力。ALL SSDで死角なしの万能サーバー。
メリット①:サイトの表示速度が安定して速い!
メリット②:アクセス負荷に強くて安定性が高い!
メリット③:24時間365日の充実サポートで安心!電話サポートもあり!
メリット④:転送量が多い!
メリット⑤:自動バックアップ機能付き!
メリット⑥:WordPressが簡単にインストールできる!
メリット⑦:10日の無料お試し期間がある!

タイトルとURLをコピーしました