[MediaWiki-commits] [Gerrit] Don't propagate permissions to older revisions - change (mediawiki...Flow)

2014-02-14 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Don't propagate permissions to older revisions
..


Don't propagate permissions to older revisions

Revisions are meant to be a standalone snapshot in time.
Instead of propagating changes in permissions, we should look at the
most recent revision to fetch the current revision state.
Otherwise, we lose track of history. E.g. we can't know if a certain
revision is/was suppressed and should be hidden from sight, if at a
later point, a later revision got restored.

Change-Id: I14f3ecc30cd003e40df110116a44474b6f424ecd
---
M Hooks.php
M includes/Block/Topic.php
M includes/Log/PostModerationLogger.php
M includes/Model/AbstractRevision.php
M includes/Model/Header.php
5 files changed, 25 insertions(+), 79 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Hooks.php b/Hooks.php
index 896de24..f1599a1 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -287,7 +287,7 @@
 * @return bool
 */
public static function onUserGetReservedNames( $names ) {
-   $permissions = array_keys( Flow\Model\AbstractRevision::$perms 
);
+   $permissions = Flow\Model\AbstractRevision::$perms;
foreach ( $permissions as $permission ) {
$names[] = msg:flow-$permission-usertext;
}
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 095c011..f649010 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -30,7 +30,6 @@
protected $topicTitle;
protected $rootLoader;
protected $newRevision;
-   protected $relatedRevisions = array();
protected $notification;
protected $requestedPost = array();
 
@@ -273,11 +272,7 @@
 
$reason = $this-submitted['reason'];
 
-   if ( $post-needsModerateHistorical( $newState ) ) {
-   $this-relatedRevisions = $this-loadHistorical( $post 
);
-   }
-
-   $this-newRevision = $post-moderate( $this-user, $newState, 
$action, $reason, $this-relatedRevisions );
+   $this-newRevision = $post-moderate( $this-user, $newState, 
$action, $reason );
if ( !$this-newRevision ) {
$this-addError( 'moderate', wfMessage( 
'flow-error-not-allowed' ) );
return;
@@ -358,10 +353,6 @@
 
$this-storage-put( $this-newRevision );
$this-storage-put( $this-workflow );
-   // These are moderated historical revisions of 
$this-newRevision
-   foreach ( $this-relatedRevisions as $revision ) {
-   $this-storage-put( $revision );
-   }
$self = $this;
$newRevision = $this-newRevision;
$rootPost = $this-loadRootPost();
diff --git a/includes/Log/PostModerationLogger.php 
b/includes/Log/PostModerationLogger.php
index 4a56234..1b4cb34 100644
--- a/includes/Log/PostModerationLogger.php
+++ b/includes/Log/PostModerationLogger.php
@@ -60,7 +60,7 @@
 
if ( ! $changeTypes ) {
$changeTypes = array();
-   foreach( AbstractRevision::$perms as $perm = $info ) {
+   foreach( AbstractRevision::$perms as $perm ) {
if ( $perm != '' ) {
$changeTypes[] = {$perm}-topic;
$changeTypes[] = {$perm}-post;
diff --git a/includes/Model/AbstractRevision.php 
b/includes/Model/AbstractRevision.php
index b49c53d..f471296 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -18,26 +18,15 @@
const MODERATED_SUPPRESSED = 'suppress';
 
/**
-* Metadata relatied to moderation states from least restrictive
-* to most restrictive.
+* List of available permission levels.
+*
+* @var array
 **/
static public $perms = array(
-   self::MODERATED_NONE = array(
-   // Whether or not to apply transition to this 
moderation state to historical revisions
-   'historical' = true,
-   ),
-   self::MODERATED_HIDDEN = array(
-   // Whether or not to apply transition to this 
moderation state to historical revisions
-   'historical' = false,
-   ),
-   self::MODERATED_DELETED = array(
-   // Whether or not to apply transition to this 
moderation state to historical revisions
-   'historical' = true,
-   ),
-   self::MODERATED_SUPPRESSED = array(
-   // Whether or not to 

[MediaWiki-commits] [Gerrit] Don't propagate permissions to older revisions - change (mediawiki...Flow)

2014-02-07 Thread Matthias Mullie (Code Review)
Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/112042

Change subject: Don't propagate permissions to older revisions
..

Don't propagate permissions to older revisions

Revisions are meant to be a standalone snapshot in time.
Instead of propagating changes in permissions, we should look at the
most recent revision to fetch the current revision state.
Otherwise, we lose track of history. E.g. we can't know if a certain
revision is/was suppressed and should be hidden from sight, if at a
later point, a later revision got restored.

Change-Id: I14f3ecc30cd003e40df110116a44474b6f424ecd
---
M Hooks.php
M includes/Block/Topic.php
M includes/Log/PostModerationLogger.php
M includes/Model/AbstractRevision.php
M includes/Model/Header.php
5 files changed, 25 insertions(+), 79 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/42/112042/1

diff --git a/Hooks.php b/Hooks.php
index b63f64f..0fa8b2c 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -268,7 +268,7 @@
 * @return bool
 */
public static function onUserGetReservedNames( $names ) {
-   $permissions = array_keys( Flow\Model\AbstractRevision::$perms 
);
+   $permissions = Flow\Model\AbstractRevision::$perms;
foreach ( $permissions as $permission ) {
$names[] = msg:flow-$permission-usertext;
}
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 2796220..77923dc 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -30,7 +30,6 @@
protected $topicTitle;
protected $rootLoader;
protected $newRevision;
-   protected $relatedRevisions = array();
protected $notification;
protected $requestedPost = array();
 
@@ -286,11 +285,7 @@
 
$reason = $this-submitted['reason'];
 
-   if ( $post-needsModerateHistorical( $newState ) ) {
-   $this-relatedRevisions = $this-loadHistorical( $post 
);
-   }
-
-   $this-newRevision = $post-moderate( $this-user, $newState, 
$action, $reason, $this-relatedRevisions );
+   $this-newRevision = $post-moderate( $this-user, $newState, 
$action, $reason );
if ( !$this-newRevision ) {
$this-addError( 'moderate', wfMessage( 
'flow-error-not-allowed' ) );
return;
@@ -376,10 +371,6 @@
}
$this-storage-put( $this-newRevision );
$this-storage-put( $this-workflow );
-   // These are moderated historical revisions of 
$this-newRevision
-   foreach ( $this-relatedRevisions as $revision ) {
-   $this-storage-put( $revision );
-   }
$self = $this;
$newRevision = $this-newRevision;
$rootPost = $this-loadRootPost();
diff --git a/includes/Log/PostModerationLogger.php 
b/includes/Log/PostModerationLogger.php
index 4a56234..1b4cb34 100644
--- a/includes/Log/PostModerationLogger.php
+++ b/includes/Log/PostModerationLogger.php
@@ -60,7 +60,7 @@
 
if ( ! $changeTypes ) {
$changeTypes = array();
-   foreach( AbstractRevision::$perms as $perm = $info ) {
+   foreach( AbstractRevision::$perms as $perm ) {
if ( $perm != '' ) {
$changeTypes[] = {$perm}-topic;
$changeTypes[] = {$perm}-post;
diff --git a/includes/Model/AbstractRevision.php 
b/includes/Model/AbstractRevision.php
index b3af131..0942bac 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -18,26 +18,15 @@
const MODERATED_SUPPRESSED = 'suppress';
 
/**
-* Metadata relatied to moderation states from least restrictive
-* to most restrictive.
+* List of available permission levels.
+*
+* @var array
 **/
static public $perms = array(
-   self::MODERATED_NONE = array(
-   // Whether or not to apply transition to this 
moderation state to historical revisions
-   'historical' = true,
-   ),
-   self::MODERATED_HIDDEN = array(
-   // Whether or not to apply transition to this 
moderation state to historical revisions
-   'historical' = false,
-   ),
-   self::MODERATED_DELETED = array(
-   // Whether or not to apply transition to this 
moderation state to historical revisions
-   'historical' = true,
-   ),
-