From 3c96ad01aab8e01f1ec8b51b39d359568ae1fe3e Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 10 Jun 2024 19:55:34 -0700 Subject: [PATCH] correctly rename strings of prefixed PEAR classes in pear-core-minimal --- resources/core-scoper.inc.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resources/core-scoper.inc.php b/resources/core-scoper.inc.php index ab51919..d3a1edc 100644 --- a/resources/core-scoper.inc.php +++ b/resources/core-scoper.inc.php @@ -29,6 +29,7 @@ ->exclude('build') ->exclude('vendor/prefixed') ->exclude('vendor/composer') + ->exclude('vendor/phpmailer') // wordfence creates a false positive here ->exclude('node_modules') ->exclude('tmp') ->exclude('@types') @@ -93,6 +94,21 @@ static function (string $filePath, string $prefix, string $content) use ($isRena $content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\?Archive_Tar(?!\\/)/', '$1\\Matomo\\Dependencies\\Archive_Tar', $content); $content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\?Console_Getopt(?!\\/)/', '$1\\Matomo\\Dependencies\\Console_Getopt', $content); $content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\?OS_Guess(?!\\/)/', '$1\\Matomo\\Dependencies\\OS_Guess', $content); + + return $content; + }, + + static function (string $filePath, string $prefix, string $content) use ($isRenamingReferences): string { + if ($isRenamingReferences) { + return $content; + } + + if (strpos($filePath, 'pear/pear-core-minimal') !== false) { + $content = str_replace("'PEAR_Error'", "'\\\\Matomo\\\\Dependencies\\\\PEAR_Error'", $content); + $content = str_replace("'PEAR_ErrorStack'", "'\\\\Matomo\\\\Dependencies\\\\PEAR_ErrorStack'", $content); + $content = str_replace("'System'", "'\\\\Matomo\\\\Dependencies\\\\System'", $content); + } + return $content; },