weixin_39591720 2020-11-21 18:24
浏览 0

Occasional error: json_decode() expects parameter 1 to be string, null given

At seemingly random times I'm getting the error: json_decode() expects parameter 1 to be string, null given.

Stack trace:

php
Fatal error: Uncaught TypeError: json_decode() expects parameter 1 to be string, null given in /var/www/html/src/vendor/jeremykendall/php-domain-parser/src/Manager.php on line 111
( ! ) TypeError: json_decode() expects parameter 1 to be string, null given in /var/www/html/src/vendor/jeremykendall/php-domain-parser/src/Manager.php on line 111
Call Stack
#   Time    Memory  Function    Location
1   0.0057  424528  {main}( )   .../process.php:0
2   0.0240  532120  Pdp\Manager->getRules( )    .../process.php:214
3   0.5702  536456  json_decode ( ) .../Manager.php:111

Here's how I call manager:

php
require './vendor/autoload.php';

use League\Uri;
use Pdp\Cache;
use Pdp\CurlHttpClient;
use Pdp\Manager;
use Pdp\Rules;

$manager = new Manager(new Cache(), new CurlHttpClient(), '1 DAY');
$rules = $manager->getRules();

Is this a bug?

该提问来源于开源项目:jeremykendall/php-domain-parser

  • 写回答

5条回答 默认 最新

  • weixin_39591720 2020-11-21 18:24
    关注

    It looks like this problem is cache related. Whenever I run the script in the OP, it deletes the pdp-PSL_FULL_.123456 cache file.

    If I add the cache file back with: cd /var/www/html/src/vendor/jeremykendall/php-domain-parser/bin/ && ./update-psl

    And then run the OP script, it deletes the cache file again. Which is causing the Fatal error: Uncaught TypeError: json_decode() expects parameter 1 to be string, null given error.

    Any idea what's going on here?

    评论

报告相同问题?