PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.19
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.19
4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 All 173 releases
← All changes | BerqWP/scoper.inc.php +11 -26 4.0.18 → 4.1.19 View file →
@@ -52,37 +52,22 @@
52 52 'WP_CONTENT_DIR',
53 53 ],
54 54
55 55 'patchers' => [
56 - // autoload_static.php lives in namespace Composer\Autoload, so its PSR-4 map
57 - // keys are literal strings without the BerqWP_Deps prefix. PHP-Scoper doesn't
58 - // rewrite them because it excludes the Composer namespace. This patcher adds
59 - // the prefix to every vendor namespace key so the ClassLoader can resolve
60 - // BerqWP_Deps\GuzzleHttp\*, BerqWP_Deps\voku\*, etc.
56 + // Composer\InstalledVersions is declared by many plugins without a class_exists
57 + // guard, causing "cannot redeclare class" fatals. Wrap our copy in a guard.
58 + // Note: autoload_static.php is generated output by php-scoper, not an input file,
59 + // so it cannot be patched here — it is fixed by fix-autoload-static.php in Makefile.
61 60 static function (string $filePath, string $prefix, string $content): string {
62 - if (!str_ends_with($filePath, 'composer/autoload_static.php')) {
61 + if (!str_ends_with($filePath, 'composer/InstalledVersions.php')) {
63 62 return $content;
64 63 }
65 -
66 - $vendorNamespaces = [
67 - 'voku\\helper\\' => 24,
68 - 'Symfony\\Polyfill\\Php80\\' => 36,
69 - 'Symfony\\Component\\CssSelector\\' => 43,
70 - 'Psr\\Http\\Message\\' => 30,
71 - 'Psr\\Http\\Client\\' => 29,
72 - 'GuzzleHttp\\Psr7\\' => 29,
73 - 'GuzzleHttp\\Promise\\' => 32,
74 - 'GuzzleHttp\\' => 24,
75 - ];
76 -
77 - foreach ($vendorNamespaces as $ns => $newLen) {
78 - // Prefix the key in $prefixLengthsPsr4 and $prefixDirsPsr4
79 - $content = str_replace("'$ns'", "'{$prefix}\\\\{$ns}'", $content);
80 - // Fix the length value (original length without prefix → new length with prefix)
81 - $oldLen = strlen($ns);
82 - $content = str_replace("'{$prefix}\\\\{$ns}' => $oldLen", "'{$prefix}\\\\{$ns}' => $newLen", $content);
83 - }
84 -
64 + $content = str_replace(
65 + "class InstalledVersions\n{",
66 + "if (!class_exists('Composer\\\\InstalledVersions', false)) {\nclass InstalledVersions\n{",
67 + $content
68 + );
69 + $content = rtrim($content) . "\n} // end class_exists check\n";
85 70 return $content;
86 71 },
87 72 ],
88 73 ];