PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 4.2.15
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v4.2.15
4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 All 136 releases
← All changes | inc/v2/PageProfiler/Storage/Base.php +33 -1 4.2.11 → 4.2.15 View file →
@@ -21,11 +21,43 @@
21 21 /**
22 22 * Retrieve data by key.
23 23 *
24 24 * @param string $key The unique identifier for the data to retrieve.
25 - * @return array|false The stored data or null if not found.
25 + * @return array<string, mixed>|false The stored data or false if not found.
26 26 */
27 27 abstract public function get( string $key );
28 +
29 + /**
30 + * Coerce a stored profiler payload to an array.
31 + *
32 + * Object-cache backends that JSON-decode without associative arrays return stdClass.
33 + * Nested objects (e.g. `af`, `bg`, `lcp`) are converted recursively.
34 + *
35 + * @param mixed $value Raw storage value.
36 + * @return array<string|int, mixed>|false
37 + */
38 + public static function normalize_value( $value ) {
39 + if ( false === $value || null === $value ) {
40 + return false;
41 + }
42 +
43 + if ( is_object( $value ) ) {
44 + $value = get_object_vars( $value );
45 + }
46 +
47 + if ( ! is_array( $value ) ) {
48 + return false;
49 + }
50 +
51 + foreach ( $value as $key => $item ) {
52 + if ( is_object( $item ) || is_array( $item ) ) {
53 + $normalized_item = self::normalize_value( $item );
54 + $value[ $key ] = ( false !== $normalized_item ) ? $normalized_item : [];
55 + }
56 + }
57 +
58 + return $value;
59 + }
28 60
29 61 /**
30 62 * Delete data by key.
31 63 *