Fatal on autoloader conflict with my block

Fatal on autoloader conflict with my block

by Mark van Hoek -
Number of replies: 2
Picture of Core developers Picture of Plugin developers

I maintain a Moodle block (https://bitbucket.org/mwebv/moodle-block_integrityadvocate/src/master/) which uses composer's standard autoload to include several third-party libraries, including GuzzleHTTP.  The problem is the PooDLL filter then comes executes and attempts to autoloads GuzzleHTTP without checking if the class/function already exists first, so we get:

--

Fatal error: Cannot redeclare GuzzleHttp\json_encode() (previously declared in /var/www/html/blocks/integrityadvocate/vendor/guzzlehttp/guzzle/src/functions.php:324) in /var/www/html/filter/poodll/3rdparty/aws-v3/GuzzleHttp/functions.php on line 322  

--

I see in filter\poodll\3rdparty\aws-v3\aws-autoloader.php this code

--

spl_autoload_register(function ($class) use ($mapping) {
    if (isset($mapping[$class])) {
        require $mapping[$class];
    }
}, true);

--


I think this code should check if the class exists - something like:

--

spl_autoload_register(function ($class) use ($mapping) {
    if (isset($mapping[$class]) && !class_exists($class, false) ) {
        require_once $mapping[$class];
    }
}, true);

--


Average of ratings: -
In reply to Mark van Hoek

Re: Fatal on autoloader conflict with my block

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Mark

I understand and sorry about that. But the good news is that I think you must be using an old version of Poodll filter. We took the AWS SDK right out of Poodll. Can you update? Check here to make sure if you like. https://github.com/justinhunt/moodle-filter_poodll

After you update the Poodll filter requires an API user and secret (not the old registration code) . Thats been the recommended way for a while so you might be ok to just update. If not, you can pick them up from https://poodll.com/member . Then paste them into the Poodll filter general settings page.
In reply to Justin Hunt

Re: Fatal on autoloader conflict with my block

by Mark van Hoek -
Picture of Core developers Picture of Plugin developers

Confirmed we are on PooDLL version 3.1.21(Build 2019052000) which includes the AWS code and the latest version PooDLL version 3.1.35 (Build 2020062400) does not include the AWS code.

I don't see any other packages in common with my block, so I think that fixes it.

Thanks a bunch Justin!