r95642 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95641‎ | r95642 | r95643 >
Date:01:56, 29 August 2011
Author:johnduhart
Status:ok (Comments)
Tags:
Comment:
Making revision states, protected states, and flags configurable
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -239,6 +239,39 @@
240240 */
241241 $wgCodeReviewRepoStatsCacheTime = 6 * 60 * 60; // 6 Hours
242242
 243+/**
 244+ * Possible states a revision can be in
 245+ *
 246+ * A system message will still needed to be added as code-status-<state>
 247+ */
 248+$wgCodeReviewStates = array(
 249+ 'new',
 250+ 'fixme',
 251+ 'reverted',
 252+ 'resolved',
 253+ 'ok',
 254+ 'deferred',
 255+ 'old',
 256+);
 257+
 258+/**
 259+ * Revisions states that a user cannot change to on their own revision
 260+ */
 261+$wgProtectedStates = array(
 262+ 'ok',
 263+ 'resolved',
 264+);
 265+
 266+/**
 267+ * List of all flags a user can mark themself as having done to a revision
 268+ *
 269+ * A system message will still needed to be added as code-signoff-flag-<flag>
 270+ */
 271+$wgCodeReviewFlags = array(
 272+ 'inspected',
 273+ 'tested',
 274+);
 275+
243276 # Schema changes
244277 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates';
245278
Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -244,10 +244,20 @@
245245 * @return Array
246246 */
247247 public static function getPossibleStates() {
248 - return array( 'new', 'fixme', 'reverted', 'resolved', 'ok', 'deferred', 'old' );
 248+ global $wgCodeReviewStates;
 249+ return $wgCodeReviewStates;
249250 }
250251
251252 /**
 253+ * List of all states that a user cannot set on their own revision
 254+ * @return Array
 255+ */
 256+ public static function getProtectedStates() {
 257+ global $wgProtectedStates;
 258+ return $wgProtectedStates;
 259+ }
 260+
 261+ /**
252262 * @return array
253263 */
254264 public static function getPossibleStateMessageKeys() {
@@ -267,7 +277,8 @@
268278 * @return Array
269279 */
270280 public static function getPossibleFlags() {
271 - return array( 'inspected', 'tested' );
 281+ global $wgCodeReviewFlags;
 282+ return $wgCodeReviewFlags;
272283 }
273284
274285 /**
@@ -280,6 +291,15 @@
281292 }
282293
283294 /**
 295+ * Returns whether the provided status is protected
 296+ * @param String $status
 297+ * @return bool
 298+ */
 299+ public static function isProtectedStatus( $status ) {
 300+ return in_array( $status, self::getProtectedStates(), true );
 301+ }
 302+
 303+ /**
284304 * @throws MWException
285305 * @param $status String, value in CodeRevision::getPossibleStates
286306 * @param $user User
@@ -293,7 +313,7 @@
294314 // Don't allow the user account tied to the committer account mark their own revisions as ok/resolved
295315 // Obviously only works if user accounts are tied!
296316 $wikiUser = $this->getWikiUser();
297 - if ( ( $status == 'ok' || $status == 'resolved' ) && $wikiUser && $user->getName() == $wikiUser->getName() ) {
 317+ if ( self::isProtectedStatus( $status ) && $wikiUser && $user->getName() == $wikiUser->getName() ) {
298318 // allow the user to review their own code if required
299319 if ( !$wikiUser->isAllowed( 'codereview-review-own' ) ) {
300320 return false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r95643Followup r95642, forgot to prefix the protected state variables with CodeReviewjohnduhart01:58, 29 August 2011
r95644Followup r95642, messages are added to RL before they can be customizedjohnduhart02:24, 29 August 2011

Comments

#Comment by Reedy (talk | contribs)   22:06, 29 August 2011
+ * A system message will still needed to be added as code-status-<state>

And css in a few different cases...

And code-status-desc-<state> message...

This is then going to require editing of core files. Which is icky (granted, CSS can be done onwiki).

#Comment by Johnduhart (talk | contribs)   06:35, 31 August 2011

Really? Besides CSS what core files need to be edited?

#Comment by Reedy (talk | contribs)   11:26, 31 August 2011

Does magically first creating new i18n messages onwiki actually work? (without said message being defined in the i18n file)

#Comment by Catrope (talk | contribs)   11:31, 31 August 2011

Yes, that works for me on trunk at least.

#Comment by Siebrand (talk | contribs)   11:35, 31 August 2011

I think that has worked for forever.

#Comment by 😂 (talk | contribs)   15:12, 23 September 2011

I'm not really sure why these need to be configurable?

#Comment by Johnduhart (talk | contribs)   22:18, 29 September 2011

It's probably not needed here in the WMF, however some other groups use the extension and would rather it be configurable instead of having to modify core files.

Status & tagging log