11--TEST--
2- OPcache static cache disabled backends report unavailable and store APIs return false
2+ OPcache static cache disabled backends report unavailable and explicit APIs return false by default
33--EXTENSIONS--
44opcache
55--INI--
@@ -12,22 +12,79 @@ opcache.static_cache.pinned_size_mb=0
1212
1313function dump_info (string $ label , OPcache \StaticCacheInfo $ info ): void
1414{
15- echo $ label , "\n" ;
16- var_dump ($ info ->enabled );
17- var_dump ($ info ->available );
18- var_dump ($ info ->startup_failed );
19- var_dump ($ info ->backend_initialized );
20- var_dump ($ info ->configured_memory );
21- var_dump ($ info ->failure_reason );
15+ echo $ label , "\n" ;
16+ var_dump ($ info ->enabled );
17+ var_dump ($ info ->available );
18+ var_dump ($ info ->startup_failed );
19+ var_dump ($ info ->backend_initialized );
20+ var_dump ($ info ->configured_memory );
21+ var_dump ($ info ->failure_reason );
22+ }
23+
24+ function dump_result (string $ label , mixed $ value ): void
25+ {
26+ echo $ label , ': ' ;
27+ var_dump ($ value );
28+ }
29+
30+ function dump_static_cache_exception (string $ label , Closure $ callback ): void
31+ {
32+ try {
33+ $ callback ();
34+ echo $ label , ": no exception \n" ;
35+ } catch (OPcache \StaticCacheException $ exception ) {
36+ echo $ label , ': ' , get_class ($ exception ), ': ' , $ exception ->getMessage (), "\n" ;
37+ }
2238}
2339
2440dump_info ('volatile ' , OPcache \volatile_cache_info ());
2541dump_info ('pinned ' , OPcache \pinned_cache_info ());
2642
27- var_dump (OPcache \volatile_store ('key ' , 'value ' ));
28- var_dump (OPcache \volatile_store_array (['array-key ' => 'value ' ]));
29- var_dump (OPcache \pinned_store ('key ' , 'value ' ));
30- var_dump (OPcache \pinned_store_array (['array-key ' => 'value ' ]));
43+ dump_result ('volatile_store ' , OPcache \volatile_store ('key ' , 'value ' ));
44+ dump_result ('volatile_store_array ' , OPcache \volatile_store_array (['array-key ' => 'value ' ]));
45+ dump_result ('volatile_fetch ' , OPcache \volatile_fetch ('key ' , 'default ' ));
46+ dump_result ('volatile_fetch_array ' , OPcache \volatile_fetch_array (['key ' ], ['key ' => 'default ' ]));
47+ dump_result ('volatile_exists ' , OPcache \volatile_exists ('key ' ));
48+ dump_result ('volatile_lock ' , OPcache \volatile_lock ('key ' ));
49+ dump_result ('volatile_unlock ' , OPcache \volatile_unlock ('key ' ));
50+ dump_result ('volatile_delete ' , OPcache \volatile_delete ('key ' ));
51+ dump_result ('volatile_delete_array ' , OPcache \volatile_delete_array (['key ' ]));
52+ dump_result ('volatile_clear ' , OPcache \volatile_clear ());
53+ dump_result ('pinned_store ' , OPcache \pinned_store ('key ' , 'value ' ));
54+ dump_result ('pinned_store_array ' , OPcache \pinned_store_array (['array-key ' => 'value ' ]));
55+ dump_result ('pinned_fetch ' , OPcache \pinned_fetch ('key ' , 'default ' ));
56+ dump_result ('pinned_fetch_array ' , OPcache \pinned_fetch_array (['key ' ], ['key ' => 'default ' ]));
57+ dump_result ('pinned_exists ' , OPcache \pinned_exists ('key ' ));
58+ dump_result ('pinned_lock ' , OPcache \pinned_lock ('key ' ));
59+ dump_result ('pinned_unlock ' , OPcache \pinned_unlock ('key ' ));
60+ dump_result ('pinned_delete ' , OPcache \pinned_delete ('key ' ));
61+ dump_result ('pinned_delete_array ' , OPcache \pinned_delete_array (['key ' ]));
62+ dump_result ('pinned_clear ' , OPcache \pinned_clear ());
63+ dump_result ('pinned_atomic_increment ' , OPcache \pinned_atomic_increment ('key ' ));
64+ dump_result ('pinned_atomic_decrement ' , OPcache \pinned_atomic_decrement ('key ' ));
65+
66+ dump_static_cache_exception ('volatile_store_throw ' , static fn () => OPcache \volatile_store ('key ' , 'value ' , 0 , true ));
67+ dump_static_cache_exception ('volatile_store_array_throw ' , static fn () => OPcache \volatile_store_array (['array-key ' => 'value ' ], 0 , true ));
68+ dump_static_cache_exception ('volatile_fetch_throw ' , static fn () => OPcache \volatile_fetch ('key ' , 'default ' , true ));
69+ dump_static_cache_exception ('volatile_fetch_array_throw ' , static fn () => OPcache \volatile_fetch_array (['key ' ], ['key ' => 'default ' ], true ));
70+ dump_static_cache_exception ('volatile_exists_throw ' , static fn () => OPcache \volatile_exists ('key ' , true ));
71+ dump_static_cache_exception ('volatile_lock_throw ' , static fn () => OPcache \volatile_lock ('key ' , 0 , true ));
72+ dump_static_cache_exception ('volatile_unlock_throw ' , static fn () => OPcache \volatile_unlock ('key ' , true ));
73+ dump_static_cache_exception ('volatile_delete_throw ' , static fn () => OPcache \volatile_delete ('key ' , true ));
74+ dump_static_cache_exception ('volatile_delete_array_throw ' , static fn () => OPcache \volatile_delete_array (['key ' ], true ));
75+ dump_static_cache_exception ('volatile_clear_throw ' , static fn () => OPcache \volatile_clear (true ));
76+ dump_static_cache_exception ('pinned_store_throw ' , static fn () => OPcache \pinned_store ('key ' , 'value ' , true ));
77+ dump_static_cache_exception ('pinned_store_array_throw ' , static fn () => OPcache \pinned_store_array (['array-key ' => 'value ' ], true ));
78+ dump_static_cache_exception ('pinned_fetch_throw ' , static fn () => OPcache \pinned_fetch ('key ' , 'default ' , true ));
79+ dump_static_cache_exception ('pinned_fetch_array_throw ' , static fn () => OPcache \pinned_fetch_array (['key ' ], ['key ' => 'default ' ], true ));
80+ dump_static_cache_exception ('pinned_exists_throw ' , static fn () => OPcache \pinned_exists ('key ' , true ));
81+ dump_static_cache_exception ('pinned_lock_throw ' , static fn () => OPcache \pinned_lock ('key ' , 0 , true ));
82+ dump_static_cache_exception ('pinned_unlock_throw ' , static fn () => OPcache \pinned_unlock ('key ' , true ));
83+ dump_static_cache_exception ('pinned_delete_throw ' , static fn () => OPcache \pinned_delete ('key ' , true ));
84+ dump_static_cache_exception ('pinned_delete_array_throw ' , static fn () => OPcache \pinned_delete_array (['key ' ], true ));
85+ dump_static_cache_exception ('pinned_clear_throw ' , static fn () => OPcache \pinned_clear (true ));
86+ dump_static_cache_exception ('pinned_atomic_increment_throw ' , static fn () => OPcache \pinned_atomic_increment ('key ' , 1 , true ));
87+ dump_static_cache_exception ('pinned_atomic_decrement_throw ' , static fn () => OPcache \pinned_atomic_decrement ('key ' , 1 , true ));
3188
3289?>
3390--EXPECT--
@@ -45,7 +102,47 @@ bool(false)
45102bool(false)
46103int(0)
47104NULL
48- bool(false)
49- bool(false)
50- bool(false)
51- bool(false)
105+ volatile_store: bool(false)
106+ volatile_store_array: bool(false)
107+ volatile_fetch: bool(false)
108+ volatile_fetch_array: bool(false)
109+ volatile_exists: bool(false)
110+ volatile_lock: bool(false)
111+ volatile_unlock: bool(false)
112+ volatile_delete: bool(false)
113+ volatile_delete_array: bool(false)
114+ volatile_clear: bool(false)
115+ pinned_store: bool(false)
116+ pinned_store_array: bool(false)
117+ pinned_fetch: bool(false)
118+ pinned_fetch_array: bool(false)
119+ pinned_exists: bool(false)
120+ pinned_lock: bool(false)
121+ pinned_unlock: bool(false)
122+ pinned_delete: bool(false)
123+ pinned_delete_array: bool(false)
124+ pinned_clear: bool(false)
125+ pinned_atomic_increment: bool(false)
126+ pinned_atomic_decrement: bool(false)
127+ volatile_store_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
128+ volatile_store_array_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
129+ volatile_fetch_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
130+ volatile_fetch_array_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
131+ volatile_exists_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
132+ volatile_lock_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
133+ volatile_unlock_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
134+ volatile_delete_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
135+ volatile_delete_array_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
136+ volatile_clear_throw: OPcache\StaticCacheException: OPcache volatile cache is disabled
137+ pinned_store_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
138+ pinned_store_array_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
139+ pinned_fetch_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
140+ pinned_fetch_array_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
141+ pinned_exists_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
142+ pinned_lock_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
143+ pinned_unlock_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
144+ pinned_delete_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
145+ pinned_delete_array_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
146+ pinned_clear_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
147+ pinned_atomic_increment_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
148+ pinned_atomic_decrement_throw: OPcache\StaticCacheException: OPcache pinned cache is disabled
0 commit comments