Skip to content

Commit 77f7559

Browse files
committed
Proper generate classes with reset state method
1 parent f778962 commit 77f7559

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

app/code/Magento/Store/Model/Store.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ protected function _construct()
468468
protected function _getSession()
469469
{
470470
if (!$this->_session->isSessionExists()) {
471-
$this->_session->setName('store_' . $this->getCode());
472471
$this->_session->start();
473472
}
474473
return $this->_session;

dev/tests/integration/framework/Magento/TestFramework/Event/Transaction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function ($errNo, $errStr, $errFile, $errLine) use ($test) {
110110
$this->_eventManager->fireEvent('startTransaction', [$test]);
111111
restore_error_handler();
112112
} catch (\Exception $e) {
113+
$this->_isTransactionActive = false;
113114
$test->getTestResultObject()->addFailure(
114115
$test,
115116
new \PHPUnit\Framework\AssertionFailedError((string)$e),
@@ -125,8 +126,8 @@ function ($errNo, $errStr, $errFile, $errLine) use ($test) {
125126
protected function _rollbackTransaction()
126127
{
127128
if ($this->_isTransactionActive) {
128-
$this->_getConnection()->rollbackTransparentTransaction();
129129
$this->_isTransactionActive = false;
130+
$this->_getConnection()->rollbackTransparentTransaction();
130131
$this->_eventManager->fireEvent('rollbackTransaction');
131132
$this->_getConnection()->closeConnection();
132133
}

lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function _getClassMethods()
9292
protected function isInterceptedMethod(\ReflectionMethod $method)
9393
{
9494
return !($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) &&
95-
!in_array($method->getName(), ['__sleep', '__wakeup', '__clone']);
95+
!in_array($method->getName(), ['__sleep', '__wakeup', '__clone', '_resetState']);
9696
}
9797

9898
/**

lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,21 @@ protected function _getClassMethods()
135135
)
136136
&& !in_array(
137137
$method->getName(),
138-
['__sleep', '__wakeup', '__clone', '__debugInfo']
138+
['__sleep', '__wakeup', '__clone', '__debugInfo', '_resetState']
139139
)
140140
) {
141141
$methods[] = $this->_getMethodInfo($method);
142142
}
143+
if ($method->getName() === '_resetState') {
144+
$methods[] = [
145+
'name' => '_resetState',
146+
'returnType' => 'void',
147+
'body' => "if (\$this->_subject) {\n" .
148+
" \$this->_subject->_resetState(); \n" .
149+
"}\n",
150+
'docblock' => ['shortDescription' => 'Reset state of proxied instance'],
151+
];
152+
}
143153
}
144154

145155
return $methods;

lib/internal/Magento/Framework/Session/SessionManager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,13 @@ private function initIniOptions()
638638
*/
639639
public function _resetState(): void
640640
{
641-
session_write_close();
641+
if (session_status() === PHP_SESSION_ACTIVE) {
642+
session_write_close();
643+
session_id('');
644+
}
645+
session_name('PHPSESSID');
646+
session_unset();
642647
static::$urlHostCache = [];
648+
$_SESSION = [];
643649
}
644650
}

0 commit comments

Comments
 (0)