Merge "RC: Handle getLine returning null, which breaks Redis engine (at least HHVM)"
[lhc/web/wiklou.git] / includes / logging / ProtectLogFormatter.php
1 <?php
2 /**
3 * Formatter for protect log entries.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
22 * @since 1.26
23 */
24
25 /**
26 * This class formats protect log entries.
27 *
28 * @since 1.26
29 */
30 class ProtectLogFormatter extends LogFormatter {
31 public function getPreloadTitles() {
32 $subtype = $this->entry->getSubtype();
33 if ( $subtype === 'move_prot' ) {
34 $params = $this->extractParameters();
35 return array( Title::newFromText( $params[3] ) );
36 }
37 return array();
38 }
39
40 protected function getMessageParameters() {
41 $params = parent::getMessageParameters();
42
43 $subtype = $this->entry->getSubtype();
44 if ( $subtype === 'move_prot' ) {
45 $oldname = $this->makePageLink( Title::newFromText( $params[3] ), array( 'redirect' => 'no' ) );
46 $params[3] = Message::rawParam( $oldname );
47 }
48
49 return $params;
50 }
51
52 protected function getParametersForApi() {
53 $entry = $this->entry;
54 $params = $entry->getParameters();
55
56 static $map = array(
57 // param keys for move_prot sub type
58 '4:title:oldtitle',
59 '4::oldtitle' => '4:title:oldtitle',
60 );
61 foreach ( $map as $index => $key ) {
62 if ( isset( $params[$index] ) ) {
63 $params[$key] = $params[$index];
64 unset( $params[$index] );
65 }
66 }
67
68 return $params;
69 }
70 }