- Timestamp:
- 09/11/2020 04:41:56 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r10249 r10250 40 40 // The test suite just needs the functions defined and doesn't want any headers or output 41 41 if ( defined( 'RUNNING_TESTS' ) && RUNNING_TESTS ) { 42 disable_caching(); 42 43 return; 43 44 } 44 45 45 wp_cache_init(); 46 // Disable object caching during manual testing, unless explicitly testing caching. 47 if ( is_test_request() && empty( $_GET['cache'] ) ) { 48 disable_caching(); 49 } else { 50 wp_cache_init(); 51 } 46 52 47 53 $cache_group = 'events'; … … 53 59 54 60 send_response( $response, $ttl ); 61 } 62 63 /** 64 * Determine if the current request is a developer manually testing on their sandbox. 65 * 66 * @return bool 67 */ 68 function is_test_request() { 69 $proxied = defined( 'WPORG_PROXIED_REQUEST' ) && WPORG_PROXIED_REQUEST; 70 $sandbox = defined( 'WPORG_SANDBOXED' ) && WPORG_SANDBOXED; 71 72 return $proxied && $sandbox; 73 } 74 75 /** 76 * Mock the caching functions. 77 */ 78 function disable_caching() { 79 /** 80 * Stub to simulate cache misses, so that the tests always get fresh results 81 * 82 * @return false 83 */ 84 function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { 85 return false; 86 } 87 88 /** 89 * Stub to avoid setting production object cache values while testing. 90 */ 91 function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { 92 // Intentionally empty 93 } 55 94 } 56 95
Note: See TracChangeset
for help on using the changeset viewer.