0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP 7.2から7.3へのアップデートでハマった話(WordPress)

Last updated at Posted at 2019-06-16

PHP 7.3がやってきます

筆者はさくらインターネットで WordPress サイトを複数動かしているんですが、2019年8月に PHP 7.2 のサポートが終了するのに合わせて、PHP 7.3 へのバージョンアップのアナウンスがされています。放っといても7月には自動で7.3に変更されるそうです。

PHP 7.3 にあげてみたら BAD GATEWAY

そこでコンパネから 7.3 にあげてみたら、サイトの反応がありません。読み込み試行が十数秒続き画面には「Bad Gateway」と表示されます。

WordPress 5.2 から導入されたリカバリモードも全然動きません。もっと深い部分です。

まずローカルXAMPPで試してみる → 動く

7.3 が原因なのは間違いないので、ローカルのXAMPP環境(PHP 7.3)を用意してまるごとサイトをインポートしてみましたが正常に動作。

さくらインターネットの別アカウントにゼロから設定 → 動かない

別アカウントのサーバにまっさらからやってみましたが、All in one Migration で取り込むと同じ問題が再発。

原因は自作プラグインの case 文

結局プラグインを一個ずつオンにしていくと自作プラグインが残りましたw。コードをゾーンでコメントアウトすると case 文が原因として残りました。

  for ($i=0;$i<=1;$i++) {
    ...
    switch ($i) {
      case -1: $date_text = '【昨日】'; break;
      case  0: $date_text = '【今日】'; break;
      case  1: $date_text = '【明日】'; break;
      default: $date_text = ''; 
    }

この、case -1case 0case 1のうちcase 1を外すと動作することを発見(4時間かっかった)。

    switch ($i) {
      case "-1": $date_text = '【昨日】'; break;
      case  "0": $date_text = '【今日】'; break;
      case  "1": $date_text = '【明日】'; break;
      default: $date_text = ''; 
    }

こうすればうごきました。きっと型の変換で整合性が取れなくなってるに違いないのですが、普通に動く環境もあるのが謎なのです。
PHP のオプションとか?

もし同じ問題を抱えてる方がいらっしゃってこの内容が役に立ったら幸いです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?