From 508ee26e5e8661a0035639d4b405588f451665a4 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 28 Nov 2018 10:23:12 -0500 Subject: [PATCH] Message: Don't include Title objects in the serialization (part 1) Stringify the title instead. This will help avoid running into the PHP/HHVM serialization incompatibility described in T210528. This is part 1: start stringifying and using the string, but continue storing the Title object for the benefit of mixed environments where some servers still only handle a Title object. Bug: T210528 Change-Id: I07aac3aab2d4e27a7203f4e4fb3ce1b5d86c517c --- includes/Message.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/Message.php b/includes/Message.php index 3bd775537f..f9d1cce206 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -290,6 +290,7 @@ class Message implements MessageSpecifier, Serializable { 'format' => $this->format, 'useDatabase' => $this->useDatabase, 'title' => $this->title, + 'titlestr' => $this->title ? $this->title->getFullText() : null, ] ); } @@ -307,7 +308,15 @@ class Message implements MessageSpecifier, Serializable { $this->format = $data['format']; $this->useDatabase = $data['useDatabase']; $this->language = $data['language'] ? Language::factory( $data['language'] ) : false; - $this->title = $data['title']; + + if ( isset( $data['titlestr'] ) ) { + $this->title = Title::newFromText( $data['titlestr'] ); + } elseif ( isset( $data['title'] ) && $data['title'] instanceof Title ) { + // Old serializations from before December 2018 + $this->title = $data['title']; + } else { + $this->title = null; // Explicit for sanity + } } /** -- 2.20.1