Skip to content

Commit 98a84f7

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-96975: Remove __sleep and __wakeup from code
1 parent b77a7d4 commit 98a84f7

File tree

29 files changed

+40
-164
lines changed

29 files changed

+40
-164
lines changed

app/code/Magento/Authorization/Model/Role.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ public function __construct( //phpcs:ignore Generic.CodeAnalysis.UselessOverridi
5858
*/
5959
public function __sleep()
6060
{
61-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
62-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
63-
6461
$properties = parent::__sleep();
6562
return array_diff($properties, ['_resource', '_resourceCollection']);
6663
}
@@ -73,9 +70,6 @@ public function __sleep()
7370
*/
7471
public function __wakeup()
7572
{
76-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
77-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
78-
7973
parent::__wakeup();
8074
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
8175
$this->_resource = $objectManager->get(\Magento\Authorization\Model\ResourceModel\Role::class);

app/code/Magento/Backend/Model/Auth/Session.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ public function getUser()
325325
$user = $this->userFactory->create();
326326
$this->userHydrator->hydrate($user, $userData);
327327
$this->user = $user;
328+
} elseif ($user = parent::getUser()) {
329+
$this->setUser($user);
328330
}
329331
}
330332

@@ -355,7 +357,7 @@ public function setUser($user)
355357
*/
356358
public function hasUser()
357359
{
358-
return $this->user || $this->hasUserData();
360+
return (bool)$this->getUser();
359361
}
360362

361363
/**
@@ -366,6 +368,7 @@ public function hasUser()
366368
public function unsUser()
367369
{
368370
$this->user = null;
371+
parent::unsUser();
369372
return $this->unsUserData();
370373
}
371374

@@ -383,6 +386,8 @@ public function getAcl()
383386
$acl = $this->aclFactory->create();
384387
$this->aclHydrator->hydrate($acl, $aclData);
385388
$this->acl = $acl;
389+
} elseif ($acl = parent::getAcl()) {
390+
$this->setAcl($acl);
386391
}
387392
}
388393

@@ -413,7 +418,7 @@ public function setAcl($acl)
413418
*/
414419
public function hasAcl()
415420
{
416-
return $this->acl || $this->hasUserAclData();
421+
return (bool)$this->getAcl();
417422
}
418423

419424
/**
@@ -424,6 +429,7 @@ public function hasAcl()
424429
public function unsAcl()
425430
{
426431
$this->acl = null;
432+
parent::unsAcl();
427433
return $this->unsUserAclData();
428434
}
429435

app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,6 @@ public function afterDelete()
852852
*/
853853
public function __sleep()
854854
{
855-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
856-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
857-
858855
$this->unsetData('entity_type');
859856
return array_diff(
860857
parent::__sleep(),
@@ -871,9 +868,6 @@ public function __sleep()
871868
*/
872869
public function __wakeup()
873870
{
874-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
875-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
876-
877871
parent::__wakeup();
878872
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
879873
$this->_indexerEavProcessor = $objectManager->get(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class);

app/code/Magento/Config/Model/Config/Backend/Encrypted.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public function __construct(
5454
*/
5555
public function __sleep()
5656
{
57-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
58-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
59-
6057
$properties = parent::__sleep();
6158
return array_diff($properties, ['_encryptor']);
6259
}
@@ -71,9 +68,6 @@ public function __sleep()
7168
*/
7269
public function __wakeup()
7370
{
74-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
75-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
76-
7771
parent::__wakeup();
7872
$this->_encryptor = \Magento\Framework\App\ObjectManager::getInstance()->get(
7973
\Magento\Framework\Encryption\EncryptorInterface::class

app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ public function setProductId($value)
270270
*/
271271
public function __sleep()
272272
{
273-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
274-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
275-
276273
return array_diff(
277274
parent::__sleep(),
278275
['metadataPool']
@@ -287,9 +284,6 @@ public function __sleep()
287284
*/
288285
public function __wakeup()
289286
{
290-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
291-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
292-
293287
parent::__wakeup();
294288
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
295289
$this->metadataPool = $objectManager->get(MetadataPool::class);

app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute/Collection.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,6 @@ protected function getIncludedOptions(array $usedProducts, AbstractAttribute $pr
363363
*/
364364
public function __sleep()
365365
{
366-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
367-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
368-
369366
return array_diff(
370367
parent::__sleep(),
371368
[
@@ -388,9 +385,6 @@ public function __sleep()
388385
*/
389386
public function __wakeup()
390387
{
391-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
392-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
393-
394388
parent::__wakeup();
395389
$objectManager = ObjectManager::getInstance();
396390
$this->_storeManager = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);

app/code/Magento/Customer/Model/Attribute.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ public function canBeFilterableInGrid()
208208
*/
209209
public function __sleep()
210210
{
211-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
212-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
213-
214211
$this->unsetData('entity_type');
215212
return array_diff(
216213
parent::__sleep(),
@@ -226,9 +223,6 @@ public function __sleep()
226223
*/
227224
public function __wakeup()
228225
{
229-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
230-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
231-
232226
parent::__wakeup();
233227
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
234228
$this->indexerRegistry = $objectManager->get(\Magento\Framework\Indexer\IndexerRegistry::class);

app/code/Magento/Eav/Model/Entity/Attribute.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,6 @@ public function getIdentities()
495495
*/
496496
public function __sleep()
497497
{
498-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
499-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
500-
501498
$this->unsetData('attribute_set_info');
502499
return array_diff(
503500
parent::__sleep(),
@@ -514,9 +511,6 @@ public function __sleep()
514511
*/
515512
public function __wakeup()
516513
{
517-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
518-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
519-
520514
parent::__wakeup();
521515
$objectManager = ObjectManager::getInstance();
522516
$this->_localeDate = $objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);

app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,9 +1411,6 @@ public function setExtensionAttributes(\Magento\Eav\Api\Data\AttributeExtensionI
14111411
*/
14121412
public function __sleep()
14131413
{
1414-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1415-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
1416-
14171414
return array_diff(
14181415
parent::__sleep(),
14191416
[
@@ -1442,9 +1439,6 @@ public function __sleep()
14421439
*/
14431440
public function __wakeup()
14441441
{
1445-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
1446-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
1447-
14481442
parent::__wakeup();
14491443
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
14501444
$this->_eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,6 @@ public function getValidAttributeIds($attributeIds)
731731
*/
732732
public function __sleep()
733733
{
734-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
735-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
736-
737734
$properties = parent::__sleep();
738735
$properties = array_diff($properties, ['_storeManager']);
739736
return $properties;
@@ -750,9 +747,6 @@ public function __sleep()
750747
*/
751748
public function __wakeup()
752749
{
753-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
754-
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
755-
756750
parent::__wakeup();
757751
$this->_storeManager = \Magento\Framework\App\ObjectManager::getInstance()
758752
->get(\Magento\Store\Model\StoreManagerInterface::class);

0 commit comments

Comments
 (0)