あぼかどブログ > Web > PHP > ToolsetTypesプラグインとPHP8系統のエラーの修正・対応方法

ToolsetTypesプラグインとPHP8系統のエラーの修正・対応方法

WordPressで運用しているサイトのPHPのバージョンを8系統にアップデートしたい。
アップデートするとToolset Typesプラグインが原因で「重大なエラー」となる。(PHP7系統では動作するっぽい)

修正・対応方法を調べるも、これといったものが見つからず。
四苦八苦して何とか正常動作できたのでメモを残します。

なお、質問をいただいてもお答えできません。
なんちゃってプログラマーなので、お答えできるほどのスキルがありません。
私の場合これで動作したので、同じように苦しんでいる方の参考までに。

<以下の環境でエラーなく、正常動作させたい>
■PHP⇒8.1.20
■WordPress⇒6.3.2
■Toolset Types⇒2.2.2

PHP8+Toolset Typeのエラーの修正・対応方法(1)

WordPressのログイン画面がエラーに。

-----
エラータイプ E_COMPILE_ERROR が ***/wp-content/plugins/types/vendor/toolset/toolset-common/lib/enlimbo.forms.class.php ファイルの 930 行目で発生しました。 エラーメッセージ: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`
-----
 ↓↓↓
930~931行目をコメントアウトし、1行追加
/*
return isset($_REQUEST[$name]) ? sanitize_text_field( $_REQUEST[$name] ) : in_array($element['#type'],
array('textfield', 'textarea')) ? '' : 0;
*/
return ( isset($_REQUEST[$name]) ? sanitize_text_field( $_REQUEST[$name] ) : in_array($element['#type'], array('textfield', 'textarea')) ) ? '' : 0;

PHP8+Toolset Typeのエラーの修正・対応方法(2)

ログイン画面のエラーは回避できるも、ダッシュボードでエラー表示。

-----
このサイトで重大なエラーが発生しました。対応手順については、サイト管理者のメール受信ボックスを確認してください。
WordPress のトラブルシューティングについてはこちらをご覧ください。
-----

気にせず、Toolset Type管轄のページから新規投稿してみる。
下書き保存でエラー。

-----
エラータイプ E_ERROR が ***/wp-content/plugins/types/vendor/toolset/toolset-common/utility/condition/theme/layouts-support/native/available.php ファイルの 29 行目で発生しました。 エラーメッセージ: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in ***/wp-content/plugins/types/vendor/toolset/toolset-common/utility/condition/theme/layouts-support/native/available.php:29
-----
 ↓↓↓
29行目をコメントアウト。
// $search_pattern = '{' . implode( $theme_paths, ',' ) . '}/{' . implode( $files_starting_with, ',' ) . '}*.php';

PHP8+Toolset Typeのエラーの修正・対応方法(3)

ダッシュボードからエラーは消えるも、編集画面で再びエラー。

-----
エラータイプ E_COMPILE_ERROR が ***/wp-content/plugins/types/vendor/twig/twig/lib/Twig/Node.php ファイルの 42 行目で発生しました。 エラーメッセージ: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`
-----
 ↓↓↓
42行目をコメントアウトし、以下を追加
// @trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED);
@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', \is_object($node) ? \get_class($node) : (null === $node ? 'null' : \gettype($node)), $name, \get_class($this)), E_USER_DEPRECATED);
 ↓↓↓
改善せず、重大エラーのまま
 ↓↓↓
-----
エラータイプ E_COMPILE_ERROR が ***/wp-content/plugins/types/vendor/twig/twig/lib/Twig/Node.php ファイルの 199 行目で発生しました。 エラーメッセージ: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`
-----
 ↓↓↓
199行目をコメントアウトし、以下を追加
// @trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED);
@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', \is_object($node) ? \get_class($node) : (null === $node ? 'null' : \gettype($node)), $name, \get_class($this)), E_USER_DEPRECATED);

上記で動作するようになりました(^-^)

<最後に>
繰り返しになりますが、質問をいただいてもお答えできません。
なんちゃってプログラマーなので、お答えできるほどのスキルがありません。
私の場合これで動作したので、同じように苦しんでいる方の参考までに。

【前後の記事】
«
 
»
 

コメントを残す

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