Changeset 57290
- Timestamp:
- 01/16/2024 12:10:47 PM (12 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-textdomain-registry.php
r57287 r57290 162 162 */ 163 163 public function get_language_files_from_path( $path ) { 164 $path = trailingslashit( $path );164 $path = rtrim( $path, '/' ) . '/'; 165 165 166 166 /** … … 238 238 switch ( $type ) { 239 239 case 'plugin': 240 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/plugins/' ), 'translations' );240 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins' ), 'translations' ); 241 241 break; 242 242 case 'theme': 243 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/themes/' ), 'translations' );243 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes' ), 'translations' ); 244 244 break; 245 245 default: 246 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR )), 'translations' );246 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR ), 'translations' ); 247 247 break; 248 248 } -
trunk/tests/phpunit/tests/l10n/wpTextdomainRegistry.php
r57287 r57290 20 20 21 21 public function tear_down() { 22 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/foobar/' ), 'translations' );23 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/plugins/' ), 'translations' );24 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/themes/' ), 'translations' );25 wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR )), 'translations' );22 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/foobar' ), 'translations' ); 23 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins' ), 'translations' ); 24 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes' ), 'translations' ); 25 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR ), 'translations' ); 26 26 27 27 parent::tear_down(); … … 85 85 */ 86 86 public function test_get_language_files_from_path_caches_results() { 87 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . ' /foobar/' );88 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . ' /plugins/' );89 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . ' /themes/' );87 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . 'foobar/' ); 88 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . 'plugins/' ); 89 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . 'themes/' ); 90 90 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) ); 91 91 92 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . ' /plugins/' ), 'translations' ) );93 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . ' /themes/' ), 'translations' ) );94 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . ' /foobar/' ), 'translations' ) );92 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . 'plugins/' ), 'translations' ) ); 93 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . 'themes/' ), 'translations' ) ); 94 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . 'foobar/' ), 'translations' ) ); 95 95 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) ), 'translations' ) ); 96 96 } … … 101 101 public function test_get_language_files_from_path_short_circuit() { 102 102 add_filter( 'pre_get_language_files_from_path', '__return_empty_array' ); 103 $result = $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . '/plugins/' );103 $result = $this->instance->get_language_files_from_path( WP_LANG_DIR . '/plugins' ); 104 104 remove_filter( 'pre_get_language_files_from_path', '__return_empty_array' ); 105 105 106 $cache = wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/plugins/' ), 'translations' );106 $cache = wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . 'plugins' ), 'translations' ); 107 107 108 108 $this->assertEmpty( $result ); … … 114 114 */ 115 115 public function test_invalidate_mo_files_cache() { 116 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . '/plugins/' );117 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ) . '/themes/' );118 $this->instance->get_language_files_from_path( trailingslashit( WP_LANG_DIR ));116 $this->instance->get_language_files_from_path( WP_LANG_DIR . '/plugins' ); 117 $this->instance->get_language_files_from_path( WP_LANG_DIR . '/themes' ); 118 $this->instance->get_language_files_from_path( WP_LANG_DIR ); 119 119 120 120 $this->instance->invalidate_mo_files_cache( … … 145 145 ); 146 146 147 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/plugins/' ), 'translations' ) );148 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/themes/' ), 'translations' ) );149 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR )), 'translations' ) );147 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins' ), 'translations' ) ); 148 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes' ), 'translations' ) ); 149 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR ), 'translations' ) ); 150 150 } 151 151
Note: See TracChangeset
for help on using the changeset viewer.