• サイトを運用しているサーバーのPHPバージョンが先日7.2に上がり、
    投稿画面でCustom field template欄に、Warningが表示されるようになってしまいました。

    Warning: count(): Parameter must be an array or an object that implements Countable in /www/wp/wp-content/plugins/custom-field-template/custom-field-template.php on line 2352

    調べてみたところ、
    https://php.net/manual/ja/function.count.php#122173
    7.2以降、Countableタイプ以外を指定するとWarningが出るみたいなのですが、これは
    私の環境だけでしょうか?
    Warningが出ないようにする方法ありましたら教えていただけると助かります。

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter under

    (@under)

    解決できたので自己レス。
    エラーの該当箇所をarrayで括り条件をつけることでエラーを回避。

     $ct_value = count($value);
    
    ↓
    
    if (is_array($value)) {$ct_value = count($value);};

    当方では2352行目と合わせて3365行目についても同じWarningがCustom field template欄に表示されます。
    また、投稿の更新ボタンを押した際に、3364行目のWarningにより302転送が失敗して「白い画面」になってしまいます。

    Warning: count(): Parameter must be an array or an object that implements Countable in /wp-content/plugins/custom-field-template/custom-field-template.php on line 3364

    Warning: Cannot modify header information – headers already sent by (output started at /wp-content/plugins/custom-field-template/custom-field-template.php:3364) in /wp-admin/post.php on line 198

    Warning: Cannot modify header information – headers already sent by (output started at /wp-content/plugins/custom-field-template/custom-field-template.php:3364) in /wp-includes/pluggable.php on line 1219

    先ほどリリースされた2.4.5で修正されたようです。

    Thread Starter under

    (@under)

    おっと、アップデートされたのですね、早速試してみます。
    このままコアファイルをいじったバージョン使うのは気持ちよくなかったので私もスッキリしそうです。
    作者様いつもありがとうございます。

    こちら2.4.5でも下記行でエラー同じエラーだったのでご報告させていただきます。

    Warning: count(): Parameter must be an array or an object that implements Countable in /home/kusanagi/kusanagi_html/DocumentRoot/wp-content/plugins/custom-field-template/custom-field-template.php on line 1977

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Warning on PHP 7.2’ is closed to new replies.