@@ -21,13 +21,13 @@ function bar() {
2121
2222function baz () {
2323 global $ wpdb ;
24- $ baz = wp_cache_get ( 'baz ' );
24+ $ baz = WP_CACHE_GET ( 'baz ' );
2525 if ( false !== $ baz ) {
2626 $ wpdb ->query ( 'ALTER TABLE TO ADD SOME FIELDS ' ); // Warning x 2.
2727 $ wpdb ->query ( $ wpdb ->prepare ( 'CREATE TABLE ' ) ); // Warning x 2.
2828 $ wpdb ->query ( 'SELECT QUERY ' ); // Warning.
2929 $ baz = $ wpdb ->get_results ( $ wpdb ->prepare ( 'SELECT X FROM Y ' ) ); // Warning.
30- wp_cache_set ( 'baz ' , $ baz );
30+ WP_cache_SET ( 'baz ' , $ baz );
3131 }
3232}
3333
@@ -66,7 +66,7 @@ function cache_delete_only() {
6666 $ wpdb ->get_row ( 'SELECT X FROM Y ' ); // Warning x 2.
6767 $ wpdb ->get_col ( 'SELECT X FROM Y ' ); // Warning x 2.
6868
69- wp_cache_delete ( 'key ' , 'group ' );
69+ WP_CACHE_DELETE ( 'key ' , 'group ' );
7070}
7171
7272// It is OK to use the wp_cache_add() function instead of wp_cache_set().
@@ -333,6 +333,24 @@ function method_names_are_caseinsensitive() {
333333 $ autoload = $ wpdb ->Get_Var ( $ wpdb ->Prepare ( "SELECT autoload FROM $ wpdb ->options WHERE option_name = %s " , $ option_name ) ); // Warning x 2.
334334}
335335
336- // Live coding/parse error test.
337- // This must be the last test in the file.
338- $ wpdb ->get_col( '
336+ // phpcs:set WordPress.DB.DirectDatabaseQuery customCacheGetFunctions[] MY_cacheget
337+ // phpcs:set WordPress.DB.DirectDatabaseQuery customCacheSetFunctions[] my_CACHESET
338+ // phpcs:set WordPress.DB.DirectDatabaseQuery customCacheDeleteFunctions[] MY_cachedel
339+ function cache_custom_mixed_case_A () {
340+ global $ wpdb ;
341+ $ quux = my_cacheget ( 'quux ' );
342+ if ( false !== $ quux ) {
343+ $ wpdb ->get_results ( 'SELECT X FROM Y ' ); // Warning direct DB call.
344+ my_cacheset ( 'key ' , 'group ' );
345+ }
346+ }
347+
348+ function cache_custom_mixed_case_B () {
349+ global $ wpdb ;
350+ $ wpdb ->query ( 'SELECT X FROM Y ' ); // Warning direct DB call.
351+ my_cachedel ( 'key ' , 'group ' );
352+ }
353+
354+ // phpcs:set WordPress.DB.DirectDatabaseQuery customCacheGetFunctions[]
355+ // phpcs:set WordPress.DB.DirectDatabaseQuery customCacheSetFunctions[]
356+ // phpcs:set WordPress.DB.DirectDatabaseQuery customCacheDeleteFunctions[]
0 commit comments