MediaWiki r110567 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r110566‎ | r110567 (on ViewVC)‎ | r110568 >
Date:14:10, 2 February 2012
Author:jeroendedauw
Status:deferred
Tags:educationprogram, nodeploy 
Comment:
kill 1.18 compat code
Modified paths:

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -29,8 +29,8 @@
3030 die( 'Not an entry point.' );
3131 }
3232
33 -if ( version_compare( $wgVersion, '1.18c', '<' ) ) { // Needs to be 1.18c because version_compare() works in confusing ways.
34 - die( '<b>Error:</b> Education Program requires MediaWiki 1.18 or above.' );
 33+if ( version_compare( $wgVersion, '1.19c', '<' ) ) { // Needs to be 1.19c because version_compare() works in confusing ways.
 34+ die( '<b>Error:</b> Education Program requires MediaWiki 1.19 or above.' );
3535 }
3636
3737 if ( !array_key_exists( 'CountryNames', $wgAutoloadClasses ) ) { // No version constant to check against :/
@@ -177,45 +177,12 @@
178178 $wgLogTypes[] = 'campus';
179179 $wgLogTypes[] = 'instructor';
180180
181 -if ( array_key_exists( 'LogFormatter', $wgAutoloadLocalClasses ) ) {
182 - $wgLogActionsHandlers['institution/*'] = 'EPLogFormatter';
183 - $wgLogActionsHandlers['course/*'] = 'EPLogFormatter';
184 - $wgLogActionsHandlers['student/*'] = 'EPLogFormatter';
185 - $wgLogActionsHandlers['online/*'] = 'EPLogFormatter';
186 - $wgLogActionsHandlers['campus/*'] = 'EPLogFormatter';
187 - $wgLogActionsHandlers['instructor/*'] = 'EPLogFormatter';
188 -}
189 -else {
190 - // Compatibility with MediaWiki 1.18.
191 - foreach ( array( 'institution', 'course' ) as $type ) {
192 - foreach ( array( 'add', 'remove', 'update' ) as $action ) {
193 - $wgLogActionsHandlers[$type . '/' . $action] = 'EPHooks::formatLogEntry';
194 - }
195 - }
196 -
197 - foreach ( array( 'instructor', 'ambassador' ) as $type ) {
198 - foreach ( array( 'add', 'remove', 'selfadd', 'selfremove' ) as $action ) {
199 - $wgLogActionsHandlers[$type . '/' . $action] = 'EPHooks::formatLogEntry';
200 - }
201 - }
202 -
203 - $wgLogActionsHandlers['student/enroll'] = 'EPHooks::formatLogEntry';
204 - $wgLogActionsHandlers['student/remove'] = 'EPHooks::formatLogEntry';
205 -
206 - // Compatibility with MediaWiki 1.18.
207 - $wgLogNames['institution'] = 'log-name-institution';
208 - $wgLogNames['course'] = 'log-name-course';
209 - $wgLogNames['student'] = 'log-name-student';
210 - $wgLogNames['ambassador'] = 'log-name-ambassador';
211 - $wgLogNames['instructor'] = 'log-name-instructor';
212 -
213 - // Compatibility with MediaWiki 1.18.
214 - $wgLogHeaders['institution'] = 'log-header-institution';
215 - $wgLogHeaders['course'] = 'log-header-course';
216 - $wgLogHeaders['student'] = 'log-header-student';
217 - $wgLogHeaders['ambassador'] = 'log-header-ambassador';
218 - $wgLogHeaders['instructor'] = 'log-header-instructor';
219 -}
 181+$wgLogActionsHandlers['institution/*'] = 'EPLogFormatter';
 182+$wgLogActionsHandlers['course/*'] = 'EPLogFormatter';
 183+$wgLogActionsHandlers['student/*'] = 'EPLogFormatter';
 184+$wgLogActionsHandlers['online/*'] = 'EPLogFormatter';
 185+$wgLogActionsHandlers['campus/*'] = 'EPLogFormatter';
 186+$wgLogActionsHandlers['instructor/*'] = 'EPLogFormatter';
220187
221188 // Rights
222189 $wgAvailableRights[] = 'ep-org'; // Manage orgs
Index: trunk/extensions/EducationProgram/includes/EPUtils.php
@@ -25,35 +25,21 @@
2626 $user = array_key_exists( 'user', $info ) ? $info['user'] : $GLOBALS['wgUser'];
2727
2828 if ( $info !== false ) {
29 - if ( class_exists( 'ManualLogEntry' ) ) {
30 - $logEntry = new ManualLogEntry( $info['type'], $info['subtype'] );
 29+ $logEntry = new ManualLogEntry( $info['type'], $info['subtype'] );
3130
32 - $logEntry->setPerformer( $user );
33 - $logEntry->setTarget( $info['title'] );
34 -
35 - if ( array_key_exists( 'comment', $info ) ) {
36 - $logEntry->setComment( $info['comment'] );
37 - }
38 -
39 - if ( array_key_exists( 'parameters', $info ) ) {
40 - $logEntry->setParameters( $info['parameters'] );
41 - }
42 -
43 - $logid = $logEntry->insert();
44 - $logEntry->publish( $logid );
 31+ $logEntry->setPerformer( $user );
 32+ $logEntry->setTarget( $info['title'] );
 33+
 34+ if ( array_key_exists( 'comment', $info ) ) {
 35+ $logEntry->setComment( $info['comment'] );
4536 }
46 - else {
47 - // Compatibility with MediaWiki 1.18.
48 - $log = new LogPage( $info['type'] );
49 -
50 - $log->addEntry(
51 - $info['subtype'],
52 - $info['title'],
53 - array_key_exists( 'comment', $info ) ? $info['comment'] : '',
54 - array_key_exists( 'parameters', $info ) ? $info['parameters'] : array(),
55 - $user
56 - );
 37+
 38+ if ( array_key_exists( 'parameters', $info ) ) {
 39+ $logEntry->setParameters( $info['parameters'] );
5740 }
 41+
 42+ $logid = $logEntry->insert();
 43+ $logEntry->publish( $logid );
5844 }
5945 }
6046
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -116,39 +116,6 @@
117117 }
118118
119119 /**
120 - * Handles formatting of log entries for MediaWiki 1.18.x.
121 - *
122 - * @since 0.1
123 - *
124 - * @param string $type
125 - * @param string $action
126 - * @param Title $title
127 - * @param boolean|null $forUI
128 - * @param array $params
129 - *
130 - * @return string
131 - */
132 - public static function formatLogEntry( $type, $action, Title $title, $forUI, array $params ) {
133 - global $wgContLang, $wgLang;
134 -
135 - $message = wfMessage( 'logentry-' . $type . '-' . $action );
136 -
137 - $message = call_user_func_array(
138 - array( $message, 'params' ),
139 - array_merge(
140 - array(
141 - '', // User link in the new system
142 - '#', // User name for gender in the new system
143 - Message::rawParam( $forUI ? Linker::link( $title ) : $title->getPrefixedText() )
144 - ),
145 - $params
146 - )
147 - );
148 -
149 - return $message->inLanguage( $forUI === null ? $wgContLang : $wgLang )->text();
150 - }
151 -
152 - /**
153120 * Called to determine the class to handle the article rendering, based on title.
154121 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleFromTitle
155122 *

Status & tagging log

  • 18:58, 2 February 2012 Reedy (Talk | contribs) changed the status of r110567 [removed: new added: deferred]
  • 14:46, 2 February 2012 MarkAHershberger (Talk | contribs) changed the tags for r110567 [added: educationprogram,nodeploy]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox