Daniel Kinzler has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/337188 )

Change subject: Provide meaningful error when accessing $wgLang prematurely.
......................................................................

Provide meaningful error when accessing $wgLang prematurely.

Change-Id: I147f0b13eccd248bffdbb6ac0f5b5d25fb0f3641
---
M client/includes/WikibaseClient.php
M repo/includes/WikibaseRepo.php
2 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/88/337188/1

diff --git a/client/includes/WikibaseClient.php 
b/client/includes/WikibaseClient.php
index 2681b08..3f7d7e8 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -634,6 +634,11 @@
                // NOTE: we cannot inject $wgContLang in the constructor, 
because it may still be null
                // when WikibaseClient is initialized. In particular, the 
language object may not yet
                // be there when the SetupAfterCache hook is run during 
bootstrapping.
+
+               if ( !$wgContLang ) {
+                       throw new MWException( 'Premature access: $wgContLang 
is not yet initialized!' );
+               }
+
                StubObject::unstub( $wgContLang );
                return $wgContLang;
        }
@@ -648,6 +653,11 @@
                // NOTE: we cannot inject $wgLang in the constructor, because 
it may still be null
                // when WikibaseClient is initialized. In particular, the 
language object may not yet
                // be there when the SetupAfterCache hook is run during 
bootstrapping.
+
+               if ( !$wgLang ) {
+                       throw new MWException( 'Premature access: $wgLang is 
not yet initialized!' );
+               }
+
                StubObject::unstub( $wgLang );
                return $wgLang;
        }
diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index a55c03d..ee8ce12 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -522,6 +522,11 @@
                // NOTE: we cannot inject $wgContLang in the constructor, 
because it may still be null
                // when WikibaseRepo is initialized. In particular, the 
language object may not yet
                // be there when the SetupAfterCache hook is run during 
bootstrapping.
+
+               if ( !$wgContLang ) {
+                       throw new MWException( 'Premature access: $wgContLang 
is not yet initialized!' );
+               }
+
                StubObject::unstub( $wgContLang );
                return $wgContLang;
        }
@@ -536,6 +541,11 @@
                // NOTE: we cannot inject $wgLang in the constructor, because 
it may still be null
                // when WikibaseRepo is initialized. In particular, the 
language object may not yet
                // be there when the SetupAfterCache hook is run during 
bootstrapping.
+
+               if ( !$wgLang ) {
+                       throw new MWException( 'Premature access: $wgLang is 
not yet initialized!' );
+               }
+
                StubObject::unstub( $wgLang );
                return $wgLang;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/337188
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I147f0b13eccd248bffdbb6ac0f5b5d25fb0f3641
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to