IP GEO Blockをインストールすると管理画面が表示されなくなる【WordPress】

スポンサーリンク
Linux
スポンサーリンク
↑管理人が個人でUnity+Live2Dで作成しているスマホゲームです

PHPが新しいバージョンでIP GEO Blockをインストール&有効化すると、管理画面が重大なエラーが発生しましたと出て表示されなくなります。

これはPHPの仕様変更で、これまで配列の要素を示すのに中括弧が使えていたのが使えなくなったためです。
サーバのエラーログには以下のような内容が出力されます。

FastCGI sent in stderr: “PHP message: PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /var/www/***/wp-content/ip-geo-api/ip2location/bcmath.php on line 70” while reading response header from upstream, client: ***, server: ***, request: “GET /wp-admin/admin.php?page=stats&noheader&proxy&chart=admin-bar-hours-scale-2x HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm.sock:”, host: “***”, referrer: “***”

プラグインの該当ファイルを編集していきます。

wp-content/ip-geo-api/ip2location/bcmath.php
70 行目
$Sum=((int)$Num1{$i}+(int)$Num2{$i});
-> $Sum=((int)$Num1[$i]+(int)$Num2[$i]);

126 
$Sum=((int)$Num1{$i}-(int)$Num2{$i});
->$Sum=((int)$Num1[$i]-(int)$Num2[$i]);

156,157
for($i=0;$i<strlen($Num1);$i++) {if(@$Num1{$i}!='0') {$Num1=substr($Num1,$i);break;}}
->for($i=0;$i<strlen($Num1);$i++) {if(@$Num1[$i]!='0') {$Num1=substr($Num1,$i);break;}}
for($i=0;$i<strlen($Num2);$i++) {if(@$Num2{$i}!='0') {$Num2=substr($Num2,$i);break;}}
->for($i=0;$i<strlen($Num2);$i++) {if(@$Num2[$i]!='0') {$Num2=substr($Num2,$i);break;}}

171
@$Rema[$i++%$Len2].=sprintf('%02d',(int)$Num1{$y}(int)$Num2{$x}); 
->@$Rema[$i++%$Len2].=sprintf('%02d',(int)$Num1[$y](int)$Num2[$x]);

177 
@$Rema2[Floor(($x-1)/2)+1+$y]+=(int)$Rema[$y]{$x};
->@$Rema2[Floor(($x-1)/2)+1+$y]+=(int)$Rema[$y][$x];

194
while(strlen($Rema2)>1&amp;&amp;$Rema2{0}=='0') $Rema2=substr($Rema2,1);
->while(strlen($Rema2)>1&amp;&amp;$Rema2[0]=='0') $Rema2=substr($Rema2,1);

/wp-content/ip-geo-api/ip2location/IP2Location.php
382
if ($f_value{1} == '') { if ($f_value[1] == '') {
->if ($f_value[1] == '') { if ($f_value[1] == '') {

385
if ($f_value{0} != 'd') {
->if ($f_value[0] != 'd') {

/wp-content/plugins/ip-geo-block/includes/Net/IPv6
849
$ip{$pos} = '_';
->$ip[$pos] = '_';

ひとまずここまでやれば管理画面は表示できますが、他にも修正が必要な箇所があるかもしれません。

そのうちプラグインのバージョンアップで解決されるかと思います。

1 Star2 Stars3 Stars4 Stars5 Stars (まだ投票されていません)
読み込み中...

コメント

広告ブロッカーを無効にしてください。

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