Make WordPress Core


Ignore:
Timestamp:
05/16/2016 03:09:33 PM (8 years ago)
Author:
ocean90
Message:

I18N: In get_translations_for_domain() check if the global $l10n was set by _load_textdomain_just_in_time() before accessing it.

Props danielhuesken.
Fixes #34114.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php

    r37415 r37440  
    5959        $is_textdomain_loaded_after  = is_textdomain_loaded( 'internationalized-plugin' );
    6060
     61        unload_textdomain( 'internationalized-plugin' );
    6162        remove_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
    6263
     
    8081        $is_textdomain_loaded_after  = is_textdomain_loaded( 'internationalized-theme' );
    8182
     83        unload_textdomain( 'internationalized-theme' );
    8284        remove_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
    8385
     
    8688        $this->assertTrue( $is_textdomain_loaded_after );
    8789    }
     90
     91    /**
     92     * @ticket 341142
     93     */
     94    public function test_get_translations_for_domain_does_not_return_null_if_override_load_textdomain_is_used() {
     95        add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
     96        add_filter( 'override_load_textdomain', '__return_true' );
     97        $translations = get_translations_for_domain( 'internationalized-plugin' );
     98        remove_filter( 'override_load_textdomain', '__return_true' );
     99        remove_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
     100
     101        $this->assertTrue( $translations instanceof NOOP_Translations );
     102    }
    88103}
Note: See TracChangeset for help on using the changeset viewer.