WordPressで更新をかけると、CSS & JavaScript Toolbox がいきなりエラー!!
Warning: count(): Parameter must be an array or an object that implements Countable
これは、PHPのバージョン7.2の仕様変更によるもので、マニュアルには下記の記載がある。
In PHP 7.2.0
count(NULL) returns a warning:
Warning: count(): Parameter must be an array or an object that implements CountableIn previous versions:
count(NULL) returned 0 without any warnings.
つまり、以前の記事にも記載したが、プラグイン CSS & JavaScript Toolbox が PHP7.2に対応していないのだ。
このエラーは
YourSite\wp-content\plugins\css-javascript-toolbox\framework\events\subjects\ の中の hook.subject.php に起因する。
81,82行目にある、下記の部分
1 2 |
add_action($this->getHookName(), array(&$this, 'trigger'), 10, count($this->getDefinition('parameters'))); add_action($this->getInstanceHookName(), array(&$this, 'trigger'), 10, count($this->getDefinition('parameters'))); |
ここがエラー原因なので、下記のように修正すると、エラーはなくなります。
1 2 3 4 |
if( ! empty ( $this->getDefinition('parameters') )){ add_action($this->getHookName(), array(&$this, 'trigger'), 10, count($this->getDefinition('parameters'))); add_action($this->getInstanceHookName(), array(&$this, 'trigger'), 10, count($this->getDefinition('parameters'))); } |