Changeset 51911
- Timestamp:
- 10/15/2021 10:52:43 PM (20 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r51910 r51911 8121 8121 * @param string|array $exclude Optional. Full path of a subdirectory to exclude from the total, 8122 8122 * or array of paths. Expected without trailing slash(es). 8123 * @param int $max_execution_time Maximum time to run before giving up. In seconds. The timeout is global 8124 * and is measured from the moment WordPress started to load. 8123 * @param int $max_execution_time Optional. Maximum time to run before giving up. In seconds. 8124 * The timeout is global and is measured from the moment 8125 * WordPress started to load. 8125 8126 * @param array $directory_cache Optional. Array of cached directory paths. 8126 8127 * … … 8195 8196 } 8196 8197 8197 if ( $max_execution_time > 0 && microtime( true ) - WP_START_TIMESTAMP > $max_execution_time ) { 8198 if ( $max_execution_time > 0 && 8199 ( microtime( true ) - WP_START_TIMESTAMP ) > $max_execution_time 8200 ) { 8198 8201 // Time exceeded. Give up instead of risking a fatal timeout. 8199 8202 $size = null; … … 8204 8207 closedir( $handle ); 8205 8208 } 8209 } 8210 8211 if ( ! is_array( $directory_cache ) ) { 8212 $directory_cache = array(); 8206 8213 } 8207 8214 -
trunk/tests/phpunit/tests/functions/cleanDirsizeCache.php
r51910 r51911 4 4 * Tests specific to the directory size caching. 5 5 * 6 * @covers ::clean_dirsize_cache7 6 * @group functions.php 8 7 */ … … 13 12 * 14 13 * @ticket 52241 14 * 15 * @covers ::clean_dirsize_cache 15 16 * 16 17 * @dataProvider data_clean_dirsize_cache_with_invalid_inputs … … 56 57 * 57 58 * @ticket 52241 59 * 60 * @covers ::clean_dirsize_cache 58 61 * 59 62 * @dataProvider data_clean_dirsize_cache_with_non_path_string … … 101 104 ); 102 105 } 106 107 /** 108 * Test the behaviour of the function when the transient doesn't exist. 109 * 110 * @ticket 52241 111 * @ticket 53635 112 * 113 * @covers ::recurse_dirsize 114 */ 115 public function test_recurse_dirsize_without_transient() { 116 delete_transient( 'dirsize_cache' ); 117 118 $size = recurse_dirsize( __DIR__ . '/fixtures' ); 119 120 $this->assertGreaterThan( 10, $size ); 121 } 122 123 /** 124 * Test the behaviour of the function when the transient does exist, but is not an array. 125 * 126 * In particular, this tests that no PHP TypeErrors are being thrown. 127 * 128 * @ticket 52241 129 * @ticket 53635 130 * 131 * @covers ::recurse_dirsize 132 */ 133 public function test_recurse_dirsize_with_invalid_transient() { 134 set_transient( 'dirsize_cache', 'this is not a valid transient for dirsize cache' ); 135 136 $size = recurse_dirsize( __DIR__ . '/fixtures' ); 137 138 $this->assertGreaterThan( 10, $size ); 139 } 103 140 }
Note: See TracChangeset
for help on using the changeset viewer.