WordPress.org

Make WordPress Core

Ticket #21319: 21319-refreshed.patch

File 21319-refreshed.patch, 1.9 KB (added by jrf, 6 years ago)

Patch refreshed against current master

  • src/wp-includes/l10n.php

    From 3f03e8fcf9de4b90d204985fe14490467e4a275d Mon Sep 17 00:00:00 2001
    From: jrfnl <github_nospam@adviesenzo.nl>
    Date: Wed, 13 Jan 2016 14:18:02 +0100
    Subject: [PATCH] Refresh of @nacin's patch and @MikeHansenMe's unit tests.
    
    ---
     src/wp-includes/l10n.php     | 11 ++++++++---
     tests/phpunit/tests/l10n.php | 12 ++++++++++++
     2 files changed, 20 insertions(+), 3 deletions(-)
    
    diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php
    index a69a718..8f340fc 100644
    a b function load_child_theme_textdomain( $domain, $path = false ) { 
    793793 */
    794794function get_translations_for_domain( $domain ) {
    795795        global $l10n;
    796         if ( !isset( $l10n[$domain] ) ) {
    797                 $l10n[$domain] = new NOOP_Translations;
     796        if ( isset( $l10n[ $domain ] ) ) {
     797                return $l10n[ $domain ];
    798798        }
    799         return $l10n[$domain];
     799
     800        static $noop_translations;
     801        if ( ! $noop_translations ) {
     802                $noop_translations = new NOOP_Translations;
     803        }
     804        return $noop_translations;
    800805}
    801806
    802807/**
  • tests/phpunit/tests/l10n.php

    diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php
    index 62357f0..d6bc011 100644
    a b class Tests_L10n extends WP_UnitTestCase { 
    1818        }
    1919
    2020        /**
     21         * @ticket 21319
     22         */
     23        function test_is_textdomain_loaded_for_no_translations() {
     24                $this->assertFalse( load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ) );
     25                $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
     26                $this->assertInstanceOf( 'NOOP_Translations', get_translations_for_domain( 'wp-tests-domain' ) );
     27                // Ensure that we don't confuse NOOP_Translations to be a loaded text domain.
     28                $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
     29                $this->assertFalse( unload_textdomain( 'wp-tests-domain' ) );
     30        }
     31
     32        /**
    2133         * @ticket 35073
    2234         */
    2335        function test_before_last_bar() {