File tree Expand file tree Collapse file tree 2 files changed +57
-4
lines changed
dev/tests/integration/framework/Magento/TestFramework Expand file tree Collapse file tree 2 files changed +57
-4
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+
7+ declare (strict_types=1 );
8+
9+ namespace Magento \TestFramework \Serialize ;
10+
11+ use Magento \Framework \Serialize \SerializerInterface ;
12+
13+ /**
14+ * Insecure SerializerInterface implementation for test use only.
15+ */
16+ class Serializer implements SerializerInterface
17+ {
18+ /**
19+ * @inheritDoc
20+ */
21+ public function serialize ($ data )
22+ {
23+ if (is_resource ($ data )) {
24+ throw new \InvalidArgumentException ('Unable to serialize value. ' );
25+ }
26+
27+ // phpcs:ignore Magento2.Security.InsecureFunction
28+ return serialize ($ data );
29+ }
30+
31+ /**
32+ * @inheritDoc
33+ */
34+ public function unserialize ($ string )
35+ {
36+ if (false === $ string || null === $ string || '' === $ string ) {
37+ throw new \InvalidArgumentException ('Unable to unserialize value. ' );
38+ }
39+ set_error_handler (
40+ function () {
41+ restore_error_handler ();
42+ throw new \InvalidArgumentException ('Unable to unserialize value, string is corrupted. ' );
43+ },
44+ E_NOTICE
45+ );
46+ // phpcs:ignore Magento2.Security.InsecureFunction
47+ $ result = unserialize ($ string );
48+ restore_error_handler ();
49+
50+ return $ result ;
51+ }
52+ }
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ public static function backupStaticVariables()
170170
171171 $ objectManager = Bootstrap::getInstance ()->getObjectManager ();
172172 $ cache = $ objectManager ->get (CacheInterface::class);
173- $ serializer = $ objectManager ->get (SerializerInterface ::class);
173+ $ serializer = $ objectManager ->get (\ Magento \ TestFramework \ Serialize \Serializer ::class);
174174 $ cachedProperties = $ cache ->load (self ::CACHE_NAME );
175175
176176 if ($ cachedProperties ) {
@@ -187,9 +187,10 @@ public static function backupStaticVariables()
187187 | Files::INCLUDE_TESTS
188188 ),
189189 function ($ classFile ) {
190- return StaticProperties::_isClassInCleanableFolders ($ classFile )
191- // phpcs:ignore Magento2.Functions.DiscouragedFunction
192- && strpos (file_get_contents ($ classFile ), ' static ' ) > 0 ;
190+ return strpos ($ classFile , 'TestFramework ' ) === -1
191+ && StaticProperties::_isClassInCleanableFolders ($ classFile )
192+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
193+ && strpos (file_get_contents ($ classFile ), ' static ' ) > 0 ;
193194 }
194195 );
195196 $ namespacePattern = '/namespace [a-zA-Z0-9 \\\\]+;/ ' ;
You can’t perform that action at this time.
0 commit comments