WikidataBuilder has uploaded a new change for review.
https://gerrit.wikimedia.org/r/132928
Change subject: New Wikidata Build - 12/05/2014 10:00
......................................................................
New Wikidata Build - 12/05/2014 10:00
Change-Id: Ia7d08192d4902320db7650eb854c71aea0a48d81
---
M composer.lock
M extensions/Wikibase/client/i18n/br.json
M extensions/Wikibase/lib/i18n/fi.json
M extensions/Wikibase/lib/i18n/mk.json
M extensions/Wikibase/repo/Wikibase.hooks.php
M extensions/Wikibase/repo/Wikibase.php
M extensions/Wikibase/repo/i18n/br.json
M extensions/Wikibase/repo/includes/WikibaseRepo.php
M extensions/Wikibase/repo/includes/content/ItemHandler.php
M extensions/Wikibase/repo/includes/specials/SpecialItemByTitle.php
M extensions/Wikibase/repo/includes/store/sql/EntityPerPageTable.php
M
extensions/Wikibase/repo/tests/phpunit/includes/specials/SpecialItemByTitleTest.php
M
extensions/Wikibase/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
M vendor/autoload.php
M vendor/composer/autoload_real.php
M vendor/composer/installed.json
16 files changed, 304 insertions(+), 122 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata
refs/changes/28/132928/1
diff --git a/composer.lock b/composer.lock
index c59bef1..dcb33d2 100644
--- a/composer.lock
+++ b/composer.lock
@@ -869,12 +869,12 @@
"source": {
"type": "git",
"url":
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git",
- "reference": "0bde25d160b68ae8e9ec2611ed6cccc66e220916"
+ "reference": "b9adc18e76be7e7c4cdc4e1db7ab1e48a555d84a"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/0bde25d160b68ae8e9ec2611ed6cccc66e220916",
- "reference": "0bde25d160b68ae8e9ec2611ed6cccc66e220916",
+ "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/b9adc18e76be7e7c4cdc4e1db7ab1e48a555d84a",
+ "reference": "b9adc18e76be7e7c4cdc4e1db7ab1e48a555d84a",
"shasum": ""
},
"require": {
@@ -937,7 +937,7 @@
"wikibaserepo",
"wikidata"
],
- "time": "2014-05-09 22:24:08"
+ "time": "2014-05-11 19:11:05"
}
],
"packages-dev": [
diff --git a/extensions/Wikibase/client/i18n/br.json
b/extensions/Wikibase/client/i18n/br.json
index 4b32d62..87527cf 100644
--- a/extensions/Wikibase/client/i18n/br.json
+++ b/extensions/Wikibase/client/i18n/br.json
@@ -8,6 +8,7 @@
]
},
"wikibase-comment-multi": "$1 {{PLURAL:$1|kemm|kemm}}",
+ "wikibase-dataitem": "Elfenn roadenn",
"wikibase-editlinks": "Kemmañ al liammoù",
"wikibase-editlinkstitle": "Kemmañ al liammoù etreyezhel",
"wikibase-linkitem-addlinks": "Ouzhpennañ liammoù",
diff --git a/extensions/Wikibase/lib/i18n/fi.json
b/extensions/Wikibase/lib/i18n/fi.json
index 0b5c4ee..88cf2b2 100644
--- a/extensions/Wikibase/lib/i18n/fi.json
+++ b/extensions/Wikibase/lib/i18n/fi.json
@@ -6,7 +6,8 @@
"Nedergard",
"Nike",
"Stryn",
- "VezonThunder"
+ "VezonThunder",
+ "Pxos"
]
},
"wikibase-lib-desc": "Sisältää Wikibase- ja Wikibase Client
-laajennuksille yhteistä toiminnallisuutta",
@@ -38,7 +39,7 @@
"wikibase-error-ui-client-error": "Yhteys asiakassivuun epäonnistui.
Yritä myöhemmin uudelleen.",
"wikibase-error-ui-no-external-page": "Määritettyä artikkelia ei
löytynyt vastaavalta sivustolta.",
"wikibase-error-ui-cant-edit": "Sinulla ei ole oikeutta suorittaa tätä
toimintoa.",
- "wikibase-error-ui-no-permissions": "Sinulla ei ole tämän toiminnon
suorittamiseen vaadittavia oikeuksia.",
+ "wikibase-error-ui-no-permissions": "Sinulla ei ole sellaisia
käyttöoikeuksia, joita tarvitaan tämän toimenpiteen suorittamiseen.",
"wikibase-error-ui-link-exists": "Et voi lisätä linkkiä tähän sivuun,
koska toisessa kohteessa on jo sama linkki.",
"wikibase-error-ui-session-failure": "Istuntosi on vanhentunut.
Kirjaudu sisään uudelleen.",
"wikibase-error-ui-edit-conflict": "Tapahtui muokkausristiriita.
Päivitä sivu ja tallenna uudelleen.",
diff --git a/extensions/Wikibase/lib/i18n/mk.json
b/extensions/Wikibase/lib/i18n/mk.json
index 96cc5bf..6a6dab3 100644
--- a/extensions/Wikibase/lib/i18n/mk.json
+++ b/extensions/Wikibase/lib/i18n/mk.json
@@ -35,7 +35,7 @@
"wikibase-error-ui-cant-edit": "Не сте овластени да ја извршите оваа
постапка.",
"wikibase-error-ui-no-permissions": "Ги немате потребните права за да
го извршите ова дејство.",
"wikibase-error-ui-link-exists": "Не можете да ставите врска за оваа
страница бидејќи веќе има друг предмет што води до неа.",
- "wikibase-error-ui-session-failure": "Сесијата истече. Најавете се
повторно.",
+ "wikibase-error-ui-session-failure": "Седницата истече. Најавете се
повторно.",
"wikibase-error-ui-edit-conflict": "Се јави спротиставеност во
уредувањата. Превчитајте и зачувајте повторно.",
"wikibase-quantitydetails-amount": "Износ",
"wikibase-quantitydetails-upperbound": "Горна граница",
diff --git a/extensions/Wikibase/repo/Wikibase.hooks.php
b/extensions/Wikibase/repo/Wikibase.hooks.php
index 3c78015..6082c32 100644
--- a/extensions/Wikibase/repo/Wikibase.hooks.php
+++ b/extensions/Wikibase/repo/Wikibase.hooks.php
@@ -1277,4 +1277,55 @@
return new PropertyHandler( $validators );
}
+ /**
+ * Helper for onAPIQuerySiteInfoStatisticsInfo
+ * @param object $row
+ * @return array
+ */
+ private static function formatDispatchRow( $row ) {
+ $data = array(
+ 'pending' => $row->chd_pending,
+ 'lag' => $row->chd_lag,
+ );
+ if ( isset( $row->chd_site ) ) {
+ $data['site'] = $row->chd_site;
+ }
+ if ( isset( $row->chd_seen ) ) {
+ $data['position'] = $row->chd_seen;
+ }
+ if ( isset( $row->chd_touched ) ) {
+ $data['touched'] = $row->chd_touched;
+ }
+
+ return $data;
+ }
+
+ /**
+ * Adds DispatchStats info to the API
+ * @param array $data
+ * @return bool
+ */
+ public static function onAPIQuerySiteInfoStatisticsInfo( array &$data )
{
+ $stats = new DispatchStats();
+ $stats->load();
+ if ( $stats->hasStats() ) {
+ $data['dispatch'] = array(
+ 'oldest' => array(
+ 'id' => $stats->getMinChangeId(),
+ 'timestamp' =>
$stats->getMinChangeTimestamp(),
+ ),
+ 'newest' => array(
+ 'id' => $stats->getMaxChangeId(),
+ 'timestamp' =>
$stats->getMaxChangeTimestamp(),
+ ),
+ 'freshest' => self::formatDispatchRow(
$stats->getFreshest() ),
+ 'median' => self::formatDispatchRow(
$stats->getMedian() ),
+ 'stalest' => self::formatDispatchRow(
$stats->getStalest() ),
+ 'average' => self::formatDispatchRow(
$stats->getAverage() ),
+ );
+ }
+
+ return true;
+ }
+
}
diff --git a/extensions/Wikibase/repo/Wikibase.php
b/extensions/Wikibase/repo/Wikibase.php
index b83aeb9..10fd985 100644
--- a/extensions/Wikibase/repo/Wikibase.php
+++ b/extensions/Wikibase/repo/Wikibase.php
@@ -180,6 +180,7 @@
$wgHooks['OutputPageBeforeHTML'][] =
'Wikibase\RepoHooks::onOutputPageBeforeHtmlRegisterConfig';
$wgHooks['MakeGlobalVariablesScript'][] =
'Wikibase\RepoHooks::onMakeGlobalVariablesScript';
$wgHooks['ContentHandlerForModelID'][] =
'Wikibase\RepoHooks::onContentHandlerForModelID';
+ $wgHooks['APIQuerySiteInfoStatisticsInfo'][] =
'Wikibase\RepoHooks::onAPIQuerySiteInfoStatisticsInfo';
// Resource Loader Modules:
$wgResourceModules = array_merge( $wgResourceModules, include( __DIR__
. "/resources/Resources.php" ) );
diff --git a/extensions/Wikibase/repo/i18n/br.json
b/extensions/Wikibase/repo/i18n/br.json
index fe6710c..f3bf854 100644
--- a/extensions/Wikibase/repo/i18n/br.json
+++ b/extensions/Wikibase/repo/i18n/br.json
@@ -20,10 +20,14 @@
"wikibase-aliases-label": "Anvet ivez :",
"wikibase-entityselector-more": "muioc'h",
"wikibase-restrictionedit-tooltip-message": "Gwarezet eo ar bajenn-mañ.
N'eo ket aotreet aozañ anezhi.",
+ "special-itembytitle": "Elfenn dre ditl",
"wikibase-itembytitle-lookup-site": "Lec'hienn :",
"wikibase-itembytitle-lookup-page": "Pajenn :",
"wikibase-itembytitle-submit": "Klask",
+ "special-itemdisambiguation": "Disheñvelout an elfennoù",
"wikibase-itemdisambiguation-lookup-language": "Yezh :",
+ "special-newproperty": "Krouiñ ur perzh nevez",
+ "special-newitem": "Krouiñ un elfenn nevez",
"wikibase-newentity-description": "Deskrivadur :",
"wikibase-newentity-submit": "Krouiñ",
"wikibase-setdescription-label": "Deskrivadur :",
diff --git a/extensions/Wikibase/repo/includes/WikibaseRepo.php
b/extensions/Wikibase/repo/includes/WikibaseRepo.php
index 80012e3..099acc3 100644
--- a/extensions/Wikibase/repo/includes/WikibaseRepo.php
+++ b/extensions/Wikibase/repo/includes/WikibaseRepo.php
@@ -5,6 +5,7 @@
use DataTypes\DataTypeFactory;
use DataValues\DataValueFactory;
use SiteSQLStore;
+use SiteStore;
use ValueFormatters\FormatterOptions;
use ValueFormatters\ValueFormatter;
use Wikibase\ChangeOp\ChangeOpFactoryProvider;
@@ -611,9 +612,9 @@
}
/**
- * @return SiteSQLStore
+ * @return SiteStore
*/
- protected function getSitesTable() {
+ public function getSiteStore() {
return SiteSQLStore::newInstance();
}
@@ -634,7 +635,7 @@
return new MessageParameterFormatter(
new DispatchingValueFormatter( $valueFormatters ),
$this->getEntityTitleLookup(),
- $this->getSitesTable(),
+ $this->getSiteStore(),
$wgLang
);
}
diff --git a/extensions/Wikibase/repo/includes/content/ItemHandler.php
b/extensions/Wikibase/repo/includes/content/ItemHandler.php
index 851d7f5..d672b6d 100644
--- a/extensions/Wikibase/repo/includes/content/ItemHandler.php
+++ b/extensions/Wikibase/repo/includes/content/ItemHandler.php
@@ -69,66 +69,6 @@
}
/**
- * Get the item corresponding to the provided site and title pair,
- * or null if there is no such item.
- *
- * @since 0.1
- *
- * @param string $siteId
- * @param string $pageName
- *
- * @return ItemContent|null
- */
- public function getContentFromSiteLink( $siteId, $pageName ) {
- $id = $this->getIdForSiteLink( $siteId, $pageName );
-
- if ( $id === null ) {
- return null;
- }
-
- return
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( $id );
- }
-
- /**
- * Get the item id for a site and page pair.
- * Returns null when there is no such pair.
- *
- * @since 0.1
- * @deprecated in 0.5, use SiteLinkLookup::getItemIdForLink instead
- *
- * @param string $siteId
- * @param string $pageName
- *
- * @return ItemId|null
- */
- public function getIdForSiteLink( $siteId, $pageName ) {
- return
StoreFactory::getStore()->newSiteLinkCache()->getItemIdForLink( $siteId,
$pageName );
- }
-
- /**
- * Get the title of the item corresponding to the provided site and
title pair,
- * or null if there is no such item.
- *
- * @since 0.3
- * @deprecated in 0.5, use SiteLinkLookup::getItemIdForLink
- * with EntityTitleLookup::getTitleForId instead
- *
- * @param string $siteId
- * @param string $pageName
- *
- * @return Title|null
- */
- public function getTitleFromSiteLink( $siteId, $pageName ) {
- $id = $this->getIdForSiteLink( $siteId, $pageName );
-
- if ( $id === null ) {
- return null;
- }
-
- return
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getTitleForId(
$id );
- }
-
- /**
* @see EntityHandler::getSpecialPageForCreation
* @since 0.2
*
diff --git a/extensions/Wikibase/repo/includes/specials/SpecialItemByTitle.php
b/extensions/Wikibase/repo/includes/specials/SpecialItemByTitle.php
index 6bd3230..b7ba2a5 100644
--- a/extensions/Wikibase/repo/includes/specials/SpecialItemByTitle.php
+++ b/extensions/Wikibase/repo/includes/specials/SpecialItemByTitle.php
@@ -1,11 +1,13 @@
<?php
namespace Wikibase\Repo\Specials;
-use ContentHandler;
use Html;
use Site;
+use SiteStore;
+use Wikibase\EntityTitleLookup;
use Wikibase\ItemHandler;
use Wikibase\Repo\WikibaseRepo;
+use Wikibase\SiteLinkLookup;
/**
* Enables accessing items by providing the identifier of a site and the title
@@ -14,8 +16,36 @@
* @since 0.1
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
+ * @author Daniel Kinzler
*/
class SpecialItemByTitle extends SpecialItemResolver {
+
+ /**
+ * @var EntityTitleLookup
+ */
+ private $titleLookup;
+
+ /**
+ * @var SiteStore
+ */
+ private $sites;
+
+ /**
+ * @var SiteLinkLookup
+ */
+ private $siteLinkLookup;
+
+ /**
+ * @var bool
+ */
+ private $normalizeItemByTitlePageNames;
+
+ /**
+ * site link groups
+ *
+ * @var string[]
+ */
+ private $groups;
/**
* Constructor.
@@ -27,6 +57,52 @@
public function __construct() {
// args $name, $restriction, $listed
parent::__construct( 'ItemByTitle', '', true );
+
+ $settings = WikibaseRepo::getDefaultInstance()->getSettings();
+
+ $this->initSettings(
+ $settings->getSetting( 'normalizeItemByTitlePageNames'
),
+ $settings->getSetting( 'siteLinkGroups' )
+ );
+
+ $this->initServices(
+
WikibaseRepo::getDefaultInstance()->getEntityTitleLookup(),
+ WikibaseRepo::getDefaultInstance()->getSiteStore(),
+
WikibaseRepo::getDefaultInstance()->getStore()->newSiteLinkCache()
+ );
+ }
+
+ /**
+ * Initialize essential settings for this special page.
+ * may be used by unit tests to override global settings.
+ *
+ * @param $normalizeItemByTitlePageNames
+ * @param $siteLinkGroups
+ */
+ public function initSettings(
+ $normalizeItemByTitlePageNames,
+ $siteLinkGroups
+ ) {
+ $this->normalizeItemByTitlePageNames =
$normalizeItemByTitlePageNames;
+ $this->groups = $siteLinkGroups;
+ }
+
+ /**
+ * Initialize the services used be this special page.
+ * May be used to inject mock services for testing.
+ *
+ * @param EntityTitleLookup $titleLookup
+ * @param SiteStore $siteStore
+ * @param SiteLinkLookup $siteLinkLookup
+ */
+ public function initServices(
+ EntityTitleLookup $titleLookup,
+ SiteStore $siteStore,
+ SiteLinkLookup $siteLinkLookup
+ ) {
+ $this->titleLookup = $titleLookup;
+ $this->sites = $siteStore;
+ $this->siteLinkLookup = $siteLinkLookup;
}
/**
@@ -51,7 +127,7 @@
$siteId = $this->stringNormalizer->trimToNFC( $site );
// no stripping of underscores here!
$pageName = $this->stringNormalizer->trimToNFC( $page );
- if ( !\Sites::singleton()->getSite( $siteId ) ) {
+ if ( !$this->sites->getSite( $siteId ) ) {
// HACK: If the site ID isn't known, add "wiki"
to it; this allows the wikipedia
// subdomains to be used to refer to
wikipedias, instead of requiring their
// full global id to be used.
@@ -62,25 +138,22 @@
}
/* @var ItemHandler $itemHandler */
- $itemHandler = ContentHandler::getForModelID(
CONTENT_MODEL_WIKIBASE_ITEM );
- $itemContent = $itemHandler->getContentFromSiteLink(
$siteId, $pageName );
-
- $normalizeItemByTitlePageNames =
WikibaseRepo::getDefaultInstance()->
- getSettings()->getSetting(
'normalizeItemByTitlePageNames' );
+ $itemId = $this->siteLinkLookup->getItemIdForLink(
$siteId, $pageName );
// Do we have an item content, and if not can we try
harder?
- if ( $itemContent === null &&
$normalizeItemByTitlePageNames === true ) {
+ if ( $itemId === null &&
$this->normalizeItemByTitlePageNames === true ) {
// Try harder by requesting normalization on
the external site
- $siteObj =
\SiteSQLStore::newInstance()->getSite( $siteId );
+ $siteObj = $this->sites->getSite( $siteId );
if ( $siteObj instanceof Site ) {
$pageName =
$siteObj->normalizePageName( $page );
- $itemContent =
$itemHandler->getContentFromSiteLink( $siteId, $pageName );
+ $itemId =
$this->siteLinkLookup->getItemIdForLink( $siteId, $pageName );
}
}
// Redirect to the item page if we found its content
- if ( $itemContent !== null ) {
- $itemUrl =
$itemContent->getTitle()->getFullUrl();
+ if ( $itemId !== null ) {
+ $title = $this->titleLookup->getTitleForId(
$itemId );
+ $itemUrl = $title->getFullUrl();
$this->getOutput()->redirect( $itemUrl );
return;
}
@@ -100,13 +173,9 @@
*/
protected function switchForm( $siteId, $page ) {
- $groups = WikibaseRepo::getDefaultInstance()->
- getSettings()->getSetting( 'siteLinkGroups' );
- $sites = \SiteSQLStore::newInstance()->getSites();
-
- if ( $sites->hasSite( $siteId ) ) {
- $site = $sites->getSite( $siteId );
- $siteExists = in_array( $site->getGroup(), $groups );
+ if ( $this->sites->getSites()->hasSite( $siteId ) ) {
+ $site = $this->sites->getSite( $siteId );
+ $siteExists = in_array( $site->getGroup(),
$this->groups );
} else {
$siteExists = false;
}
@@ -188,5 +257,4 @@
}
}
-
}
diff --git a/extensions/Wikibase/repo/includes/store/sql/EntityPerPageTable.php
b/extensions/Wikibase/repo/includes/store/sql/EntityPerPageTable.php
index 7170de5..8eceab1 100644
--- a/extensions/Wikibase/repo/includes/store/sql/EntityPerPageTable.php
+++ b/extensions/Wikibase/repo/includes/store/sql/EntityPerPageTable.php
@@ -3,7 +3,6 @@
namespace Wikibase;
use InvalidArgumentException;
-use Iterator;
use Wikibase\DataModel\Entity\BasicEntityIdParser;
use Wikibase\DataModel\Entity\ItemId;
@@ -245,10 +244,16 @@
public function listEntities( $entityType, $limit, EntityId $after =
null ) {
if ( $entityType == null ) {
$where = array();
+ //NOTE: needs to be id/type, not type/id, according to
the definition of the relevant
+ // index in wikibase.sql: wb_entity_per_page
(epp_entity_id, epp_entity_type);
+ $orderBy = array( 'epp_entity_id', 'epp_entity_type' );
} elseif ( !is_string( $entityType ) ) {
throw new InvalidArgumentException( '$entityType must
be a string (or null)' );
} else {
$where = array( 'epp_entity_type' => $entityType );
+ // NOTE: If the type is fixed, don't use the type in
the order;
+ // before changing this, check index usage.
+ $orderBy = array( 'epp_entity_id' );
}
if ( !is_int( $limit ) || $limit < 1 ) {
@@ -260,9 +265,10 @@
if ( $after ) {
if ( $entityType === null ) {
// Ugly. About time we switch to qualified,
string based IDs!
- $where[] = '( ( epp_entity_type = ' .
$dbr->addQuotes( $after->getEntityType() ) .
- 'AND epp_entity_id > ' .
$after->getNumericId() . ' ) ' .
- ' OR epp_entity_type > ' .
$dbr->addQuotes( $after->getEntityType() ) . ' )';
+ // NOTE: this must be consistent with the sort
order, see above!
+ $where[] = '( ( epp_entity_type > ' .
$dbr->addQuotes( $after->getEntityType() ) .
+ 'AND epp_entity_id = ' .
$after->getNumericId() . ' ) ' .
+ ' OR epp_entity_id > ' .
$after->getNumericId() . ' )';
} else {
$where[] = 'epp_entity_id > ' .
$after->getNumericId();
}
@@ -274,7 +280,7 @@
$where,
__METHOD__,
array(
- 'ORDER BY' => array( 'epp_entity_type',
'epp_entity_id' ),
+ 'ORDER BY' => $orderBy,
'LIMIT' => $limit
)
);
diff --git
a/extensions/Wikibase/repo/tests/phpunit/includes/specials/SpecialItemByTitleTest.php
b/extensions/Wikibase/repo/tests/phpunit/includes/specials/SpecialItemByTitleTest.php
index 7938322..399b913 100644
---
a/extensions/Wikibase/repo/tests/phpunit/includes/specials/SpecialItemByTitleTest.php
+++
b/extensions/Wikibase/repo/tests/phpunit/includes/specials/SpecialItemByTitleTest.php
@@ -2,7 +2,15 @@
namespace Wikibase\Test;
+use FauxResponse;
+use Site;
+use SiteStore;
+use Title;
+use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\EntityTitleLookup;
use Wikibase\Repo\Specials\SpecialItemByTitle;
+use Wikibase\SiteLinkLookup;
/**
* @covers Wikibase\Repo\Specials\SpecialItemByTitle
@@ -16,32 +24,110 @@
* ^---- needed because we rely on Title objects internally
*
* @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
* @author Daniel Kinzler
- * @author Adam Shorland
*/
class SpecialItemByTitleTest extends SpecialPageTestBase {
- protected function newSpecialPage() {
- return new SpecialItemByTitle();
+ /**
+ * @return EntityTitleLookup
+ */
+ private function getMockTitleLookup() {
+ $mock = $this->getMock( 'Wikibase\EntityTitleLookup' );
+ $mock->expects( $this->any() )
+ ->method( 'getTitleForId' )
+ ->will( $this->returnCallback(
+ function ( EntityId $id ) {
+ return Title::makeTitle( NS_MAIN,
$id->getSerialization() );
+ }
+ ) );
+
+ return $mock;
}
- public function testExecute() {
- //TODO: Verify that more of the output is correct.
+ /**
+ * @return SiteLinkLookup
+ */
+ private function getMockSiteLinkLookup() {
+ $entityId = new ItemId( 'Q123' );
+
+ $mock = $this->getMock( '\Wikibase\SiteLinkLookup' );
+
+ $mock->expects( $this->any() )
+ ->method( 'getItemIdForLink' )
+ ->will( $this->returnCallback(
+ function ( $siteId, $pageName ) use ( $entityId
) {
+ return ( $siteId === 'dewiki' ) ?
$entityId : null;
+ }
+ ) );
+
+ return $mock;
+ }
+
+ /**
+ * @return SiteStore
+ */
+ private function getMockSiteStore() {
+ $getSite = function ( $siteId ) {
+ $site = new Site();
+ $site->setGlobalId( $siteId );
+ $site->setLinkPath( "http://$siteId.com/$1" );
+ return $site;
+ };
+
+ $mockSiteList = $this->getMock( 'SiteList' );
+ $mockSiteList->expects( $this->any() )
+ ->method( 'getSite' )
+ ->will( $this->returnCallback( $getSite ) );
+
+ $mock = $this->getMock( 'SiteStore' );
+ $mock->expects( $this->any() )
+ ->method( 'getSite' )
+ ->will( $this->returnCallback( $getSite ) );
+
+ $mock->expects( $this->any() )
+ ->method( 'getSites' )
+ ->will( $this->returnValue( $mockSiteList ) );
+
+ return $mock;
+ }
+
+ /**
+ * @return SpecialItemByTitle
+ */
+ protected function newSpecialPage() {
+ $page = new SpecialItemByTitle();
+
+ $page->initSettings(
+ true,
+ array( 'wikipedia' )
+ );
+
+ $page->initServices(
+ $this->getMockTitleLookup(),
+ $this->getMockSiteStore(),
+ $this->getMockSiteLinkLookup()
+ );
+
+ return $page;
+ }
+
+ public function requestProvider() {
+ $cases = array();
+ $matchers = array();
$matchers['site'] = array(
'tag' => 'input',
'attributes' => array(
'id' => 'wb-itembytitle-sitename',
'name' => 'site',
- ) );
+ ) );
$matchers['page'] = array(
'tag' => 'input',
'attributes' => array(
'id' => 'pagename',
'class' => 'wb-input-text',
'name' => 'page',
- ) );
+ ) );
$matchers['submit'] = array(
'tag' => 'input',
'attributes' => array(
@@ -49,16 +135,39 @@
'class' => 'wb-input-button',
'type' => 'submit',
'name' => 'submit',
- ) );
+ ) );
- list( $output, ) = $this->executeSpecialPage( '' );
- foreach( $matchers as $key => $matcher ) {
- $this->assertTag( $matcher, $output, "Failed to match
html output with tag '{$key}''" );
+ $cases['empty'] = array( '', null, $matchers );
+
+ // enwiki/NotFound (mock returns null for everything but
dewiki)
+ $matchers['site']['attributes']['value'] = 'enwiki';
+ $matchers['page']['attributes']['value'] = 'NotFound';
+
+ $cases['enwiki/NotFound'] = array( 'enwiki/NotFound', null,
$matchers );
+
+ // dewiki/Gefunden (mock returns Q123 for dewiki)
+ $matchers = array();
+
+ $cases['dewiki/Gefunden'] = array( 'dewiki/Gefunden', 'Q123',
$matchers );
+
+ return $cases;
+ }
+
+ /**
+ * @dataProvider requestProvider
+ *
+ * @param $sub
+ * @param $target
+ * @param $matchers
+ */
+ public function testExecute( $sub, $target, $matchers ) {
+ /* @var FauxResponse $response */
+ list( $output, $response ) = $this->executeSpecialPage( $sub );
+
+ if ( $target !== null ) {
+ $target = Title::newFromText( $target );
+ $this->assertEquals( $target->getFullURL(),
$response->getheader( 'Location' ), 'Redirect' );
}
-
- list( $output, ) = $this->executeSpecialPage(
'SiteText/PageText' );
- $matchers['site']['attributes']['value'] = 'SiteText';
- $matchers['page']['attributes']['value'] = 'PageText';
foreach( $matchers as $key => $matcher ) {
$this->assertTag( $matcher, $output, "Failed to match
html output with tag '{$key}''" );
diff --git
a/extensions/Wikibase/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
b/extensions/Wikibase/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
index acf79c1..73dc203 100644
---
a/extensions/Wikibase/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
+++
b/extensions/Wikibase/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
@@ -106,7 +106,7 @@
$expectedIds = $this->getIdStrings( $expected );
$actualIds = $this->getIdStrings( $actual );
- $this->assertArrayEquals( $expectedIds, $actualIds, $msg );
+ $this->assertArrayEquals( $expectedIds, $actualIds, false );
}
/**
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 25cf840..b4fbe36 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
-return ComposerAutoloaderInitf82899569e5001c1e2867d6eeeee90cc::getLoader();
+return ComposerAutoloaderInitea2ae508816499e08df28f6705f1a7c7::getLoader();
diff --git a/vendor/composer/autoload_real.php
b/vendor/composer/autoload_real.php
index 8027099..9b67684 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInitf82899569e5001c1e2867d6eeeee90cc
+class ComposerAutoloaderInitea2ae508816499e08df28f6705f1a7c7
{
private static $loader;
@@ -19,9 +19,9 @@
return self::$loader;
}
-
spl_autoload_register(array('ComposerAutoloaderInitf82899569e5001c1e2867d6eeeee90cc',
'loadClassLoader'), true, true);
+
spl_autoload_register(array('ComposerAutoloaderInitea2ae508816499e08df28f6705f1a7c7',
'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
-
spl_autoload_unregister(array('ComposerAutoloaderInitf82899569e5001c1e2867d6eeeee90cc',
'loadClassLoader'));
+
spl_autoload_unregister(array('ComposerAutoloaderInitea2ae508816499e08df28f6705f1a7c7',
'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
@@ -45,14 +45,14 @@
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
- composerRequiref82899569e5001c1e2867d6eeeee90cc($file);
+ composerRequireea2ae508816499e08df28f6705f1a7c7($file);
}
return $loader;
}
}
-function composerRequiref82899569e5001c1e2867d6eeeee90cc($file)
+function composerRequireea2ae508816499e08df28f6705f1a7c7($file)
{
require $file;
}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index f4fd8a5..bab1f4d 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -896,12 +896,12 @@
"source": {
"type": "git",
"url":
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git",
- "reference": "0bde25d160b68ae8e9ec2611ed6cccc66e220916"
+ "reference": "b9adc18e76be7e7c4cdc4e1db7ab1e48a555d84a"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/0bde25d160b68ae8e9ec2611ed6cccc66e220916",
- "reference": "0bde25d160b68ae8e9ec2611ed6cccc66e220916",
+ "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/b9adc18e76be7e7c4cdc4e1db7ab1e48a555d84a",
+ "reference": "b9adc18e76be7e7c4cdc4e1db7ab1e48a555d84a",
"shasum": ""
},
"require": {
@@ -924,7 +924,7 @@
"conflict": {
"mediawiki/mediawiki": "<1.23"
},
- "time": "2014-05-09 22:24:08",
+ "time": "2014-05-11 19:11:05",
"type": "mediawiki-extension",
"installation-source": "dist",
"autoload": {
--
To view, visit https://gerrit.wikimedia.org/r/132928
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7d08192d4902320db7650eb854c71aea0a48d81
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata
Gerrit-Branch: master
Gerrit-Owner: WikidataBuilder <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits