Sabberworm namespace issue in packaged releases (autoload.inc.php)
markkimsal opened this issue · 3 comments
I'm creating a stand alone server project that may or may-not allow multiple, selectable versions of dompdf. I'm using the pre-packaged releases, but the autoload.inc.php doesn't seem to handle Sabberworm namespaces properly
Two simple fixes:
- The filenames seem to no longer have Sabberworm/CSS/ in the paths.
- The php-css-parser/
lib/
has changed tosrc/
// Sabberworm
spl_autoload_register(function($class)
{
if (strpos($class, 'Sabberworm') !== false) {
$file = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$file = str_replace('Sabberworm/CSS/', '', $file); // added
$file = realpath(__DIR__ . '/lib/php-css-parser/src/' . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php'); // changed
if (file_exists($file)) {
require_once $file;
return true;
}
}
return false;
});
I would create a PR, but I cannot find this file or one that generates it.
This is low priority because I can simply include a patched copy of this autoload.inc.php. I've found that this seems to affect 1.1.1 and 1.2.0
P.S., the second str_replace should probably use DS constant or happen before the first str_replace.
The autoloader is currently housed in the utils project. I've moved the issue. Thanks for pointing out the issue. My build system doesn't currently run any tests against the packaged version but I should probably include that in the process.
I'll recreate the 1.1.1 and 1.2.0 packages with the patched autoloader.
I'm going to drop the autoloader from the repo now that we're using Composer to aid in packaged release generation.