From aa10200318c09a8b61377acf6fa85cbb4f2035f6 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 10:23:11 +0100 Subject: [PATCH 01/29] Fix regular expressions for 'exclude tests' --- .../Magento/Setup/Console/Command/DiCompileCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 4c50a3de4fb3..d81168478e79 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -256,8 +256,8 @@ private function getExcludedModulePaths(array $modulePaths) } $excludedModulePaths = [ - '#^(?:' . join('|', $basePathsRegExps) . ')/Test#', - '#^(?:' . join('|', $basePathsRegExps) . ')/tests#', + '#^(?:' . join('|', $basePathsRegExps) . ')/Tests?/#', + '#^(?:' . join('|', $basePathsRegExps) . ')/tests/#', ]; return $excludedModulePaths; } @@ -278,8 +278,8 @@ function ($libraryPath) { ); $excludedLibraryPaths = [ - '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?Test#', - '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?tests#', + '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?Tests?/#', + '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?tests/#', ]; return $excludedLibraryPaths; } @@ -293,7 +293,7 @@ function ($libraryPath) { private function getExcludedSetupPaths($setupPath) { return [ - '#^(?:' . preg_quote($setupPath, '#') . ')(/[\\w]+)*/Test#' + '#^(?:' . preg_quote($setupPath, '#') . ')(/[\\w]+)*/Tests?/#' ]; } From d5cb373a708a7d2bc5475bba0af8c6c7ec14a5fc Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 22:41:56 +0100 Subject: [PATCH 02/29] Revert "Fix regular expressions for 'exclude tests'" This reverts commit aa10200318c09a8b61377acf6fa85cbb4f2035f6. --- .../Magento/Setup/Console/Command/DiCompileCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index d81168478e79..4c50a3de4fb3 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -256,8 +256,8 @@ private function getExcludedModulePaths(array $modulePaths) } $excludedModulePaths = [ - '#^(?:' . join('|', $basePathsRegExps) . ')/Tests?/#', - '#^(?:' . join('|', $basePathsRegExps) . ')/tests/#', + '#^(?:' . join('|', $basePathsRegExps) . ')/Test#', + '#^(?:' . join('|', $basePathsRegExps) . ')/tests#', ]; return $excludedModulePaths; } @@ -278,8 +278,8 @@ function ($libraryPath) { ); $excludedLibraryPaths = [ - '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?Tests?/#', - '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?tests/#', + '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?Test#', + '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?tests#', ]; return $excludedLibraryPaths; } @@ -293,7 +293,7 @@ function ($libraryPath) { private function getExcludedSetupPaths($setupPath) { return [ - '#^(?:' . preg_quote($setupPath, '#') . ')(/[\\w]+)*/Tests?/#' + '#^(?:' . preg_quote($setupPath, '#') . ')(/[\\w]+)*/Test#' ]; } From 5fdf3d4b2580739cf9ea6d3804497fa39c9cabc0 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 22:52:58 +0100 Subject: [PATCH 03/29] Allow only valid preferences during di:compile --- .../Module/Di/Compiler/Config/Reader.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php index 3b8d301fb3d0..9c17939f3e07 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php @@ -7,7 +7,9 @@ namespace Magento\Setup\Module\Di\Compiler\Config; use Magento\Framework\App; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\ObjectManager\ConfigInterface; +use Magento\Framework\Phrase; use Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator; use Magento\Setup\Module\Di\Code\Reader\Type; use Magento\Setup\Module\Di\Compiler\ArgumentsResolverFactory; @@ -92,6 +94,37 @@ public function generateCachePerScope( foreach ($definitionsCollection->getInstancesNamesList() as $instanceName) { $preference = $areaConfig->getPreference($instanceName); if ($instanceName !== $preference) { + if (array_key_exists($preference, $areaConfig->getVirtualTypes())) { + // Special handling is required for virtual types. + $config['preferences'][$instanceName] = $preference; + continue; + } + + if (!class_exists($preference)) { + throw new LocalizedException(new Phrase( + 'Preference declared for "%instanceName" as "%preference", but the latter does not exist.', + [ + 'instanceName' => $instanceName, + 'preference' => $preference, + ] + )); + } + + // Classes defined by PHP extensions are allowed. + $reflection = new \ReflectionClass($preference); + if ($reflection->getExtension()) { + $config['preferences'][$instanceName] = $preference; + continue; + } + + if (!$definitionsCollection->hasInstance($preference)) { + // Removing this preference, because its class has been excluded intentionally. + // See 'excludePatterns' in Magento\Setup\Module\Di\Code\Reader\ClassesScanner, + // populated via Magento\Setup\Console\Command\DiCompileCommand + // TODO: add logging here so developers get useful messaging. + continue; + } + $config['preferences'][$instanceName] = $preference; } } From 38c2061f0ecc4eb1f580e2cf4c48b9850cf1637e Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 22:57:02 +0100 Subject: [PATCH 04/29] Remove invalid preferences --- app/code/Magento/Catalog/etc/di.xml | 1 - app/code/Magento/RemoteStorage/etc/di.xml | 1 - app/etc/di.xml | 1 - .../testsuite/Magento/Test/Legacy/_files/obsolete_classes.php | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index b509debe7bae..5fc3c6880057 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -73,7 +73,6 @@ - diff --git a/app/code/Magento/RemoteStorage/etc/di.xml b/app/code/Magento/RemoteStorage/etc/di.xml index aa1447b84b2c..85114f186e2f 100644 --- a/app/code/Magento/RemoteStorage/etc/di.xml +++ b/app/code/Magento/RemoteStorage/etc/di.xml @@ -9,7 +9,6 @@ - Magento\RemoteStorage\Driver\DriverPool diff --git a/app/etc/di.xml b/app/etc/di.xml index 9bb5e00d48f9..f0341316ef74 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -82,7 +82,6 @@ - diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index c4ae253fe749..3dc237171c20 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -2845,7 +2845,7 @@ ['Magento\Framework\Stdlib\CookieManager', 'Magento\Framework\Stdlib\CookieManagerInterface'], ['Magento\Framework\Interception\PluginList', 'Magento\Framework\Interception\PluginListInterface'], ['Magento\Framework\Interception\Config', 'Magento\Framework\Interception\ConfigInterface'], - ['Magento\Framework\Interception\Chain', 'Magento\Framework\Interception\ChainInterface'], + ['Magento\Framework\Interception\Chain'], ['Magento\Framework\Interception\Definition', 'Magento\Framework\Interception\DefinitionInterface'], ['Magento\Framework\ObjectManager\Factory', 'Magento\Framework\ObjectManager\FactoryInterface'], ['Magento\Framework\ObjectManager\Config', 'Magento\Framework\ObjectManager\ConfigInterface'], From 0677c171842c16c24381a63b205ecb02e0a04ddf Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 22:58:03 +0100 Subject: [PATCH 05/29] Allow classes without contructors --- .../src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php | 2 +- setup/src/Magento/Setup/Module/Di/Definition/Collection.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php index f6138d8be303..083bc6b76596 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php @@ -50,7 +50,7 @@ public function getList($path) { $classes = []; foreach ($this->classesScanner->getList($path) as $className) { - $classes[$className] = $this->classReaderDecorator->getConstructor($className); + $classes[$className] = (array) $this->classReaderDecorator->getConstructor($className); } return $classes; diff --git a/setup/src/Magento/Setup/Module/Di/Definition/Collection.php b/setup/src/Magento/Setup/Module/Di/Definition/Collection.php index 559cafbb4491..c00b540c4196 100644 --- a/setup/src/Magento/Setup/Module/Di/Definition/Collection.php +++ b/setup/src/Magento/Setup/Module/Di/Definition/Collection.php @@ -91,6 +91,6 @@ public function getInstancesNamesList() */ public function hasInstance($instanceName) { - return isset($this->definitions[$instanceName]); + return array_key_exists($instanceName, $this->definitions); } } From 1188e033410259b7172cd5e02b8c12cdda314f0c Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 22:58:19 +0100 Subject: [PATCH 06/29] Fix type error --- .../Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php b/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php index 7a6d34fbcbe0..b1678725c911 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php @@ -193,6 +193,10 @@ private function getConfiguredArguments($instanceType) $configuredArguments = $this->diContainerConfig->getArguments($instanceType); return array_map( function ($type) { + if (!is_array($type)) { + return; + } + if (isset($type['instance'])) { $type['instance'] = ltrim($type['instance'], '\\'); } From d3a8b3f71dd1871c03272003be63a92aa2da8e0b Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 22:58:29 +0100 Subject: [PATCH 07/29] Allow preferences for classes in the 'setup' area --- setup/src/Magento/Setup/Console/Command/DiCompileCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 4c50a3de4fb3..91d5b506dca6 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -399,6 +399,7 @@ private function getOperationsConfiguration( OperationFactory::AREA_CONFIG_GENERATOR => [ $compiledPathsList['application'], $compiledPathsList['library'], + $compiledPathsList['setup'], $compiledPathsList['generated_helpers'], ], OperationFactory::INTERCEPTION_CACHE => [ From 84c45e4681c069db767ab3f5d6c1ac86f919ab49 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 7 Jun 2021 23:20:00 +0100 Subject: [PATCH 08/29] Make noise on DI compile failure --- .../Setup/Module/Di/Compiler/Config/Reader.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php index 9c17939f3e07..a8e9a5357179 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php @@ -118,11 +118,16 @@ public function generateCachePerScope( } if (!$definitionsCollection->hasInstance($preference)) { - // Removing this preference, because its class has been excluded intentionally. // See 'excludePatterns' in Magento\Setup\Module\Di\Code\Reader\ClassesScanner, // populated via Magento\Setup\Console\Command\DiCompileCommand - // TODO: add logging here so developers get useful messaging. - continue; + throw new LocalizedException(new Phrase( + 'Preference declared for "%instanceName" as "%preference", but the latter' + . ' has not been included in dependency injection compilation.', + [ + 'instanceName' => $instanceName, + 'preference' => $preference, + ] + )); } $config['preferences'][$instanceName] = $preference; From f24f57459c9be9892d74be0e744c62c92058802f Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 9 Jun 2021 15:21:13 +0100 Subject: [PATCH 09/29] Fix argumentresolver unit test failure --- .../Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php b/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php index b1678725c911..dbfd7ecd75d9 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php @@ -193,11 +193,11 @@ private function getConfiguredArguments($instanceType) $configuredArguments = $this->diContainerConfig->getArguments($instanceType); return array_map( function ($type) { - if (!is_array($type)) { + if (is_object($type)) { return; } - if (isset($type['instance'])) { + if (is_array($type) && isset($type['instance'])) { $type['instance'] = ltrim($type['instance'], '\\'); } From 38d7e5d29c5204524288252cc2a511e85946140e Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Tue, 15 Jun 2021 21:01:55 +0100 Subject: [PATCH 10/29] Fix test for DI config reader --- .../Test/Unit/Module/Di/Compiler/Config/ReaderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php index 0e5a57cfcfa5..fae3182203b4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php @@ -174,8 +174,8 @@ private function getVirtualTypes() private function getPreferences() { return [ - 'Interface1' => 'ConcreteType1', - 'ThirdPartyInterface' => 'ConcreteType2' + 'Interface1' => 'DateTime', + 'ThirdPartyInterface' => 'DateTimeZone', ]; } @@ -187,8 +187,8 @@ private function getPreferencesMap() return [ ['ConcreteType1', 'ConcreteType1'], ['ConcreteType2', 'ConcreteType2'], - ['Interface1', 'ConcreteType1'], - ['ThirdPartyInterface', 'ConcreteType2'] + ['Interface1', 'DateTime'], + ['ThirdPartyInterface', 'DateTimeZone'], ]; } From 69e376159eabf87e449e62fc4f985a5034606769 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 22 Feb 2024 16:48:55 +0000 Subject: [PATCH 11/29] Adhere to coding standard --- .../Setup/Console/Command/DiCompileCommand.php | 17 +++++++++++++---- .../Module/Di/Code/Reader/Decorator/Area.php | 7 ++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 91d5b506dca6..69e202a9c249 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -1,8 +1,10 @@ writeln($line); } + // we must have an exit code higher than zero to indicate something was wrong return Cli::RETURN_FAILURE; } @@ -224,6 +225,7 @@ function (OperationInterface $operation) use ($progressBar) { // we must have an exit code higher than zero to indicate something was wrong return Cli::RETURN_FAILURE; } + return Cli::RETURN_SUCCESS; } @@ -231,6 +233,7 @@ function (OperationInterface $operation) use ($progressBar) { * Build list of module path regexps which should be excluded from compilation * * @param string[] $modulePaths + * * @return string[] */ private function getExcludedModulePaths(array $modulePaths) @@ -251,6 +254,7 @@ private function getExcludedModulePaths(array $modulePaths) $vendorPathsRegExps[] = $vendorDir . '/(?:' . join('|', $vendorModules) . ')'; } + $basePathsRegExps[] = preg_quote($basePath, '#') . '/(?:' . join('|', $vendorPathsRegExps) . ')'; } @@ -266,6 +270,7 @@ private function getExcludedModulePaths(array $modulePaths) * Build list of library path regexps which should be excluded from compilation * * @param string[] $libraryPaths + * * @return string[] */ private function getExcludedLibraryPaths(array $libraryPaths) @@ -288,6 +293,7 @@ function ($libraryPath) { * Get excluded setup application paths * * @param string $setupPath + * * @return string[] */ private function getExcludedSetupPaths($setupPath) @@ -301,6 +307,7 @@ private function getExcludedSetupPaths($setupPath) * Delete directories by their code from "var" directory * * @param array $directoryCodeList + * * @return void */ private function cleanupFilesystem($directoryCodeList) @@ -314,6 +321,7 @@ private function cleanupFilesystem($directoryCodeList) * Configure Object Manager * * @param OutputInterface $output + * * @return void */ private function configureObjectManager(OutputInterface $output) @@ -365,6 +373,7 @@ private function configureObjectManager(OutputInterface $output) * Returns operations configuration * * @param array $compiledPathsList + * * @return array */ private function getOperationsConfiguration( diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php index 083bc6b76596..03b39e02e7b5 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php @@ -1,19 +1,16 @@ Date: Sun, 28 Jul 2024 15:29:34 +0300 Subject: [PATCH 12/29] add sourceMap generation for less files in developer mode --- .../Framework/Css/PreProcessor/Adapter/Less/Processor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php index 8f40ab044c02..184a895adbd2 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -69,7 +69,8 @@ public function processContent(File $asset) $parser = new \Less_Parser( [ 'relativeUrls' => false, - 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER + 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER, + 'sourceMap' => $this->appState->getMode() === State::MODE_DEVELOPER ] ); From af193c60fcf3eed9320ccc8eb163fa5d0cdd9001 Mon Sep 17 00:00:00 2001 From: Antonio Pedicini Date: Tue, 30 Jul 2024 21:23:24 +0100 Subject: [PATCH 13/29] issue 37750: whitelisting *.google-analytics.com *.analytics.google.com --- .../Magento/GoogleGtag/etc/csp_whitelist.xml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml b/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml index 150d51eaec5b..9a8e90b852a8 100644 --- a/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml +++ b/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml @@ -12,16 +12,16 @@ - www.google-analytics.com - analytics.google.com + *.google-analytics.com + *.analytics.google.com www.googletagmanager.com - - www.google-analytics.com - analytics.google.com + + *.google-analytics.com + *.analytics.google.com www.googletagmanager.com @@ -32,12 +32,12 @@ - - - + + + - www.google-analytics.com - analytics.google.com + *.google-analytics.com + *.analytics.google.com www.googletagmanager.com From a7f95885e8ac6b2a94ffad4c6da22da33d7f734f Mon Sep 17 00:00:00 2001 From: IOWEB TECHNOLOGIES Date: Wed, 4 Sep 2024 13:35:41 +0300 Subject: [PATCH 14/29] remove duplicate getMode call --- .../Framework/Css/PreProcessor/Adapter/Less/Processor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php index 184a895adbd2..181edd47c279 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -66,11 +66,12 @@ public function processContent(File $asset) { $path = $asset->getPath(); try { + $mode = $this->appState->getMode(); $parser = new \Less_Parser( [ 'relativeUrls' => false, - 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER, - 'sourceMap' => $this->appState->getMode() === State::MODE_DEVELOPER + 'compress' => $mode !== State::MODE_DEVELOPER, + 'sourceMap' => $mode === State::MODE_DEVELOPER ] ); From 52da6505fb34b23a47fe9db5e930a15d26557711 Mon Sep 17 00:00:00 2001 From: IOWEB TECHNOLOGIES Date: Wed, 4 Sep 2024 16:31:50 +0300 Subject: [PATCH 15/29] add class description --- .../Framework/Css/PreProcessor/Adapter/Less/Processor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php index 181edd47c279..14e54e774348 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -16,6 +16,8 @@ /** * Class Processor + * + * Process LESS files into CSS */ class Processor implements ContentProcessorInterface { From 613cb239c6cd55d9535ca5259a509c7e4e05ba5c Mon Sep 17 00:00:00 2001 From: IOWEB TECHNOLOGIES Date: Fri, 6 Sep 2024 11:58:22 +0300 Subject: [PATCH 16/29] fix source maps detection in browser --- .../Css/PreProcessor/Adapter/Less/Processor.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php index 14e54e774348..82925a01f532 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\Css\PreProcessor\Adapter\Less; +use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\State; use Magento\Framework\Css\PreProcessor\File\Temporary; use Magento\Framework\Phrase; @@ -40,6 +41,7 @@ class Processor implements ContentProcessorInterface * @var Temporary */ private $temporaryFile; + private DirectoryList $directoryList; /** * Constructor @@ -53,12 +55,14 @@ public function __construct( LoggerInterface $logger, State $appState, Source $assetSource, - Temporary $temporaryFile + Temporary $temporaryFile, + DirectoryList $directoryList ) { $this->logger = $logger; $this->appState = $appState; $this->assetSource = $assetSource; $this->temporaryFile = $temporaryFile; + $this->directoryList = $directoryList; } /** @@ -73,7 +77,9 @@ public function processContent(File $asset) [ 'relativeUrls' => false, 'compress' => $mode !== State::MODE_DEVELOPER, - 'sourceMap' => $mode === State::MODE_DEVELOPER + 'sourceMap' => $mode === State::MODE_DEVELOPER, + 'sourceMapRootpath' => '/', + 'sourceMapBasepath' => $this->directoryList->getPath(DirectoryList::TEMPLATE_MINIFICATION_DIR) . '/pub/' ] ); From 187201cd5d4966f87aaef3769befa5e45f469c14 Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Mon, 23 Sep 2024 20:31:27 +0200 Subject: [PATCH 17/29] Removes some code for PHP versions we no longer support. --- .../Webapi/Rest/Request/Deserializer/Xml.php | 10 +--- .../Magento/Framework/Xml/Security.php | 10 ---- .../Magento/Setup/Model/PhpReadinessCheck.php | 47 --------------- .../Test/Unit/Model/PhpReadinessCheckTest.php | 60 ------------------- 4 files changed, 1 insertion(+), 126 deletions(-) diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php index bf72d8b04ff1..facc8a741168 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php @@ -72,19 +72,11 @@ public function deserialize($xmlRequestBody) sprintf('"%s" data type is invalid. String is expected.', gettype($xmlRequestBody)) ); } - /** Disable external entity loading to prevent possible vulnerability */ - if (version_compare(PHP_VERSION, '8.0') < 0) { - // this function no longer has an effect in PHP 8.0, but it's required in earlier versions - $previousLoaderState = libxml_disable_entity_loader(true); - } + set_error_handler([$this, 'handleErrors']); $xmlParser = $this->parserFactory->create(); $xmlParser->loadXML($xmlRequestBody); - restore_error_handler(); - if (isset($previousLoaderState)) { - libxml_disable_entity_loader($previousLoaderState); - } /** Process errors during XML parsing. */ if ($this->_errorMessage !== null) { diff --git a/lib/internal/Magento/Framework/Xml/Security.php b/lib/internal/Magento/Framework/Xml/Security.php index 8d125736c6d3..67419a484f18 100644 --- a/lib/internal/Magento/Framework/Xml/Security.php +++ b/lib/internal/Magento/Framework/Xml/Security.php @@ -58,11 +58,6 @@ public function scan($xmlContent) $document = new DOMDocument(); - if (version_compare(PHP_VERSION, '8.0') < 0) { - // this function no longer has an effect in PHP 8.0, but it's required in earlier versions - // phpcs:ignore - $loadEntities = libxml_disable_entity_loader(true); - } $useInternalXmlErrors = libxml_use_internal_errors(true); /** @@ -92,11 +87,6 @@ function ($errno, $errstr) { } } restore_error_handler(); - // Entity load to previous setting - if (isset($loadEntities)) { - // phpcs:ignore - libxml_disable_entity_loader($loadEntities); - } libxml_use_internal_errors($useInternalXmlErrors); if (!$result) { diff --git a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php index 86a377c8edc6..b2630415b38c 100644 --- a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php +++ b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php @@ -102,7 +102,6 @@ public function checkPhpSettings() $settings = array_merge( $this->checkXDebugNestedLevel(), - $this->checkPopulateRawPostSetting(), $this->checkFunctionsExistence() ); @@ -270,52 +269,6 @@ private function checkXDebugNestedLevel() return $data; } - /** - * Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set to -1 - * - * Beginning PHP 7.0, support for 'always_populate_raw_post_data' is going to removed. - * And beginning PHP 5.6, a deprecated message is displayed if 'always_populate_raw_post_data' - * is set to a value other than -1. - * - * @return array - */ - private function checkPopulateRawPostSetting() - { - // HHVM and PHP 7does not support 'always_populate_raw_post_data' to be set to -1 - if (version_compare(PHP_VERSION, '7.0.0-beta') >= 0 || defined('HHVM_VERSION')) { - return []; - } - - $data = []; - $error = false; - $iniSetting = (int)ini_get('always_populate_raw_post_data'); - - $checkVersionConstraint = $this->versionParser->parseConstraints('~5.6.0'); - $normalizedPhpVersion = $this->getNormalizedCurrentPhpVersion(PHP_VERSION); - $currentVersion = $this->versionParser->parseConstraints($normalizedPhpVersion); - if ($checkVersionConstraint->matches($currentVersion) && $iniSetting !== -1) { - $error = true; - } - - $message = sprintf( - 'Your PHP Version is %s, but always_populate_raw_post_data = %d. - $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. - This will stop the installer from running. - Please open your php.ini file and set always_populate_raw_post_data to -1. - If you need more help please call your hosting provider.', - PHP_VERSION, - (int)ini_get('always_populate_raw_post_data') - ); - - $data['always_populate_raw_post_data'] = [ - 'message' => $message, - 'helpUrl' => 'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data', - 'error' => $error - ]; - - return $data; - } - /** * Check whether all special functions exists * diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php index 919b16c20140..2ac4ba5572b4 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php @@ -245,14 +245,6 @@ public function testCheckPhpSettings(): void 50 ); - $rawPostMessage = sprintf( - 'Your PHP Version is %s, but always_populate_raw_post_data = -1. - $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. - This will stop the installer from running. - Please open your php.ini file and set always_populate_raw_post_data to -1. - If you need more help please call your hosting provider.', - PHP_VERSION - ); $expected = [ 'responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, 'data' => [ @@ -267,14 +259,6 @@ public function testCheckPhpSettings(): void ] ] ]; - if (!$this->isPhp7OrHhvm()) { - $this->setUpNoPrettyVersionParser(); - $expected['data']['always_populate_raw_post_data'] = [ - 'message' => $rawPostMessage, - 'helpUrl' => 'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data', - 'error' => false - ]; - } $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpSettings()); } @@ -293,14 +277,6 @@ public function testCheckPhpSettingsFailed(): void 200 ); - $rawPostMessage = sprintf( - 'Your PHP Version is %s, but always_populate_raw_post_data = -1. - $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. - This will stop the installer from running. - Please open your php.ini file and set always_populate_raw_post_data to -1. - If you need more help please call your hosting provider.', - PHP_VERSION - ); $expected = [ 'responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'data' => [ @@ -315,14 +291,6 @@ public function testCheckPhpSettingsFailed(): void ] ] ]; - if (!$this->isPhp7OrHhvm()) { - $this->setUpNoPrettyVersionParser(); - $expected['data']['always_populate_raw_post_data'] = [ - 'message' => $rawPostMessage, - 'helpUrl' => 'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data', - 'error' => false - ]; - } $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpSettings()); } @@ -333,28 +301,10 @@ public function testCheckPhpSettingsNoXDebug(): void { $this->phpInfo->expects($this->once())->method('getCurrent')->willReturn([]); - $rawPostMessage = sprintf( - 'Your PHP Version is %s, but always_populate_raw_post_data = -1. - $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. - This will stop the installer from running. - Please open your php.ini file and set always_populate_raw_post_data to -1. - If you need more help please call your hosting provider.', - PHP_VERSION - ); $expected = [ 'responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, 'data' => [] ]; - if (!$this->isPhp7OrHhvm()) { - $this->setUpNoPrettyVersionParser(); - $expected['data'] = [ - 'always_populate_raw_post_data' => [ - 'message' => $rawPostMessage, - 'helpUrl' => 'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data', - 'error' => false - ] - ]; - } $expected['data']['missed_function_imagecreatefromjpeg'] = [ 'message' => 'You must have installed GD library with --with-jpeg-dir=DIR option.', @@ -453,14 +403,6 @@ public function testCheckPhpExtensionsFailed(): void ]; $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpExtensions()); } - - /** - * @return bool - */ - protected function isPhp7OrHhvm(): bool - { - return version_compare(PHP_VERSION, '7.0.0-beta') >= 0 || defined('HHVM_VERSION'); - } } namespace Magento\Setup\Model; @@ -473,8 +415,6 @@ function ini_get($param) { if ($param === 'xdebug.max_nesting_level') { return 100; - } elseif ($param === 'always_populate_raw_post_data') { - return -1; } elseif ($param === 'memory_limit') { return '512M'; } From 07b50991bf9e922714a4b89c77f5ac6353034252 Mon Sep 17 00:00:00 2001 From: IOWEB TECHNOLOGIES Date: Tue, 1 Oct 2024 09:00:25 +0300 Subject: [PATCH 18/29] add patch to fix tests --- .../PreProcessor/Adapter/Less/Processor.php | 17 +++- .../Adapter/Less/ProcessorTest.php | 90 +++++++++++++++++-- .../Adapter/Less/_file/test-developer.css | 20 +++++ .../Adapter/Less/_file/test-production.css | 15 ++++ .../PreProcessor/Adapter/Less/_file/test.css | 19 ---- 5 files changed, 131 insertions(+), 30 deletions(-) create mode 100644 lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-developer.css create mode 100644 lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-production.css delete mode 100644 lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test.css diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php index 82925a01f532..8b01c6055c8f 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Css\PreProcessor\Adapter\Less; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\ObjectManager; use Magento\Framework\App\State; use Magento\Framework\Css\PreProcessor\File\Temporary; use Magento\Framework\Phrase; @@ -41,6 +42,10 @@ class Processor implements ContentProcessorInterface * @var Temporary */ private $temporaryFile; + + /** + * @var DirectoryList + */ private DirectoryList $directoryList; /** @@ -50,19 +55,20 @@ class Processor implements ContentProcessorInterface * @param State $appState * @param Source $assetSource * @param Temporary $temporaryFile + * @param ?DirectoryList $directoryList */ public function __construct( LoggerInterface $logger, State $appState, Source $assetSource, Temporary $temporaryFile, - DirectoryList $directoryList + ?DirectoryList $directoryList = null, ) { $this->logger = $logger; $this->appState = $appState; $this->assetSource = $assetSource; $this->temporaryFile = $temporaryFile; - $this->directoryList = $directoryList; + $this->directoryList = $directoryList ?: ObjectManager::getInstance()->get(DirectoryList::class); } /** @@ -73,13 +79,18 @@ public function processContent(File $asset) $path = $asset->getPath(); try { $mode = $this->appState->getMode(); + $sourceMapBasePath = sprintf( + '%s/pub/', + $this->directoryList->getPath(DirectoryList::TEMPLATE_MINIFICATION_DIR), + ); + $parser = new \Less_Parser( [ 'relativeUrls' => false, 'compress' => $mode !== State::MODE_DEVELOPER, 'sourceMap' => $mode === State::MODE_DEVELOPER, 'sourceMapRootpath' => '/', - 'sourceMapBasepath' => $this->directoryList->getPath(DirectoryList::TEMPLATE_MINIFICATION_DIR) . '/pub/' + 'sourceMapBasepath' => $sourceMapBasePath, ] ); diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php index 4e50808ea021..26ffa78abdd2 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Css\Test\Unit\PreProcessor\Adapter\Less; +use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\State; use Magento\Framework\Css\PreProcessor\Adapter\Less\Processor; use Magento\Framework\Css\PreProcessor\File\Temporary; @@ -23,8 +24,8 @@ class ProcessorTest extends TestCase const ASSET_PATH = 'test-path'; const TMP_PATH_LESS = '_file/test.less'; - - const TMP_PATH_CSS = '_file/test.css'; + const TMP_PATH_CSS_PRODUCTION = '_file/test-production.css'; + const TMP_PATH_CSS_DEVELOPER = '_file/test-developer.css'; const ERROR_MESSAGE = 'Test exception'; @@ -52,6 +53,10 @@ class ProcessorTest extends TestCase * @var Temporary|MockObject */ private $temporaryFileMock; + /** + * @var DirectoryList|MockObject + */ + private $directoryListMock; /** * Set up @@ -69,12 +74,16 @@ protected function setUp(): void $this->temporaryFileMock = $this->getMockBuilder(Temporary::class) ->disableOriginalConstructor() ->getMock(); + $this->directoryListMock = $this->getMockBuilder(DirectoryList::class) + ->disableOriginalConstructor() + ->getMock(); $this->processor = new Processor( $this->loggerMock, $this->appStateMock, $this->assetSourceMock, - $this->temporaryFileMock + $this->temporaryFileMock, + $this->directoryListMock, ); } @@ -89,7 +98,7 @@ public function testProcessContentException() $this->appStateMock->expects(self::once()) ->method('getMode') - ->willReturn(State::MODE_DEVELOPER); + ->willReturn(State::MODE_PRODUCTION); $this->assetSourceMock->expects(self::once()) ->method('getContent') @@ -120,7 +129,7 @@ public function testProcessContentEmpty() $this->appStateMock->expects(self::once()) ->method('getMode') - ->willReturn(State::MODE_DEVELOPER); + ->willReturn(State::MODE_PRODUCTION); $this->assetSourceMock->expects(self::once()) ->method('getContent') @@ -141,7 +150,7 @@ public function testProcessContentEmpty() } /** - * Test for processContent method (not empty content) + * Test for processContent method in production mode (not empty content) */ public function testProcessContentNotEmpty() { @@ -149,7 +158,7 @@ public function testProcessContentNotEmpty() $this->appStateMock->expects(self::once()) ->method('getMode') - ->willReturn(State::MODE_DEVELOPER); + ->willReturn(State::MODE_PRODUCTION); $this->assetSourceMock->expects(self::once()) ->method('getContent') @@ -170,11 +179,46 @@ public function testProcessContentNotEmpty() $clearSymbol = ["\n", "\r", "\t", ' ']; self::assertEquals( - trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS))), + trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS_PRODUCTION))), trim(str_replace($clearSymbol, '', $this->processor->processContent($assetMock))) ); } + /** + * Test for processContent method in developer mode (not empty content) + */ + public function testProcessContentNotEmptyInDeveloperMode() + { + $assetMock = $this->getAssetMock(); + + $this->appStateMock->expects(self::once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->assetSourceMock->expects(self::once()) + ->method('getContent') + ->with($assetMock) + ->willReturn(self::TEST_CONTENT); + + $this->temporaryFileMock->expects(self::once()) + ->method('createFile') + ->with(self::ASSET_PATH, self::TEST_CONTENT) + ->willReturn(__DIR__ . '/' . self::TMP_PATH_LESS); + + $assetMock->expects(self::once()) + ->method('getPath') + ->willReturn(self::ASSET_PATH); + + $this->loggerMock->expects(self::never()) + ->method('critical'); + + $clearSymbol = ["\n", "\r", "\t", ' ']; + self::assertEquals( + trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS_DEVELOPER))), + trim(str_replace($clearSymbol, '', $this->normalizeInlineSourceMap($this->processor->processContent($assetMock)))) + ); + } + /** * @return File|MockObject */ @@ -186,4 +230,34 @@ private function getAssetMock() return $assetMock; } + + /** + * - find json part of sourcemap + * - url decode it + * - replace \/ with / in source filenames + * - remove absolute path in filename, make it a relative path + */ + private function normalizeInlineSourceMap(string $css): string + { + $regexBegin = 'sourceMappingURL=data:application/json,'; + $regexEnd = '*/'; + $regex = '@' . preg_quote($regexBegin, '@') . '([^\*]+)' . preg_quote($regexEnd, '@') . '@'; + + if (preg_match($regex, $css, $matches) === 1) { + $inlineSourceMapJson = $matches[1]; + $inlineSourceMapJson = urldecode($inlineSourceMapJson); + $inlineSourceMapJson = json_decode($inlineSourceMapJson, true, 512, JSON_UNESCAPED_SLASHES); + + $relativeFilenames = []; + foreach ($inlineSourceMapJson['sources'] as $filename) { + $relativeFilenames[] = str_replace(sprintf('%s/', BP), '', $filename); + } + $inlineSourceMapJson['sources'] = $relativeFilenames; + $inlineSourceMapJson = json_encode($inlineSourceMapJson, JSON_UNESCAPED_SLASHES); + + $css = preg_replace($regex, sprintf('%s%s%s', $regexBegin, $inlineSourceMapJson, $regexEnd), $css); + } + + return $css; + } } diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-developer.css b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-developer.css new file mode 100644 index 000000000000..41ebde913043 --- /dev/null +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-developer.css @@ -0,0 +1,20 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +body { + background: #333333; + color: #454545; +} +a { + color: #ff9900; +} +h1, +h2, +h3, +h4, +h5, +h6 { + color: #333333; +} +/*#sourceMappingURL=data:application/json,{"version":3,"sources":["lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test.less"],"names":[],"mappings":";;;;AASA;EACE,mBAAA;EACA,cAAA;;AAEF;EACE,cAAA;;AAEF;AAAI;AAAI;AAAI;AAAI;AAAI;EAClB,cAAA"}*/ diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-production.css b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-production.css new file mode 100644 index 000000000000..f8236f0d9740 --- /dev/null +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test-production.css @@ -0,0 +1,15 @@ +body { + background: #333333; + color: #454545 +} +a { + color: #ff9900 +} +h1, +h2, +h3, +h4, +h5, +h6 { + color: #333333 +} diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test.css b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test.css deleted file mode 100644 index d6eaa03c1030..000000000000 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/_file/test.css +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -body { - background: #333333; - color: #454545; -} -a { - color: #ff9900; -} -h1, -h2, -h3, -h4, -h5, -h6 { - color: #333333; -} From 111d285788f760b6f228f4e8219069352b17ceda Mon Sep 17 00:00:00 2001 From: Dimitri BOUTEILLE Date: Mon, 7 Oct 2024 08:34:06 +0200 Subject: [PATCH 19/29] Update Magento\Directory\Model\AllowedCountries::getAllowedCountries() PHPDoc --- app/code/Magento/Directory/Model/AllowedCountries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Directory/Model/AllowedCountries.php b/app/code/Magento/Directory/Model/AllowedCountries.php index 69326439edc0..b6690a1991bd 100644 --- a/app/code/Magento/Directory/Model/AllowedCountries.php +++ b/app/code/Magento/Directory/Model/AllowedCountries.php @@ -47,7 +47,7 @@ public function __construct( * Retrieve all allowed countries for scope or scopes * * @param string $scope - * @param string|null $scopeCode + * @param string|null|array $scopeCode * @return array * @since 100.1.2 */ From 08e05b3bf25a0972b6827ee01ae8db0cc9989b1f Mon Sep 17 00:00:00 2001 From: IOWEB TECHNOLOGIES Date: Thu, 10 Oct 2024 10:37:57 +0300 Subject: [PATCH 20/29] apply latest patch to fix coding standards errors --- .../Adapter/Less/ProcessorTest.php | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php index 26ffa78abdd2..0afa14ea86a0 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php @@ -19,15 +19,15 @@ class ProcessorTest extends TestCase { - const TEST_CONTENT = 'test-content'; + private const TEST_CONTENT = 'test-content'; - const ASSET_PATH = 'test-path'; + private const ASSET_PATH = 'test-path'; - const TMP_PATH_LESS = '_file/test.less'; - const TMP_PATH_CSS_PRODUCTION = '_file/test-production.css'; - const TMP_PATH_CSS_DEVELOPER = '_file/test-developer.css'; + private const TMP_PATH_LESS = '_file/test.less'; + private const TMP_PATH_CSS_PRODUCTION = '_file/test-production.css'; + private const TMP_PATH_CSS_DEVELOPER = '_file/test-developer.css'; - const ERROR_MESSAGE = 'Test exception'; + private const ERROR_MESSAGE = 'Test exception'; /** * @var Processor @@ -179,8 +179,16 @@ public function testProcessContentNotEmpty() $clearSymbol = ["\n", "\r", "\t", ' ']; self::assertEquals( - trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS_PRODUCTION))), - trim(str_replace($clearSymbol, '', $this->processor->processContent($assetMock))) + trim(str_replace( + $clearSymbol, + '', + file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS_PRODUCTION) + )), + trim(str_replace( + $clearSymbol, + '', + $this->processor->processContent($assetMock) + )) ); } @@ -214,8 +222,16 @@ public function testProcessContentNotEmptyInDeveloperMode() $clearSymbol = ["\n", "\r", "\t", ' ']; self::assertEquals( - trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS_DEVELOPER))), - trim(str_replace($clearSymbol, '', $this->normalizeInlineSourceMap($this->processor->processContent($assetMock)))) + trim(str_replace( + $clearSymbol, + '', + file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS_DEVELOPER) + )), + trim(str_replace( + $clearSymbol, + '', + $this->normalizeInlineSourceMap($this->processor->processContent($assetMock)) + )) ); } From d2ad73dad182ae2cdd417d7897c64e5699bcbe0a Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Mon, 21 Oct 2024 14:15:50 +0530 Subject: [PATCH 21/29] 39241: Fix PHPCS warning --- app/code/Magento/Directory/Model/AllowedCountries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Directory/Model/AllowedCountries.php b/app/code/Magento/Directory/Model/AllowedCountries.php index b6690a1991bd..ea162988b8d3 100644 --- a/app/code/Magento/Directory/Model/AllowedCountries.php +++ b/app/code/Magento/Directory/Model/AllowedCountries.php @@ -18,7 +18,7 @@ */ class AllowedCountries { - const ALLOWED_COUNTRIES_PATH = 'general/country/allow'; + public const ALLOWED_COUNTRIES_PATH = 'general/country/allow'; /** * @var ScopeConfigInterface From 6b743fe6c73c2526f6da0da80933faabc65e1d21 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Wed, 23 Oct 2024 12:43:14 +0530 Subject: [PATCH 22/29] 39241: Fix static failure related to copyright tag --- app/code/Magento/Directory/Model/AllowedCountries.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Directory/Model/AllowedCountries.php b/app/code/Magento/Directory/Model/AllowedCountries.php index ea162988b8d3..5cb6762048cb 100644 --- a/app/code/Magento/Directory/Model/AllowedCountries.php +++ b/app/code/Magento/Directory/Model/AllowedCountries.php @@ -1,7 +1,7 @@ Date: Wed, 23 Oct 2024 13:08:02 +0530 Subject: [PATCH 23/29] 39241: update copyright year --- app/code/Magento/Directory/Model/AllowedCountries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Directory/Model/AllowedCountries.php b/app/code/Magento/Directory/Model/AllowedCountries.php index 5cb6762048cb..dfac85e3f97b 100644 --- a/app/code/Magento/Directory/Model/AllowedCountries.php +++ b/app/code/Magento/Directory/Model/AllowedCountries.php @@ -1,6 +1,6 @@ Date: Mon, 28 Oct 2024 11:31:23 +0530 Subject: [PATCH 24/29] Fixed static test failures --- .../Framework/Webapi/Rest/Request/Deserializer/Xml.php | 4 ++-- lib/internal/Magento/Framework/Xml/Security.php | 4 ++-- setup/src/Magento/Setup/Model/PhpReadinessCheck.php | 4 ++-- .../Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php index facc8a741168..53f36cf08b3a 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Xml.php @@ -1,7 +1,7 @@ Date: Thu, 31 Oct 2024 18:27:02 +0000 Subject: [PATCH 25/29] issue 37750: only img-src and connection-src directives changed --- app/code/Magento/GoogleGtag/etc/csp_whitelist.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml b/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml index 9a8e90b852a8..660a69785887 100644 --- a/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml +++ b/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml @@ -12,8 +12,8 @@ - *.google-analytics.com - *.analytics.google.com + www.google-analytics.com + analytics.google.com www.googletagmanager.com From a9ac117cf63157d59054eaf0b6328213e03f6f11 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Tue, 5 Nov 2024 19:09:30 +0530 Subject: [PATCH 26/29] 38991: fix static test failure --- app/code/Magento/GoogleGtag/etc/csp_whitelist.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml b/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml index 660a69785887..2667959464aa 100644 --- a/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml +++ b/app/code/Magento/GoogleGtag/etc/csp_whitelist.xml @@ -1,8 +1,8 @@ Date: Fri, 8 Nov 2024 08:20:49 +0200 Subject: [PATCH 27/29] fix copyright --- .../Framework/Css/PreProcessor/Adapter/Less/Processor.php | 4 ++-- .../Css/Test/Unit/PreProcessor/Adapter/Less/ProcessorTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php index 8b01c6055c8f..52fac681eca0 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -1,7 +1,7 @@ Date: Fri, 8 Nov 2024 14:22:23 +0530 Subject: [PATCH 28/29] 33161: Fix static failure related to copyright tag --- app/code/Magento/RemoteStorage/etc/di.xml | 4 ++-- app/etc/di.xml | 4 ++-- .../Magento/Test/Legacy/_files/obsolete_classes.php | 6 +++--- .../src/Magento/Setup/Console/Command/DiCompileCommand.php | 5 ++--- .../Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php | 5 ++--- .../Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php | 5 ++--- .../src/Magento/Setup/Module/Di/Compiler/Config/Reader.php | 4 ++-- setup/src/Magento/Setup/Module/Di/Definition/Collection.php | 4 ++-- .../Test/Unit/Module/Di/Compiler/Config/ReaderTest.php | 4 ++-- 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/RemoteStorage/etc/di.xml b/app/code/Magento/RemoteStorage/etc/di.xml index 69c166a3c320..802bac5df2dc 100644 --- a/app/code/Magento/RemoteStorage/etc/di.xml +++ b/app/code/Magento/RemoteStorage/etc/di.xml @@ -1,8 +1,8 @@ diff --git a/app/etc/di.xml b/app/etc/di.xml index a2e1deca2b62..385518fd79a2 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -1,8 +1,8 @@ diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index b9b59400955b..4ad7b3797ac5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -1,13 +1,13 @@ [, ]) * * @codingStandardsIgnoreFile - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. */ return [ ['Mage_Admin_Helper_Data', 'Magento\Backend\Helper\Data'], diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 69e202a9c249..eff78236285a 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -1,8 +1,7 @@ Date: Fri, 8 Nov 2024 14:25:04 +0530 Subject: [PATCH 29/29] 33161: Fix static failure related to copyright tag --- app/code/Magento/Catalog/etc/di.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 13cc69c370a4..2ba1898629e7 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1,8 +1,8 @@