Skip to content

Commit 00cd00a

Browse files
authored
Merge branch '2.4-develop' into feature/cms-block
2 parents c3f7bed + 9fa16c7 commit 00cd00a

File tree

8 files changed

+36
-32
lines changed

8 files changed

+36
-32
lines changed

app/code/Magento/Config/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
<virtualType name="systemConfigQueryLocker" type="Magento\Framework\Cache\LockGuardedCacheLoader">
9898
<arguments>
99-
<argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument>
99+
<argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Database</argument>
100100
</arguments>
101101
</virtualType>
102102

app/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@
17861786
</type>
17871787
<type name="Magento\Framework\Cache\LockGuardedCacheLoader">
17881788
<arguments>
1789-
<argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument>
1789+
<argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Database</argument>
17901790
</arguments>
17911791
</type>
17921792
<preference for="Magento\Framework\HTTP\AsyncClientInterface" type="Magento\Framework\HTTP\AsyncClient\GuzzleAsyncClient" />

dev/tests/integration/etc/di/preferences/ce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
\Magento\Framework\App\Config\ScopeConfigInterface::class => \Magento\TestFramework\App\Config::class,
2828
\Magento\Framework\App\ResourceConnection\ConfigInterface::class =>
2929
\Magento\Framework\App\ResourceConnection\Config::class,
30-
\Magento\Framework\Lock\Backend\Cache::class =>
30+
\Magento\Framework\Lock\Backend\Database::class =>
3131
\Magento\TestFramework\Lock\Backend\DummyLocker::class,
3232
\Magento\Framework\Session\SessionStartChecker::class => \Magento\TestFramework\Session\SessionStartChecker::class,
3333
\Magento\Framework\HTTP\AsyncClientInterface::class => \Magento\TestFramework\HTTP\AsyncClientInterfaceMock::class,

dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/DatabaseTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Magento\Framework\Lock\Backend;
99

10+
use Magento\Framework\App\ResourceConnection;
11+
use Magento\Framework\App\DeploymentConfig;
12+
1013
/**
1114
* \Magento\Framework\Lock\Backend\Database test case
1215
*/
@@ -25,7 +28,10 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase
2528
protected function setUp(): void
2629
{
2730
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
28-
$this->model = $this->objectManager->create(\Magento\Framework\Lock\Backend\Database::class);
31+
$resourceConnection = $this->objectManager->create(ResourceConnection::class);
32+
$deploymentConfig = $this->objectManager->create(DeploymentConfig::class);
33+
// create object with new otherwise dummy locker is created because of di.xml preference for integration tests
34+
$this->model = new Database($resourceConnection, $deploymentConfig);
2935
}
3036

3137
public function testLockAndUnlock()

dev/tests/integration/testsuite/Magento/MessageQueue/Model/Cron/ConsumersRunnerTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\MessageQueue\Model\Cron;
77

8+
use Magento\Framework\App\DeploymentConfig;
9+
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\Lock\Backend\Database;
811
use Magento\Framework\MessageQueue\Consumer\ConfigInterface as ConsumerConfigInterface;
912
use Magento\Framework\Lock\LockManagerInterface;
1013
use Magento\Framework\App\DeploymentConfig\FileReader;
@@ -83,7 +86,10 @@ protected function setUp(): void
8386
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8487
$this->shellMock = $this->getMockBuilder(ShellInterface::class)
8588
->getMockForAbstractClass();
86-
$this->lockManager = $this->objectManager->get(LockManagerInterface::class);
89+
$resourceConnection = $this->objectManager->create(ResourceConnection::class);
90+
$deploymentConfig = $this->objectManager->create(DeploymentConfig::class);
91+
// create object with new otherwise dummy locker is created because of di.xml preference for integration tests
92+
$this->lockManager = new Database($resourceConnection, $deploymentConfig);
8793
$this->consumerConfig = $this->objectManager->get(ConsumerConfigInterface::class);
8894
$this->reader = $this->objectManager->get(FileReader::class);
8995
$this->filesystem = $this->objectManager->get(Filesystem::class);

dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,20 @@ private function checkArgumentMismatch($phrase, &$incorrectNumberOfArgumentsErro
9999
{
100100
if (preg_match_all('/%(\w+)/', $phrase['phrase'], $matches) || $phrase['arguments']) {
101101
$placeholderCount = count(array_unique($matches[1]));
102+
// count all occurrences of sprintf placeholders
103+
preg_match_all('/%\b([sducoxXbgGeEfF])\b/', $phrase['phrase'], $sprintfMatches);
104+
if (count($sprintfMatches[0]) > count(array_unique($sprintfMatches[0]))) {
105+
$placeholderCount = $placeholderCount +
106+
count($sprintfMatches[0]) - count(array_unique($sprintfMatches[0]));
107+
}
102108

103-
// Check for zend placeholders %placeholder% and sprintf placeholder %s
104-
if (preg_match_all('/%((s)|([A-Za-z]+)%)/', $phrase['phrase'], $placeHolders, PREG_OFFSET_CAPTURE)) {
109+
// Check for zend placeholders %placeholder% and sprintf placeholders and remove from the count
110+
if (preg_match_all(
111+
'/%\b(([sducoxXbgGeEfF])\b|([A-Za-z]+)%)/',
112+
$phrase['phrase'],
113+
$placeHolders,
114+
PREG_OFFSET_CAPTURE
115+
)) {
105116
foreach ($placeHolders[0] as $ph) {
106117
// Check if char after placeholder is not a digit or letter
107118
$charAfterPh = $phrase['phrase'][$ph[1] + strlen($ph[0])];

lib/internal/Magento/Framework/Lock/Backend/Database.php

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use Magento\Framework\App\DeploymentConfig;
1111
use Magento\Framework\App\ResourceConnection;
1212
use Magento\Framework\Config\ConfigOptionsListConstants;
13-
use Magento\Framework\Exception\AlreadyExistsException;
14-
use Magento\Framework\Phrase;
1513
use Magento\Framework\DB\ExpressionConverter;
14+
use Magento\Framework\Exception\FileSystemException;
15+
use Magento\Framework\Exception\RuntimeException;
1616

1717
/**
1818
* Implementation of the lock manager on the basis of MySQL.
@@ -68,7 +68,8 @@ public function __construct(
6868
* @param string $name lock name
6969
* @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
7070
* @return bool
71-
* @throws AlreadyExistsException
71+
* @throws FileSystemException
72+
* @throws RuntimeException
7273
* @throws \Zend_Db_Statement_Exception
7374
*/
7475
public function lock(string $name, int $timeout = -1): bool
@@ -78,20 +79,6 @@ public function lock(string $name, int $timeout = -1): bool
7879
}
7980
$name = $this->addPrefix($name);
8081

81-
/**
82-
* Before MySQL 5.7.5, only a single simultaneous lock per connection can be acquired.
83-
* This limitation can be removed once MySQL minimum requirement has been raised,
84-
* currently we support MySQL 5.6 way only.
85-
*/
86-
if ($this->currentLock) {
87-
throw new AlreadyExistsException(
88-
new Phrase(
89-
'Current connection is already holding lock for %1, only single lock allowed',
90-
[$this->currentLock]
91-
)
92-
);
93-
}
94-
9582
$result = (bool)$this->resource->getConnection()->query(
9683
"SELECT GET_LOCK(?, ?);",
9784
[$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout]

lib/internal/Magento/Framework/Lock/Test/Unit/Backend/DatabaseTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\App\DeploymentConfig;
1111
use Magento\Framework\App\ResourceConnection;
1212
use Magento\Framework\DB\Adapter\AdapterInterface;
13-
use Magento\Framework\Exception\AlreadyExistsException;
1413
use Magento\Framework\Lock\Backend\Database;
1514
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1615
use PHPUnit\Framework\MockObject\MockObject;
@@ -90,7 +89,6 @@ protected function setUp(): void
9089
}
9190

9291
/**
93-
* @throws AlreadyExistsException
9492
* @throws \Zend_Db_Statement_Exception
9593
*/
9694
public function testLock()
@@ -107,7 +105,6 @@ public function testLock()
107105
}
108106

109107
/**
110-
* @throws AlreadyExistsException
111108
* @throws \Zend_Db_Statement_Exception
112109
*/
113110
public function testlockWithTooLongName()
@@ -124,12 +121,10 @@ public function testlockWithTooLongName()
124121
}
125122

126123
/**
127-
* @throws AlreadyExistsException
128124
* @throws \Zend_Db_Statement_Exception
129125
*/
130126
public function testlockWithAlreadyAcquiredLockInSameSession()
131127
{
132-
$this->expectException('Magento\Framework\Exception\AlreadyExistsException');
133128
$this->deploymentConfig
134129
->method('isDbAvailable')
135130
->with()
@@ -138,12 +133,11 @@ public function testlockWithAlreadyAcquiredLockInSameSession()
138133
->method('fetchColumn')
139134
->willReturn(true);
140135

141-
$this->database->lock('testLock');
142-
$this->database->lock('differentLock');
136+
$this->assertTrue($this->database->lock('testLock'));
137+
$this->assertTrue($this->database->lock('differentLock'));
143138
}
144139

145140
/**
146-
* @throws AlreadyExistsException
147141
* @throws \Zend_Db_Statement_Exception
148142
*/
149143
public function testLockWithUnavailableDeploymentConfig()

0 commit comments

Comments
 (0)