Ticket #64767: 64767.patch
| File 64767.patch, 6.6 KB (added by , 6 months ago) |
|---|
-
wp-includes/l10n/class-wp-translation-file-mo.php
13 13 * @since 6.5.0 14 14 */ 15 15 class WP_Translation_File_MO extends WP_Translation_File { 16 16 17 /** 17 18 * Endian value. 18 19 * … … 34 35 const MAGIC_MARKER = 0x950412de; 35 36 36 37 /** 38 * Normalize unpacked uint32 values to integers. 39 * 40 * Prevents float-to-int cast warnings on PHP 8.5+. 41 * 42 * @param mixed $value Value from unpack(). 43 * @return int 44 */ 45 private function normalize_uint32( $value ): int { 46 return (int) ( $value & 0xFFFFFFFF ); 47 } 48 49 /** 37 50 * Detects endian and validates file. 38 51 * 39 52 * @since 6.5.0 … … 54 67 return false; 55 68 } 56 69 70 $big = $this->normalize_uint32( $big ); 71 57 72 $little = unpack( 'V', $header ); 58 73 59 74 if ( false === $little ) { … … 66 81 return false; 67 82 } 68 83 84 $little = $this->normalize_uint32( $little ); 85 69 86 // Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678. 70 if ( (int)self::MAGIC_MARKER === $big ) {87 if ( self::MAGIC_MARKER === $big ) { 71 88 return 'N'; 72 89 } 73 90 74 91 // Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678. 75 if ( (int)self::MAGIC_MARKER === $little ) {92 if ( self::MAGIC_MARKER === $little ) { 76 93 return 'V'; 77 94 } 78 95 … … 115 132 return false; 116 133 } 117 134 118 $offsets = unpack( "{$this->uint32}rev/{$this->uint32}total/{$this->uint32}originals_addr/{$this->uint32}translations_addr/{$this->uint32}hash_length/{$this->uint32}hash_addr", $offsets ); 135 $offsets = unpack( 136 "{$this->uint32}rev/{$this->uint32}total/{$this->uint32}originals_addr/{$this->uint32}translations_addr/{$this->uint32}hash_length/{$this->uint32}hash_addr", 137 $offsets 138 ); 119 139 120 140 if ( false === $offsets ) { 121 141 return false; 122 142 } 123 143 144 // Normalize all unpacked uint32 values to prevent PHP 8.5 float warnings. 145 foreach ( $offsets as $key => $value ) { 146 $offsets[ $key ] = $this->normalize_uint32( $value ); 147 } 148 124 149 $offsets['originals_length'] = $offsets['translations_addr'] - $offsets['originals_addr']; 125 150 $offsets['translations_length'] = $offsets['hash_addr'] - $offsets['translations_addr']; 126 151 … … 146 171 continue; 147 172 } 148 173 174 // Normalize unpacked values. 175 $o['length'] = $this->normalize_uint32( $o['length'] ); 176 $o['pos'] = $this->normalize_uint32( $o['pos'] ); 177 $t['length'] = $this->normalize_uint32( $t['length'] ); 178 $t['pos'] = $this->normalize_uint32( $t['pos'] ); 179 149 180 $original = substr( $file_contents, $o['pos'], $o['length'] ); 150 181 $translation = substr( $file_contents, $t['pos'], $t['length'] ); 151 182 // GlotPress bug. … … 207 238 208 239 $file_header = pack( 209 240 $this->uint32 . '*', 210 // Force cast to an integer as it can be a float on x86 systems. See https://core.trac.wordpress.org/ticket/60678.211 241 (int) self::MAGIC_MARKER, 212 242 0, /* rev */ 213 243 $entry_count, … … 236 266 237 267 return $file_header . $o_addr . $t_addr . $o_entries . $t_entries; 238 268 } 239 } 269 } 270 No newline at end of file
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)