[MediaWiki-commits] [Gerrit] Move ApiWikibase::checkPermissions to ModifyEntity - change (mediawiki...Wikibase)

2015-07-05 Thread Addshore (Code Review)
Addshore has uploaded a new change for review.

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

Change subject: Move ApiWikibase::checkPermissions to ModifyEntity
..

Move ApiWikibase::checkPermissions to ModifyEntity

Apparently this is the only class that currently
uses this method, so lets put it there rather than in
this base class we would love to kill.

Change-Id: I04c9318fa9af9df10b9eb1d48c8cfc803e29023e
---
M repo/includes/api/ApiWikibase.php
M repo/includes/api/ModifyEntity.php
2 files changed, 29 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/08/222908/1

diff --git a/repo/includes/api/ApiWikibase.php 
b/repo/includes/api/ApiWikibase.php
index c05b6cc..35ea991 100644
--- a/repo/includes/api/ApiWikibase.php
+++ b/repo/includes/api/ApiWikibase.php
@@ -186,27 +186,6 @@
}
 
/**
-* Check the rights for the user accessing the module.
-*
-* @param $entity EntityDocument the entity to check
-* @param $user User doing the action
-*
-* @return Status the check's result
-* @todo: use this also to check for read access in ApiGetEntities, etc
-*/
-   protected function checkPermissions( EntityDocument $entity, User $user 
) {
-   $permissions = $this-getRequiredPermissions( $entity );
-   $status = Status::newGood();
-
-   foreach ( array_unique( $permissions ) as $perm ) {
-   $permStatus = 
$this-permissionChecker-getPermissionStatusForEntity( $user, $perm, $entity );
-   $status-merge( $permStatus );
-   }
-
-   return $status;
-   }
-
-   /**
 * @see EntitySaveHelper::loadEntityRevision
 */
protected function loadEntityRevision(
diff --git a/repo/includes/api/ModifyEntity.php 
b/repo/includes/api/ModifyEntity.php
index 965ea0b..c34efcc 100644
--- a/repo/includes/api/ModifyEntity.php
+++ b/repo/includes/api/ModifyEntity.php
@@ -8,10 +8,12 @@
 use LogicException;
 use Status;
 use UsageException;
+use User;
 use Wikibase\ChangeOp\ChangeOp;
 use Wikibase\ChangeOp\ChangeOpException;
 use Wikibase\ChangeOp\ChangeOpValidationException;
 use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityDocument;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParsingException;
 use Wikibase\DataModel\Entity\ItemId;
@@ -22,6 +24,7 @@
 use Wikibase\Lib\Store\SiteLinkLookup;
 use Wikibase\Lib\Store\StorageException;
 use Wikibase\Repo\SiteLinkTargetProvider;
+use Wikibase\Repo\Store\EntityPermissionChecker;
 use Wikibase\Repo\WikibaseRepo;
 use Wikibase\StringNormalizer;
 use Wikibase\Summary;
@@ -81,6 +84,11 @@
private $errorReporter;
 
/**
+* @var EntityPermissionChecker
+*/
+   private $permissionChecker;
+
+   /**
 * Flags to pass to EditEntity::attemptSave; use with the EDIT_XXX 
constants.
 *
 * @see EditEntity::attemptSave
@@ -113,6 +121,7 @@
$settings-getSetting( 'specialSiteLinkGroups' )
);
 
+   $this-permissionChecker = 
$wikibaseRepo-getEntityPermissionChecker();
$this-entityStore = $wikibaseRepo-getEntityStore();
$this-titleLookup = $wikibaseRepo-getEntityTitleLookup();
$this-siteLinkGroups = $settings-getSetting( 'siteLinkGroups' 
);
@@ -406,6 +415,26 @@
}
 
/**
+* Check the rights for the user accessing the module.
+*
+* @param $entity EntityDocument the entity to check
+* @param $user User doing the action
+*
+* @return Status the check's result
+*/
+   private function checkPermissions( EntityDocument $entity, User $user ) 
{
+   $permissions = $this-getRequiredPermissions( $entity );
+   $status = Status::newGood();
+
+   foreach ( array_unique( $permissions ) as $perm ) {
+   $permStatus = 
$this-permissionChecker-getPermissionStatusForEntity( $user, $perm, $entity );
+   $status-merge( $permStatus );
+   }
+
+   return $status;
+   }
+
+   /**
 * @param bool $entityIsNew
 */
protected function addFlags( $entityIsNew ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/222908
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04c9318fa9af9df10b9eb1d48c8cfc803e29023e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore addshorew...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] Move ApiWikibase::checkPermissions to ModifyEntity - change (mediawiki...Wikibase)

2015-07-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Move ApiWikibase::checkPermissions to ModifyEntity
..


Move ApiWikibase::checkPermissions to ModifyEntity

Apparently this is the only class that currently
uses this method, so lets put it there rather than in
this base class we would love to kill.

Change-Id: I04c9318fa9af9df10b9eb1d48c8cfc803e29023e
---
M repo/includes/api/ApiWikibase.php
M repo/includes/api/ModifyEntity.php
2 files changed, 29 insertions(+), 21 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/api/ApiWikibase.php 
b/repo/includes/api/ApiWikibase.php
index c05b6cc..35ea991 100644
--- a/repo/includes/api/ApiWikibase.php
+++ b/repo/includes/api/ApiWikibase.php
@@ -186,27 +186,6 @@
}
 
/**
-* Check the rights for the user accessing the module.
-*
-* @param $entity EntityDocument the entity to check
-* @param $user User doing the action
-*
-* @return Status the check's result
-* @todo: use this also to check for read access in ApiGetEntities, etc
-*/
-   protected function checkPermissions( EntityDocument $entity, User $user 
) {
-   $permissions = $this-getRequiredPermissions( $entity );
-   $status = Status::newGood();
-
-   foreach ( array_unique( $permissions ) as $perm ) {
-   $permStatus = 
$this-permissionChecker-getPermissionStatusForEntity( $user, $perm, $entity );
-   $status-merge( $permStatus );
-   }
-
-   return $status;
-   }
-
-   /**
 * @see EntitySaveHelper::loadEntityRevision
 */
protected function loadEntityRevision(
diff --git a/repo/includes/api/ModifyEntity.php 
b/repo/includes/api/ModifyEntity.php
index 965ea0b..c34efcc 100644
--- a/repo/includes/api/ModifyEntity.php
+++ b/repo/includes/api/ModifyEntity.php
@@ -8,10 +8,12 @@
 use LogicException;
 use Status;
 use UsageException;
+use User;
 use Wikibase\ChangeOp\ChangeOp;
 use Wikibase\ChangeOp\ChangeOpException;
 use Wikibase\ChangeOp\ChangeOpValidationException;
 use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityDocument;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParsingException;
 use Wikibase\DataModel\Entity\ItemId;
@@ -22,6 +24,7 @@
 use Wikibase\Lib\Store\SiteLinkLookup;
 use Wikibase\Lib\Store\StorageException;
 use Wikibase\Repo\SiteLinkTargetProvider;
+use Wikibase\Repo\Store\EntityPermissionChecker;
 use Wikibase\Repo\WikibaseRepo;
 use Wikibase\StringNormalizer;
 use Wikibase\Summary;
@@ -81,6 +84,11 @@
private $errorReporter;
 
/**
+* @var EntityPermissionChecker
+*/
+   private $permissionChecker;
+
+   /**
 * Flags to pass to EditEntity::attemptSave; use with the EDIT_XXX 
constants.
 *
 * @see EditEntity::attemptSave
@@ -113,6 +121,7 @@
$settings-getSetting( 'specialSiteLinkGroups' )
);
 
+   $this-permissionChecker = 
$wikibaseRepo-getEntityPermissionChecker();
$this-entityStore = $wikibaseRepo-getEntityStore();
$this-titleLookup = $wikibaseRepo-getEntityTitleLookup();
$this-siteLinkGroups = $settings-getSetting( 'siteLinkGroups' 
);
@@ -406,6 +415,26 @@
}
 
/**
+* Check the rights for the user accessing the module.
+*
+* @param $entity EntityDocument the entity to check
+* @param $user User doing the action
+*
+* @return Status the check's result
+*/
+   private function checkPermissions( EntityDocument $entity, User $user ) 
{
+   $permissions = $this-getRequiredPermissions( $entity );
+   $status = Status::newGood();
+
+   foreach ( array_unique( $permissions ) as $perm ) {
+   $permStatus = 
$this-permissionChecker-getPermissionStatusForEntity( $user, $perm, $entity );
+   $status-merge( $permStatus );
+   }
+
+   return $status;
+   }
+
+   /**
 * @param bool $entityIsNew
 */
protected function addFlags( $entityIsNew ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/222908
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I04c9318fa9af9df10b9eb1d48c8cfc803e29023e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore addshorew...@gmail.com
Gerrit-Reviewer: Jeroen De Dauw jeroended...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org