Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TimestampType | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| getSQLDeclaration | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
42 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\Rdbms\DBAL; |
| 4 | |
| 5 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 6 | use Doctrine\DBAL\Platforms\MySQLPlatform; |
| 7 | use Doctrine\DBAL\Platforms\PostgreSQLPlatform; |
| 8 | use Doctrine\DBAL\Platforms\SQLitePlatform; |
| 9 | use Doctrine\DBAL\Types\Type; |
| 10 | |
| 11 | /** |
| 12 | * Handling timestamp edge cases in mediawiki. |
| 13 | * https://www.mediawiki.org/wiki/Manual:Timestamp |
| 14 | */ |
| 15 | class TimestampType extends Type { |
| 16 | public const TIMESTAMP = 'mwtimestamp'; |
| 17 | |
| 18 | public function getSQLDeclaration( array $fieldDeclaration, AbstractPlatform $platform ): string { |
| 19 | if ( $platform instanceof MySQLPlatform ) { |
| 20 | // "infinite" (in expiry values has to be VARBINARY) |
| 21 | if ( isset( $fieldDeclaration['allowInfinite'] ) && $fieldDeclaration['allowInfinite'] ) { |
| 22 | return 'VARBINARY(14)'; |
| 23 | } |
| 24 | return 'BINARY(14)'; |
| 25 | } |
| 26 | |
| 27 | if ( $platform instanceof SQLitePlatform ) { |
| 28 | return 'BLOB'; |
| 29 | } |
| 30 | |
| 31 | if ( $platform instanceof PostgreSQLPlatform ) { |
| 32 | return 'TIMESTAMPTZ'; |
| 33 | } |
| 34 | |
| 35 | return $platform->getDateTimeTzTypeDeclarationSQL( $fieldDeclaration ); |
| 36 | } |
| 37 | |
| 38 | public function getName(): string { |
| 39 | return self::TIMESTAMP; |
| 40 | } |
| 41 | } |