[MediaWiki-commits] [Gerrit] Always throw TermLookupException in EntityInfoTermLookup - change (mediawiki...Wikibase)

2015-09-10 Thread Aude (Code Review)
Aude has uploaded a new change for review.

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

Change subject: Always throw TermLookupException in EntityInfoTermLookup
..

Always throw TermLookupException in EntityInfoTermLookup

Have the getLabel and getDescription methods delegate
to getLabels and getDescriptions, which handles the
OutOfBoundsException and then throws TermLookupException.

@todo add tests for this

Bug: T112003
Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
---
M lib/includes/store/EntityInfoTermLookup.php
1 file changed, 16 insertions(+), 16 deletions(-)


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

diff --git a/lib/includes/store/EntityInfoTermLookup.php 
b/lib/includes/store/EntityInfoTermLookup.php
index 951acf7..8feb0db 100644
--- a/lib/includes/store/EntityInfoTermLookup.php
+++ b/lib/includes/store/EntityInfoTermLookup.php
@@ -42,24 +42,24 @@
 * @return string|null
 */
public function getLabel( EntityId $entityId, $languageCode ) {
-   try {
-   return $this->entityInfo->getLabel( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
-   }
+   return $this->getLabels( $entityId, array( $languageCode ) );
}
 
/**
 * Gets all labels of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getLabels( EntityId $entityId, array $languages ) {
-   return $this->entityInfo->getLabels( $entityId, $languages );
+   public function getLabels( EntityId $entityId, array $languageCodes ) {
+   try {
+   return $this->entityInfo->getLabels( $entityId, 
$languageCodes );
+   } catch ( \OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
/**
@@ -72,24 +72,24 @@
 * @return string|null
 */
public function getDescription( EntityId $entityId, $languageCode ) {
-   try {
-   return $this->entityInfo->getDescription( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
-   }
+   return $this->getDescription( $entityId, array( $languageCode ) 
);
}
 
/**
 * Gets all descriptions of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getDescriptions( EntityId $entityId, array $languages ) 
{
-   return $this->entityInfo->getDescriptions( $entityId, 
$languages );
+   public function getDescriptions( EntityId $entityId, array 
$languageCodes ) {
+   try {
+   return $this->entityInfo->getDescriptions( $entityId, 
$languageCodes );
+   } catch ( \OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Always throw TermLookupException in EntityInfoTermLookup - change (mediawiki...Wikibase)

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

Change subject: Always throw TermLookupException in EntityInfoTermLookup
..


Always throw TermLookupException in EntityInfoTermLookup

Also fix wrong exception in LabelDescriptionLookup mock

(squashed https://gerrit.wikimedia.org/r/#/c/237374/ from Thiemo)

Bug: T112003
Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
---
M lib/includes/store/EntityInfoTermLookup.php
M lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
M lib/tests/phpunit/store/EntityInfoTermLookupTest.php
3 files changed, 39 insertions(+), 15 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  Daniel Kinzler: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/lib/includes/store/EntityInfoTermLookup.php 
b/lib/includes/store/EntityInfoTermLookup.php
index 951acf7..6e69318 100644
--- a/lib/includes/store/EntityInfoTermLookup.php
+++ b/lib/includes/store/EntityInfoTermLookup.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Lib\Store;
 
+use OutOfBoundsException;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Services\Lookup\TermLookup;
 use Wikibase\DataModel\Services\Lookup\TermLookupException;
@@ -44,8 +45,13 @@
public function getLabel( EntityId $entityId, $languageCode ) {
try {
return $this->entityInfo->getLabel( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException(
+   $entityId,
+   array( $languageCode ),
+   $ex->getMessage(),
+   $ex
+   );
}
}
 
@@ -53,13 +59,17 @@
 * Gets all labels of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getLabels( EntityId $entityId, array $languages ) {
-   return $this->entityInfo->getLabels( $entityId, $languages );
+   public function getLabels( EntityId $entityId, array $languageCodes ) {
+   try {
+   return $this->entityInfo->getLabels( $entityId, 
$languageCodes );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
/**
@@ -74,8 +84,13 @@
public function getDescription( EntityId $entityId, $languageCode ) {
try {
return $this->entityInfo->getDescription( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException(
+   $entityId,
+   array( $languageCode ),
+   $ex->getMessage(),
+   $ex
+   );
}
}
 
@@ -83,13 +98,17 @@
 * Gets all descriptions of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getDescriptions( EntityId $entityId, array $languages ) 
{
-   return $this->entityInfo->getDescriptions( $entityId, 
$languages );
+   public function getDescriptions( EntityId $entityId, array 
$languageCodes ) {
+   try {
+   return $this->entityInfo->getDescriptions( $entityId, 
$languageCodes );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
 }
diff --git a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php 
b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
index 2cc061d..b6d19ce 100644
--- a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
@@ -2,11 +2,12 @@
 
 namespace Wikibase\Lib\Test;
 
-use OutOfBoundsException;
+use MediaWikiTestCase;
 use Title;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\ItemId;
 

[MediaWiki-commits] [Gerrit] Always throw TermLookupException in EntityInfoTermLookup - change (mediawiki...Wikibase)

2015-09-10 Thread Aude (Code Review)
Aude has uploaded a new change for review.

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

Change subject: Always throw TermLookupException in EntityInfoTermLookup
..

Always throw TermLookupException in EntityInfoTermLookup

Also fix wrong exception in LabelDescriptionLookup mock

(squashed https://gerrit.wikimedia.org/r/#/c/237374/ from Thiemo)

Bug: T112003
Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
---
M lib/includes/store/EntityInfoTermLookup.php
M lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
M lib/tests/phpunit/store/EntityInfoTermLookupTest.php
3 files changed, 39 insertions(+), 15 deletions(-)


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

diff --git a/lib/includes/store/EntityInfoTermLookup.php 
b/lib/includes/store/EntityInfoTermLookup.php
index 951acf7..6e69318 100644
--- a/lib/includes/store/EntityInfoTermLookup.php
+++ b/lib/includes/store/EntityInfoTermLookup.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Lib\Store;
 
+use OutOfBoundsException;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Services\Lookup\TermLookup;
 use Wikibase\DataModel\Services\Lookup\TermLookupException;
@@ -44,8 +45,13 @@
public function getLabel( EntityId $entityId, $languageCode ) {
try {
return $this->entityInfo->getLabel( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException(
+   $entityId,
+   array( $languageCode ),
+   $ex->getMessage(),
+   $ex
+   );
}
}
 
@@ -53,13 +59,17 @@
 * Gets all labels of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getLabels( EntityId $entityId, array $languages ) {
-   return $this->entityInfo->getLabels( $entityId, $languages );
+   public function getLabels( EntityId $entityId, array $languageCodes ) {
+   try {
+   return $this->entityInfo->getLabels( $entityId, 
$languageCodes );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
/**
@@ -74,8 +84,13 @@
public function getDescription( EntityId $entityId, $languageCode ) {
try {
return $this->entityInfo->getDescription( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException(
+   $entityId,
+   array( $languageCode ),
+   $ex->getMessage(),
+   $ex
+   );
}
}
 
@@ -83,13 +98,17 @@
 * Gets all descriptions of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getDescriptions( EntityId $entityId, array $languages ) 
{
-   return $this->entityInfo->getDescriptions( $entityId, 
$languages );
+   public function getDescriptions( EntityId $entityId, array 
$languageCodes ) {
+   try {
+   return $this->entityInfo->getDescriptions( $entityId, 
$languageCodes );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
 }
diff --git a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php 
b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
index 2cc061d..b6d19ce 100644
--- a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
@@ -2,11 +2,12 @@
 
 namespace Wikibase\Lib\Test;
 
-use OutOfBoundsException;
+use MediaWikiTestCase;
 use Title;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\ItemId;
 use 

[MediaWiki-commits] [Gerrit] Always throw TermLookupException in EntityInfoTermLookup - change (mediawiki...Wikibase)

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

Change subject: Always throw TermLookupException in EntityInfoTermLookup
..


Always throw TermLookupException in EntityInfoTermLookup

Also fix wrong exception in LabelDescriptionLookup mock

(squashed https://gerrit.wikimedia.org/r/#/c/237374/ from Thiemo)

Bug: T112003
Change-Id: Iff176d6ac834ca6138425e47ae0d101e436b276b
---
M lib/includes/store/EntityInfoTermLookup.php
M lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
M lib/tests/phpunit/store/EntityInfoTermLookupTest.php
3 files changed, 39 insertions(+), 15 deletions(-)

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



diff --git a/lib/includes/store/EntityInfoTermLookup.php 
b/lib/includes/store/EntityInfoTermLookup.php
index 951acf7..6e69318 100644
--- a/lib/includes/store/EntityInfoTermLookup.php
+++ b/lib/includes/store/EntityInfoTermLookup.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Lib\Store;
 
+use OutOfBoundsException;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Services\Lookup\TermLookup;
 use Wikibase\DataModel\Services\Lookup\TermLookupException;
@@ -44,8 +45,13 @@
public function getLabel( EntityId $entityId, $languageCode ) {
try {
return $this->entityInfo->getLabel( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException(
+   $entityId,
+   array( $languageCode ),
+   $ex->getMessage(),
+   $ex
+   );
}
}
 
@@ -53,13 +59,17 @@
 * Gets all labels of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getLabels( EntityId $entityId, array $languages ) {
-   return $this->entityInfo->getLabels( $entityId, $languages );
+   public function getLabels( EntityId $entityId, array $languageCodes ) {
+   try {
+   return $this->entityInfo->getLabels( $entityId, 
$languageCodes );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
/**
@@ -74,8 +84,13 @@
public function getDescription( EntityId $entityId, $languageCode ) {
try {
return $this->entityInfo->getDescription( $entityId, 
$languageCode );
-   } catch ( \OutOfBoundsException $ex ) {
-   throw new TermLookupException( $entityId, array( 
$languageCode ), $ex->getMessage(), $ex );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException(
+   $entityId,
+   array( $languageCode ),
+   $ex->getMessage(),
+   $ex
+   );
}
}
 
@@ -83,13 +98,17 @@
 * Gets all descriptions of an Entity with the specified EntityId.
 *
 * @param EntityId $entityId
-* @param string[] $languages
+* @param string[] $languageCodes
 *
 * @throws TermLookupException
 * @return string[]
 */
-   public function getDescriptions( EntityId $entityId, array $languages ) 
{
-   return $this->entityInfo->getDescriptions( $entityId, 
$languages );
+   public function getDescriptions( EntityId $entityId, array 
$languageCodes ) {
+   try {
+   return $this->entityInfo->getDescriptions( $entityId, 
$languageCodes );
+   } catch ( OutOfBoundsException $ex ) {
+   throw new TermLookupException( $entityId, 
$languageCodes, $ex->getMessage(), $ex );
+   }
}
 
 }
diff --git a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php 
b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
index 2cc061d..b6d19ce 100644
--- a/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdHtmlLinkFormatterTest.php
@@ -2,11 +2,12 @@
 
 namespace Wikibase\Lib\Test;
 
-use OutOfBoundsException;
+use MediaWikiTestCase;
 use Title;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\ItemId;
 use