Skip to content

Commit 4dce93e

Browse files
committed
Remove "|" when prefix is empty
Fix Test to lock database with long name
1 parent 08972b4 commit 4dce93e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function isLocked(string $name): bool
167167
*/
168168
private function addPrefix(string $name): string
169169
{
170-
$prefix = $this->getPrefix() . '|';
170+
$prefix = $this->getPrefix() ? $this->getPrefix() . '|' : '';
171171
$name = ExpressionConverter::shortenEntityName($prefix . $name, $prefix);
172172

173173
if (strlen($name) > 64) {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,18 @@ public function testLock()
106106
* @throws \Magento\Framework\Exception\AlreadyExistsException
107107
* @throws \Magento\Framework\Exception\InputException
108108
* @throws \Zend_Db_Statement_Exception
109-
* @expectedException \Magento\Framework\Exception\InputException
110109
*/
111110
public function testlockWithTooLongName()
112111
{
113112
$this->deploymentConfig
114113
->method('isDbAvailable')
115114
->with()
116115
->willReturn(true);
117-
$this->database->lock('BbXbyf9rIY5xuAVdviQJmh76FyoeeVHTDpcjmcImNtgpO4Hnz4xk76ZGEyYALvrQu');
116+
$this->statement->expects($this->once())
117+
->method('fetchColumn')
118+
->willReturn(true);
119+
120+
$this->assertTrue($this->database->lock('BbXbyf9rIY5xuAVdviQJmh76FyoeeVHTDpcjmcImNtgpO4Hnz4xk76ZGEyYALvrQu'));
118121
}
119122

120123
/**

0 commit comments

Comments
 (0)