WordPress.org

Make WordPress Core

Changeset 28472


Ignore:
Timestamp:
05/17/2014 05:20:26 PM (7 years ago)
Author:
wonderboymusic
Message:

Eliminate the use of extract() in MO::import_from_reader().

See #22400.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pomo/mo.php

    r22349 r28472  
    156156            return false;
    157157
    158         extract( $header );
    159 
    160158        // support revision 0 of MO format specs, only
    161         if ($revision != 0)
    162             return false;
     159        if ( $header['revision'] != 0 ) {
     160            return false;
     161        }
    163162
    164163        // seek to data blocks
    165         $reader->seekto($originals_lenghts_addr);
     164        $reader->seekto( $header['originals_lenghts_addr'] );
    166165
    167166        // read originals' indices
    168         $originals_lengths_length = $translations_lenghts_addr - $originals_lenghts_addr;
    169         if ( $originals_lengths_length != $total * 8 )
    170             return false;
     167        $originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr'];
     168        if ( $originals_lengths_length != $header['total'] * 8 ) {
     169            return false;
     170        }
    171171
    172172        $originals = $reader->read($originals_lengths_length);
    173         if ( $reader->strlen( $originals ) != $originals_lengths_length )
    174             return false;
     173        if ( $reader->strlen( $originals ) != $originals_lengths_length ) {
     174            return false;
     175        }
    175176
    176177        // read translations' indices
    177         $translations_lenghts_length = $hash_addr - $translations_lenghts_addr;
    178         if ( $translations_lenghts_length != $total * 8 )
    179             return false;
     178        $translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr'];
     179        if ( $translations_lenghts_length != $header['total'] * 8 ) {
     180            return false;
     181        }
    180182
    181183        $translations = $reader->read($translations_lenghts_length);
    182         if ( $reader->strlen( $translations ) != $translations_lenghts_length )
    183             return false;
     184        if ( $reader->strlen( $translations ) != $translations_lenghts_length ) {
     185            return false;
     186        }
    184187
    185188        // transform raw data into set of indices
     
    188191
    189192        // skip hash table
    190         $strings_addr = $hash_addr + $hash_length * 4;
     193        $strings_addr = $header['hash_addr'] + $header['hash_length'] * 4;
    191194
    192195        $reader->seekto($strings_addr);
     
    195198        $reader->close();
    196199
    197         for ( $i = 0; $i < $total; $i++ ) {
     200        for ( $i = 0; $i < $header['total']; $i++ ) {
    198201            $o = unpack( "{$endian}length/{$endian}pos", $originals[$i] );
    199202            $t = unpack( "{$endian}length/{$endian}pos", $translations[$i] );
Note: See TracChangeset for help on using the changeset viewer.