Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SerializedValueContainer | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
newSegmented | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
isUnified | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
isSegmented | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * Helper class for segmenting large cache values without relying on serializing classes |
5 | * |
6 | * @since 1.34 |
7 | */ |
8 | class SerializedValueContainer { |
9 | private const SCHEMA = '__svc_schema__'; |
10 | // 64 bit UID |
11 | private const SCHEMA_UNIFIED = 'DAAIDgoKAQw'; |
12 | // 64 bit UID |
13 | private const SCHEMA_SEGMENTED = 'CAYCDAgCDw4'; |
14 | |
15 | /** |
16 | * @deprecated since 1.42 |
17 | */ |
18 | public const UNIFIED_DATA = '__data__'; |
19 | public const SEGMENTED_HASHES = '__hashes__'; |
20 | |
21 | /** |
22 | * @param string[] $segmentHashList Ordered list of hashes for each segment |
23 | * @return stdClass |
24 | */ |
25 | public static function newSegmented( array $segmentHashList ) { |
26 | return (object)[ |
27 | self::SCHEMA => self::SCHEMA_SEGMENTED, |
28 | self::SEGMENTED_HASHES => $segmentHashList |
29 | ]; |
30 | } |
31 | |
32 | /** |
33 | * @deprecated since 1.42. |
34 | * @param mixed $value |
35 | * @return bool |
36 | */ |
37 | public static function isUnified( $value ) { |
38 | wfDeprecated( __METHOD__, '1.42' ); |
39 | return ( |
40 | $value instanceof stdClass && |
41 | ( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_UNIFIED |
42 | ); |
43 | } |
44 | |
45 | /** |
46 | * @param mixed $value |
47 | * @return bool |
48 | */ |
49 | public static function isSegmented( $value ) { |
50 | return ( |
51 | $value instanceof stdClass && |
52 | ( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_SEGMENTED |
53 | ); |
54 | } |
55 | } |