Since the method for constructing a serialized value container via `newUnified()` has been removed in Id5179be032d45732db659d506d2781, its corresponding `isUnified()` method is now obsolete and this patch deprecates it to be removed in 1.43. Bug: T344521 Change-Id: I5a90028c2a596dfec9a1df306cc9d0ab90dfedd6
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Helper class for segmenting large cache values without relying on serializing classes
|
|
*
|
|
* @since 1.34
|
|
*/
|
|
class SerializedValueContainer {
|
|
private const SCHEMA = '__svc_schema__';
|
|
// 64 bit UID
|
|
private const SCHEMA_UNIFIED = 'DAAIDgoKAQw';
|
|
// 64 bit UID
|
|
private const SCHEMA_SEGMENTED = 'CAYCDAgCDw4';
|
|
|
|
/**
|
|
* @deprecated since 1.42
|
|
*/
|
|
public const UNIFIED_DATA = '__data__';
|
|
public const SEGMENTED_HASHES = '__hashes__';
|
|
|
|
/**
|
|
* @param string[] $segmentHashList Ordered list of hashes for each segment
|
|
* @return stdClass
|
|
*/
|
|
public static function newSegmented( array $segmentHashList ) {
|
|
return (object)[
|
|
self::SCHEMA => self::SCHEMA_SEGMENTED,
|
|
self::SEGMENTED_HASHES => $segmentHashList
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @deprecated since 1.42.
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public static function isUnified( $value ) {
|
|
wfDeprecated( __METHOD__, '1.42' );
|
|
return (
|
|
$value instanceof stdClass &&
|
|
( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_UNIFIED
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public static function isSegmented( $value ) {
|
|
return (
|
|
$value instanceof stdClass &&
|
|
( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_SEGMENTED
|
|
);
|
|
}
|
|
}
|