We recently released a new version of our Zoom meeting plugin and discovered that the Firebase/JWT library we are including gets into a conflict if another plugin includes the same library in their plugin.
This is my hacky solution: https://github.com/ucla/moodle-mod_zoom/commit/88559bf691c8976635f4649543ff554c1d41502d#diff-d944aa757018f57bda16a1ccf8199b5bR31
// Some plugins already might include this library, like mod_bigbluebuttonbn.
// Hacky, but need to create whitelist of plugins that might have JWT library.
if (!class_exists('Firebase\JWT\JWT')) {
if (file_exists($CFG->dirroot.'/mod/bigbluebuttonbn/vendor/firebase/php-jwt/src/JWT.php')) {
require_once($CFG->dirroot.'/mod/bigbluebuttonbn/vendor/firebase/php-jwt/src/JWT.php');
} else {
require_once($CFG->dirroot.'/mod/zoom/jwt/JWT.php');
}
}
But as you can see it is not scalable because there might be more plugins that include the same library. Any better workarounds? I tried just having the class_exists() call, but sometimes the other plugin lib.php file gets included before or after I include the JWT library.
Maybe I can just check if the class_exists() right when I create the Firebase\JWT class at https://github.com/ucla/moodle-mod_zoom/blob/88559bf691c8976635f4649543ff554c1d41502d/classes/webservice.php#L126, but is there a better solution?