Skip to content

Commit 44635a2

Browse files
authored
Remove deprecated lock-related methods (#6219)
| Q | A |------------- | ----------- | Type | bug/feature/improvement | Fixed issues | Follows #6191 #### Summary This PR removed methods that have been deprecated in #6191.
1 parent 304e3ec commit 44635a2

12 files changed

+18
-107
lines changed

UPGRADE.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ awareness about deprecated code.
88

99
# Upgrade to 4.0
1010

11+
## BC BREAK: Removed lock-related `AbstractPlatform` methods
12+
13+
The methods `AbstractPlatform::getReadLockSQL()`, `::getWriteLockSQL()` and `::getForUpdateSQL()` have been removed
14+
Use `QueryBuilder::forUpdate()` as a replacement for the latter.
15+
1116
## BC BREAK: BIGINT vales are cast to int if possible
1217

1318
`BigIntType` casts values retrieved from the database to int if they're inside
@@ -215,9 +220,11 @@ The following classes have been converted to enums:
215220
1. `Doctrine\DBAL\ColumnCase`,
216221
2. `Doctrine\DBAL\LockMode`,
217222
3. `Doctrine\DBAL\ParameterType`,
218-
4. `Doctrine\DBAL\TransactionIsolationLevel`,
219-
5. `Doctrine\DBAL\Platforms\DateIntervalUnit`,
220-
6. `Doctrine\DBAL\Platforms\TrimMode`.
223+
4. `Doctrine\DBAL\ArrayParameterType`,
224+
5. `Doctrine\DBAL\TransactionIsolationLevel`,
225+
6. `Doctrine\DBAL\Platforms\DateIntervalUnit`,
226+
7. `Doctrine\DBAL\Platforms\TrimMode`.
227+
8. `Doctrine\DBAL\Query\ForUpdate\ConflictResolutionMode`
221228

222229
The corresponding class constants are now instances of their enum type.
223230

psalm.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353

5454
<!-- TODO for PHPUnit 11 -->
5555
<referencedMethod name="PHPUnit\Framework\TestCase::iniSet"/>
56-
57-
<!-- TODO: remove in 4.0.0 -->
58-
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getForUpdateSQL"/>
59-
<referencedMethod name="Doctrine\DBAL\Platforms\DB2Platform::getForUpdateSQL"/>
6056
</errorLevel>
6157
</DeprecatedMethod>
6258
<DocblockTypeContradiction>

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,11 +739,6 @@ public function getSetTransactionIsolationSQL(TransactionIsolationLevel $level):
739739
return 'SET SESSION TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
740740
}
741741

742-
public function getReadLockSQL(): string
743-
{
744-
return 'LOCK IN SHARE MODE';
745-
}
746-
747742
protected function initializeDoctrineTypeMappings(): void
748743
{
749744
$this->doctrineTypeMapping = [

src/Platforms/AbstractPlatform.php

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use Doctrine\DBAL\Types;
3434
use Doctrine\DBAL\Types\Exception\TypeNotFound;
3535
use Doctrine\DBAL\Types\Type;
36-
use Doctrine\Deprecations\Deprecation;
3736

3837
use function addcslashes;
3938
use function array_map;
@@ -701,23 +700,6 @@ public function getBitOrComparisonExpression(string $value1, string $value2): st
701700
*/
702701
abstract public function getCurrentDatabaseExpression(): string;
703702

704-
/**
705-
* Returns the FOR UPDATE expression.
706-
*
707-
* @deprecated This API is not portable. Use {@link QueryBuilder::forUpdate()}` instead.
708-
*/
709-
public function getForUpdateSQL(): string
710-
{
711-
Deprecation::triggerIfCalledFromOutside(
712-
'doctrine/dbal',
713-
'https://github.com/doctrine/dbal/pull/6191',
714-
'%s is deprecated as non-portable.',
715-
__METHOD__,
716-
);
717-
718-
return 'FOR UPDATE';
719-
}
720-
721703
/**
722704
* Honors that some SQL vendors such as MsSql use table hints for locking instead of the
723705
* ANSI SQL FOR UPDATE specification.
@@ -729,45 +711,6 @@ public function appendLockHint(string $fromClause, LockMode $lockMode): string
729711
return $fromClause;
730712
}
731713

732-
/**
733-
* Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock.
734-
*
735-
* This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database
736-
* vendors allow to lighten this constraint up to be a real read lock.
737-
*
738-
* @deprecated This API is not portable.
739-
*/
740-
public function getReadLockSQL(): string
741-
{
742-
Deprecation::trigger(
743-
'doctrine/dbal',
744-
'https://github.com/doctrine/dbal/pull/6191',
745-
'%s is deprecated as non-portable.',
746-
__METHOD__,
747-
);
748-
749-
return $this->getForUpdateSQL();
750-
}
751-
752-
/**
753-
* Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows.
754-
*
755-
* The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard.
756-
*
757-
* @deprecated This API is not portable.
758-
*/
759-
public function getWriteLockSQL(): string
760-
{
761-
Deprecation::trigger(
762-
'doctrine/dbal',
763-
'https://github.com/doctrine/dbal/pull/6191',
764-
'%s is deprecated as non-portable.',
765-
__METHOD__,
766-
);
767-
768-
return $this->getForUpdateSQL();
769-
}
770-
771714
/**
772715
* Returns the SQL snippet to drop an existing table.
773716
*/

src/Platforms/DB2Platform.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,6 @@ public function createSelectSQLBuilder(): SelectSQLBuilder
564564
return new DefaultSelectSQLBuilder($this, 'WITH RR USE AND KEEP UPDATE LOCKS', null);
565565
}
566566

567-
/** @deprecated This API is not portable. */
568-
public function getForUpdateSQL(): string
569-
{
570-
return ' WITH RR USE AND KEEP UPDATE LOCKS';
571-
}
572-
573567
public function getDummySelectSQL(string $expression = '1'): string
574568
{
575569
return sprintf('SELECT %s FROM sysibm.sysdummy1', $expression);

src/Platforms/PostgreSQLPlatform.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,6 @@ public function getTruncateTableSQL(string $tableName, bool $cascade = false): s
685685
return $sql;
686686
}
687687

688-
public function getReadLockSQL(): string
689-
{
690-
return 'FOR SHARE';
691-
}
692-
693688
protected function initializeDoctrineTypeMappings(): void
694689
{
695690
$this->doctrineTypeMapping = [

src/Platforms/SQLServerPlatform.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,12 +1096,6 @@ public function appendLockHint(string $fromClause, LockMode $lockMode): string
10961096
};
10971097
}
10981098

1099-
/** @deprecated This API is not portable. */
1100-
public function getForUpdateSQL(): string
1101-
{
1102-
return ' ';
1103-
}
1104-
11051099
protected function createReservedKeywordsList(): KeywordList
11061100
{
11071101
return new SQLServerKeywords();

src/Platforms/SQLitePlatform.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,6 @@ public function getTruncateTableSQL(string $tableName, bool $cascade = false): s
415415
return 'DELETE FROM ' . $tableIdentifier->getQuotedName($this);
416416
}
417417

418-
public function getForUpdateSQL(): string
419-
{
420-
return '';
421-
}
422-
423418
/** @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy. */
424419
public function getInlineColumnCommentSQL(string $comment): string
425420
{

src/Query/ForUpdate.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44

55
namespace Doctrine\DBAL\Query;
66

7+
use Doctrine\DBAL\Query\ForUpdate\ConflictResolutionMode;
8+
79
/** @internal */
810
final class ForUpdate
911
{
1012
public function __construct(
11-
private readonly int $conflictResolutionMode,
13+
private readonly ConflictResolutionMode $conflictResolutionMode,
1214
) {
1315
}
1416

15-
public function getConflictResolutionMode(): int
17+
public function getConflictResolutionMode(): ConflictResolutionMode
1618
{
1719
return $this->conflictResolutionMode;
1820
}

src/Query/ForUpdate/ConflictResolutionMode.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,15 @@
44

55
namespace Doctrine\DBAL\Query\ForUpdate;
66

7-
final class ConflictResolutionMode
7+
enum ConflictResolutionMode
88
{
99
/**
1010
* Wait for the row to be unlocked
1111
*/
12-
public const ORDINARY = 0;
12+
case ORDINARY;
1313

1414
/**
1515
* Skip the row if it is locked
1616
*/
17-
public const SKIP_LOCKED = 1;
18-
19-
/**
20-
* This class cannot be instantiated.
21-
*
22-
* @codeCoverageIgnore
23-
*/
24-
private function __construct()
25-
{
26-
}
17+
case SKIP_LOCKED;
2718
}

src/Query/QueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public function getMaxResults(): ?int
492492
*
493493
* @return $this
494494
*/
495-
public function forUpdate(int $conflictResolutionMode = ConflictResolutionMode::ORDINARY): self
495+
public function forUpdate(ConflictResolutionMode $conflictResolutionMode = ConflictResolutionMode::ORDINARY): self
496496
{
497497
$this->forUpdate = new ForUpdate($conflictResolutionMode);
498498

tests/Platforms/DB2PlatformTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ public function testGeneratesSQLSnippets(): void
321321
);
322322

323323
self::assertEquals("'1987/05/02' - 10 YEAR", $this->platform->getDateSubYearsExpression("'1987/05/02'", '10'));
324-
self::assertEquals(' WITH RR USE AND KEEP UPDATE LOCKS', $this->platform->getForUpdateSQL());
325324

326325
self::assertEquals(
327326
'LOCATE(substring_column, string_column)',

0 commit comments

Comments
 (0)