From 471637c571d5fc53b28ceb3887ed26dad971e897 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 18 Jan 2016 17:18:19 -0500 Subject: [PATCH] When serializing Message, don't try to unstub StubUserLang If the serialization is happening during PHP shutdown due to a Session save, it can fatal because $wgLang is already gone. Change-Id: I7d877be15ef8639f3b94b74bba763053ec289358 --- includes/Message.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/Message.php b/includes/Message.php index 54efd261b65..c71a9534985 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -271,7 +271,7 @@ class Message implements MessageSpecifier, Serializable { public function serialize() { return serialize( array( 'interface' => $this->interface, - 'language' => $this->language->getCode(), + 'language' => $this->language instanceof StubUserLang ? false : $this->language->getCode(), 'key' => $this->key, 'keysToTry' => $this->keysToTry, 'parameters' => $this->parameters, @@ -287,6 +287,8 @@ class Message implements MessageSpecifier, Serializable { * @param string $serialized */ public function unserialize( $serialized ) { + global $wgLang; + $data = unserialize( $serialized ); $this->interface = $data['interface']; $this->key = $data['key']; @@ -294,7 +296,7 @@ class Message implements MessageSpecifier, Serializable { $this->parameters = $data['parameters']; $this->format = $data['format']; $this->useDatabase = $data['useDatabase']; - $this->language = Language::factory( $data['language'] ); + $this->language = $data['language'] ? Language::factory( $data['language'] ) : $wgLang; $this->title = $data['title']; } -- 2.11.4.GIT