[MediaWiki-commits] [Gerrit] Fixed typos in documentation - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Fixed typos in documentation .. Fixed typos in documentation Change-Id: Idea478299a023c2a4d4b58479842d0ff0d4f11b7 --- M lib/includes/store/EntityLookup.php 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved Nikerabbit: Looks good to me, approved jenkins-bot: Checked diff --git a/lib/includes/store/EntityLookup.php b/lib/includes/store/EntityLookup.php index 2856e19..f61b21b 100644 --- a/lib/includes/store/EntityLookup.php +++ b/lib/includes/store/EntityLookup.php @@ -32,9 +32,9 @@ interface EntityLookup { /** -* Returns the entity with the provided id or null is there is no such +* Returns the entity with the provided id or null if there is no such * entity. If a $revision is given, the requested revision of the entity is loaded. -* The the revision does not belong to the given entity, null is returned. +* If the revision does not belong to the given entity, null is returned. * * @since 0.3 * -- To view, visit https://gerrit.wikimedia.org/r/55032 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idea478299a023c2a4d4b58479842d0ff0d4f11b7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Nikerabbit Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add timeout and options to MediaWikiSite::normalizePageName - change (mediawiki/core)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/55056 Change subject: Add timeout and options to MediaWikiSite::normalizePageName .. Add timeout and options to MediaWikiSite::normalizePageName In some cases it can be necessary to manipulate the timeout and options to get a better and more predictable behavior. Change-Id: I0a1d807155a1381715afc241b65d53cd7afd4b7a --- M includes/site/MediaWikiSite.php 1 file changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/56/55056/1 diff --git a/includes/site/MediaWikiSite.php b/includes/site/MediaWikiSite.php index 0509272..51a13b3 100644 --- a/includes/site/MediaWikiSite.php +++ b/includes/site/MediaWikiSite.php @@ -90,11 +90,13 @@ * @since 1.21 * * @param string $pageName +* @param string $timeout +* @param array $options * * @return string * @throws MWException */ - public function normalizePageName( $pageName ) { + public function normalizePageName( $pageName, $timeout = 'default', $options = array() ) { // Check if we have strings as arguments. if ( !is_string( $pageName ) ) { @@ -133,8 +135,7 @@ $url = $this->getFileUrl( 'api.php' ) . '?' . wfArrayToCgi( $args ); // Go on call the external site - //@todo: we need a good way to specify a timeout here. - $ret = Http::get( $url ); + $ret = Http::get( $url, timeout, $options ); } if ( $ret === false ) { -- To view, visit https://gerrit.wikimedia.org/r/55056 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a1d807155a1381715afc241b65d53cd7afd4b7a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix example links in API - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/55083 Change subject: Fix example links in API .. Fix example links in API Some of the API links uses an old style prefix-less id. This type of id was deprecated and unsupported a long time ago. Change-Id: Ib86599ee068a13a3a66e61f5f52ee2a27937858d --- M repo/includes/api/SetDescription.php M repo/includes/api/SetLabel.php M repo/includes/api/SetSiteLink.php 3 files changed, 8 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/83/55083/1 diff --git a/repo/includes/api/SetDescription.php b/repo/includes/api/SetDescription.php index ffa76a2..16ef254 100644 --- a/repo/includes/api/SetDescription.php +++ b/repo/includes/api/SetDescription.php @@ -81,8 +81,8 @@ */ protected function getExamples() { return array( - 'api.php?action=wbsetdescription&id=42&language=en&value=An%20encyclopedia%20that%20everyone%20can%20edit' - => 'Set the string "An encyclopedia that everyone can edit" for page with id "42" as a decription in English language', + 'api.php?action=wbsetdescription&id=Q42&language=en&value=An%20encyclopedia%20that%20everyone%20can%20edit' + => 'Set the string "An encyclopedia that everyone can edit" for page with id "Q42" as a decription in English language', ); } diff --git a/repo/includes/api/SetLabel.php b/repo/includes/api/SetLabel.php index 9cfe93a..97ee0a7 100644 --- a/repo/includes/api/SetLabel.php +++ b/repo/includes/api/SetLabel.php @@ -80,8 +80,8 @@ */ protected function getExamples() { return array( - 'api.php?action=wbsetlabel&id=42&language=en&value=Wikimedia&format=jsonfm' - => 'Set the string "Wikimedia" for page with id "42" as a label in English language and report it as pretty printed json', + 'api.php?action=wbsetlabel&id=Q42&language=en&value=Wikimedia&format=jsonfm' + => 'Set the string "Wikimedia" for page with id "Q42" as a label in English language and report it as pretty printed json', ); } diff --git a/repo/includes/api/SetSiteLink.php b/repo/includes/api/SetSiteLink.php index b5ccc73..5a5ec4b 100644 --- a/repo/includes/api/SetSiteLink.php +++ b/repo/includes/api/SetSiteLink.php @@ -197,10 +197,10 @@ */ protected function getExamples() { return array( - 'api.php?action=wbsetsitelink&id=42&linksite=enwiki&linktitle=Wikimedia' - => 'Add title "Wikimedia" for English page with id "42" if the site link does not exist', - 'api.php?action=wbsetsitelink&id=42&linksite=enwiki&linktitle=Wikimedia&summary=World%20domination%20will%20be%20mine%20soon!' - => 'Add title "Wikimedia" for English page with id "42", if the site link does not exist', + 'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Wikimedia' + => 'Add title "Wikimedia" for English page with id "Q42" if the site link does not exist', + 'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Wikimedia&summary=World%20domination%20will%20be%20mine%20soon!' + => 'Add title "Wikimedia" for English page with id "Q42", if the site link does not exist', ); } -- To view, visit https://gerrit.wikimedia.org/r/55083 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib86599ee068a13a3a66e61f5f52ee2a27937858d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix NamespaceChecker so it return correct results - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/55089 Change subject: Fix NamespaceChecker so it return correct results .. Fix NamespaceChecker so it return correct results Change-Id: I079d906f53ec48cdcc1b11cfbea757c02d989a8a --- M client/WikibaseClient.hooks.php M client/includes/NamespaceChecker.php M client/tests/phpunit/includes/NamespaceCheckerTest.php 3 files changed, 60 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/89/55089/1 diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index 6891b31..702c78a 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -82,10 +82,12 @@ 'includes/ChangeHandler', 'includes/RepoLinker', 'includes/EntityCacheUpdater', + 'includes/NamespaceChecker', 'includes/api/ApiClientInfo', 'includes/store/EntityCacheTable', + ); foreach ( $testFiles as $file ) { diff --git a/client/includes/NamespaceChecker.php b/client/includes/NamespaceChecker.php index 4d00d8a..bba1fcc 100644 --- a/client/includes/NamespaceChecker.php +++ b/client/includes/NamespaceChecker.php @@ -26,11 +26,18 @@ * * @licence GNU GPL v2+ * @author Katie Filbert < aude.w...@gmail.com > + * @author John Erling Blad < jeb...@gmail.com > */ class NamespaceChecker { + /** +* @var array +*/ protected $excludedNamespaces; + /** +* @var array +*/ protected $enabledNamespaces; /** @@ -41,10 +48,15 @@ * * @throws \MWException */ - public function __construct( array $excludedNamespaces, array $enabledNamespaces ) { + public function __construct( array $excludedNamespaces, array $enabledNamespaces = null, array $defaultNamespaces = null ) { $this->excludedNamespaces = $excludedNamespaces; - - $this->enabledNamespaces = $enabledNamespaces; + $this->enabledNamespaces = array_filter( + isset( $defaultNamespaces ) ? $defaultNamespaces : array(), + function ( $ns ) { + return $ns % 2 === 0; + } + ); + $this->enabledNamespaces = array_unique( array_merge( $this->enabledNamespaces, $enabledNamespaces ) ); } /** @@ -127,4 +139,15 @@ return $this->excludedNamespaces; } + /** +* Get valid namespaces +* +* @since 0.4 +* +* @return array|bool +*/ + public function getValidNamespaces() { + return array_diff( $this->enabledNamespaces, $this->excludedNamespaces ); + } + } diff --git a/client/tests/phpunit/includes/NamespaceCheckerTest.php b/client/tests/phpunit/includes/NamespaceCheckerTest.php index 5bde35d..a883fae 100644 --- a/client/tests/phpunit/includes/NamespaceCheckerTest.php +++ b/client/tests/phpunit/includes/NamespaceCheckerTest.php @@ -27,6 +27,7 @@ * @ingroup Test * * @group WikibaseClient + * @group NamespaceCheckerTest * * @licence GNU GPL v2+ * @author Katie Filbert < aude.w...@gmail.com > @@ -35,28 +36,46 @@ public function constructorProvider() { return array( - array( array(), array( NS_MAIN ) ), - array( array( NS_USER_TALK ), array() ) + array( array(), array(), array(), null ), // #0 + array( array( NS_MAIN ), array(), array( NS_MAIN ), null ), // #1 + array( array(), array( NS_USER_TALK ), array(), null ), // #2 + array( array( NS_MAIN ), array( NS_USER_TALK ), array( NS_MAIN ), null ), // #3 + array( array( NS_MAIN ), array(), array( NS_MAIN ), array( NS_MAIN ) ), // #4 + array( array( NS_MAIN ), array(), array(), array( NS_MAIN ) ), // #5 + array( array( NS_USER, NS_MAIN ), array(), array( NS_MAIN ), array( NS_USER ) ), // #6, order will be reversed + array( array( NS_MAIN, NS_USER ), array(), array( NS_MAIN ), array( NS_MAIN, NS_USER ) ), // #7 + array( array( NS_MAIN ), array( NS_USER ), array( NS_MAIN ), array( NS_MAIN, NS_USER ) ), // #8 + array( array( NS_MAIN ), array( NS_USER ), array( NS_MAIN ), array( NS_MAIN, NS_TALK, NS_USER, NS_USER_TALK ) ), // #9 ); } /** * @dataProvider constructorProvider */ - public function testConstructor( array $excluded, array $enabled ) { - $namespaceChecker = new Na
[MediaWiki-commits] [Gerrit] (bug 45998) introducing Special:DispatchStats - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (bug 45998) introducing Special:DispatchStats .. (bug 45998) introducing Special:DispatchStats This adds a special page that shows statistics about the current status of change propagation to client wikis. Change-Id: Ief1f66b969015789cbca8061878ff039452701e2 --- M repo/Wikibase.i18n.alias.php M repo/Wikibase.i18n.php M repo/Wikibase.php A repo/includes/specials/SpecialDispatchStats.php A repo/includes/store/sql/DispatchStats.php A repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php 6 files changed, 928 insertions(+), 12 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/Wikibase.i18n.alias.php b/repo/Wikibase.i18n.alias.php index 209bd49..2b09438 100644 --- a/repo/Wikibase.i18n.alias.php +++ b/repo/Wikibase.i18n.alias.php @@ -16,6 +16,7 @@ /** English (English) */ $specialPageAliases['en'] = array( + 'DispatchStats' => array( 'DispatchStats' ), 'EntityData' => array( 'EntityData' ), 'NewItem' => array( 'NewItem', 'CreateItem' ), 'NewProperty' => array( 'NewProperty', 'CreateProperty' ), diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index e75677a..fc5fd2c 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -169,6 +169,22 @@ 'wikibase-setentity-language' => 'Language:', 'wikibase-setentity-invalid-langcode' => 'The language identifier "$1" is unknown. Please use a language identifier known to the system, such as "en".', 'wikibase-setentity-invalid-id' => 'The ID "$1" is unknown to the system. Please use a valid entity ID.', + 'special-dispatchstats' => 'Change dispatch statistics', + 'wikibase-dispatchstats-intro' => 'This page provides statistics about change dispatching to the clients.', + 'wikibase-dispatchstats-no-stats' => 'There are currently no statistics available.', + 'wikibase-dispatchstats-changes' => 'Change Log Statistics', + 'wikibase-dispatchstats-stats' => 'Dispatch Statistics', + 'wikibase-dispatchstats-change-id' => 'ID', + 'wikibase-dispatchstats-change-timestamp' => 'Timestamp', + 'wikibase-dispatchstats-oldest-change' => 'Oldest', + 'wikibase-dispatchstats-newest-change' => 'Newest', + 'wikibase-dispatchstats-site-id' => 'Site', + 'wikibase-dispatchstats-lag-num' => 'Pending', + 'wikibase-dispatchstats-lag-time' => 'Lag', + 'wikibase-dispatchstats-freshest' => 'Freshest', + 'wikibase-dispatchstats-stalest' => 'Stalest', + 'wikibase-dispatchstats-median' => 'Median', + 'wikibase-dispatchstats-average' => 'Average', 'special-listdatatypes' => 'List of all datatypes available', 'wikibase-listdatatypes-intro' => 'This is a list of all datatypes currently in use on this installation:', 'wikibase-history-title-with-label' => 'Revision history of "$2" ($1)', @@ -679,6 +695,22 @@ "language identifier" is the same as "language code".', 'wikibase-setentity-invalid-id' => 'Response informing that the selected entity ID is not valid. $1 is the invalid ID.', + 'special-dispatchstats' => 'This special page shows statistics about the process used to notify client wikis about changes on the repository.', + 'wikibase-dispatchstats-intro' => 'Intro text for the DispatchStats special page.', + 'wikibase-dispatchstats-no-stats' => 'Message shown when there are no statistics to be shown.', + 'wikibase-dispatchstats-changes' => 'Section header for statistics about the change log', + 'wikibase-dispatchstats-stats' => 'Section header for statistics about the dispatcher', + 'wikibase-dispatchstats-change-id' => 'Column header for change IDs', + 'wikibase-dispatchstats-change-timestamp' => 'Column header for change timestamps', + 'wikibase-dispatchstats-oldest-change' => 'Row header for the oldest recorded change', + 'wikibase-dispatchstats-newest-change' => 'Row header for the newest recorded change', + 'wikibase-dispatchstats-site-id' => 'Column header for site IDs', + 'wikibase-dispatchstats-lag-num' => 'Column header for the number of changes not yet dispatched to this client wiki', + 'wikibase-dispatchstats-lag-time' => 'Column header for the time since a dispatcher visited this client wiki', + 'wikibase-dispatchstats-freshest' => 'Row header for the freshest (most recently updated) client wiki', + 'wikibase-dispatchstats-stalest' => 'Row header for the stalest (least recently updated) client wiki', + 'wikibase-dispatchstats-median' => 'Row header for the median client wiki, such that half of the client wikis are fresher and half are staler than this one.', + 'wikibase-dispatchstats-average' => 'Row header for average lag values', 'speci
[MediaWiki-commits] [Gerrit] FIX bad syntax of ORDER BY. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: FIX bad syntax of ORDER BY. .. FIX bad syntax of ORDER BY. This fixes the way the ORDER BY option is passed to the Database::select() function. This was previously done wrong in some places, rendering the ORDER BY clause ineffective. The bad ORDER BY could potentially lead to confusion when iterating over large sets of data. This may be the/a cause of changes "ocasionally" not being dispatched. Change-Id: I2e607f968232edd8d089c3566e919c193d4f3387 --- M lib/maintenance/dispatchChanges.php M repo/includes/store/sql/TermSearchKeyBuilder.php 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/lib/maintenance/dispatchChanges.php b/lib/maintenance/dispatchChanges.php index 53d706e..5add8ad 100644 --- a/lib/maintenance/dispatchChanges.php +++ b/lib/maintenance/dispatchChanges.php @@ -652,7 +652,7 @@ ), array( 'LIMIT' => $limit, - 'ORDER BY ' . $table->getPrefixedField( 'id' ) . ' ASC' + 'ORDER BY ' => $table->getPrefixedField( 'id' ) . ' ASC' ), __METHOD__ ); diff --git a/repo/includes/store/sql/TermSearchKeyBuilder.php b/repo/includes/store/sql/TermSearchKeyBuilder.php index 5c299b4..06052f1 100644 --- a/repo/includes/store/sql/TermSearchKeyBuilder.php +++ b/repo/includes/store/sql/TermSearchKeyBuilder.php @@ -167,7 +167,7 @@ __METHOD__, array( 'LIMIT' => $this->batchSize, - 'ORDER BY term_row_id ASC', + 'ORDER BY' => 'term_row_id ASC', 'FOR UPDATE' ) ); -- To view, visit https://gerrit.wikimedia.org/r/55092 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2e607f968232edd8d089c3566e919c193d4f3387 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler Gerrit-Reviewer: Aude Gerrit-Reviewer: Denny Vrandecic Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug ) Fix removed underscores in site id - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/55451 Change subject: (Bug ) Fix removed underscores in site id .. (Bug ) Fix removed underscores in site id A fix in ItemByTitle that should only strip underscores in "page" also strips underscores in "site". That makes some language code fail, and then the page lookup fail. Change-Id: I61acaeabdf44d80dde9b129c4de51e10e4004cd8 --- M repo/includes/specials/SpecialItemByTitle.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/51/55451/1 diff --git a/repo/includes/specials/SpecialItemByTitle.php b/repo/includes/specials/SpecialItemByTitle.php index c085971..5b8c36f 100644 --- a/repo/includes/specials/SpecialItemByTitle.php +++ b/repo/includes/specials/SpecialItemByTitle.php @@ -66,7 +66,7 @@ // If ther are enough data, then try to lookup the item content if ( isset( $site ) && isset( $page ) ) { // Try to get a item content - $siteId = \Wikibase\Utils::trimToNFC( str_replace( '_', ' ', $site ) ); + $siteId = \Wikibase\Utils::trimToNFC( $site ); // no stripping of underscores here! $pageName = \Wikibase\Utils::trimToNFC( str_replace( '_', ' ', $page ) ); $itemHandler = new \Wikibase\ItemHandler(); $itemContent = $itemHandler->getFromSiteLink( $siteId, $pageName ); -- To view, visit https://gerrit.wikimedia.org/r/55451 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I61acaeabdf44d80dde9b129c4de51e10e4004cd8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] More extensive testing of Change classes. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: More extensive testing of Change classes. .. More extensive testing of Change classes. This adds extensive tests cases for the different Change classes. It takes special care to test the serialization of different data structures that may be contained in Change objects. Change-Id: I55ec8d947ca2670b00b6e307c34cfc11c74b57f7 --- M client/tests/phpunit/includes/ChangeHandlerTest.php M lib/WikibaseLib.php M lib/includes/changes/ChangeRow.php M lib/includes/changes/DiffChange.php M lib/includes/changes/EntityChange.php M lib/tests/phpunit/changes/ChangeRowTest.php M lib/tests/phpunit/changes/DiffChangeTest.php M lib/tests/phpunit/changes/EntityChangeTest.php M lib/tests/phpunit/changes/TestChanges.php 9 files changed, 370 insertions(+), 181 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/tests/phpunit/includes/ChangeHandlerTest.php b/client/tests/phpunit/includes/ChangeHandlerTest.php index 1c45513..2038e2a 100644 --- a/client/tests/phpunit/includes/ChangeHandlerTest.php +++ b/client/tests/phpunit/includes/ChangeHandlerTest.php @@ -403,6 +403,9 @@ } } + /** +* @todo: move to TestChanges, unify with TestChanges::getChanges() +*/ public static function makeTestChanges( $userId, $entityId ) { $entity = Item::newEmpty(); $entity->setId( new EntityId( Item::ENTITY_TYPE, $entityId ) ); @@ -742,124 +745,8 @@ // == - - protected static function getTestChanges() { - static $changes = array(); - - if ( empty( $changes ) ) { - $empty = Property::newEmpty(); - $empty->setId( new \Wikibase\EntityId( Property::ENTITY_TYPE, 100 ) ); - - $changes['property-creation'] = EntityChange::newFromUpdate( EntityChange::ADD, null, $empty ); - $changes['property-deletion'] = EntityChange::newFromUpdate( EntityChange::REMOVE, $empty, null ); - - // - - $old = Property::newEmpty(); - $old->setId( new \Wikibase\EntityId( Property::ENTITY_TYPE, 100 ) ); - $new = $old->copy(); - - $new->setLabel( "de", "dummy" ); - $changes['property-set-label'] = EntityChange::newFromUpdate( EntityChange::UPDATE, $old, $new ); - $old = $new->copy(); - - // - - $old = Item::newEmpty(); - $old->setId( new \Wikibase\EntityId( Item::ENTITY_TYPE, 100 ) ); - $new = $old->copy(); - - $changes['item-creation'] = EntityChange::newFromUpdate( EntityChange::ADD, null, $new ); - $changes['item-deletion'] = EntityChange::newFromUpdate( EntityChange::REMOVE, $old, null ); - - // - - $dewiki = \Sites::singleton()->getSite( 'dewiki' ); - $link = new \Wikibase\SiteLink( $dewiki, "Dummy" ); - $new->addSiteLink( $link, 'add' ); - $changes['set-dewiki-sitelink'] = EntityChange::newFromUpdate( EntityChange::UPDATE, $old, $new ); - $old = $new->copy(); - - $enwiki = \Sites::singleton()->getSite( 'enwiki' ); - $link = new \Wikibase\SiteLink( $enwiki, "Emmy" ); - $new->addSiteLink( $link, 'add' ); - $changes['set-enwiki-sitelink'] = EntityChange::newFromUpdate( EntityChange::UPDATE, $old, $new ); - $old = $new->copy(); - - // - - $link = new \Wikibase\SiteLink( $dewiki, "Dummy2" ); - $new->addSiteLink( $link, 'set' ); - $changes['change-dewiki-sitelink'] = EntityChange::newFromUpdate( EntityChange::UPDATE, $old, $new ); - $old = $new->copy(); - - $link = new \Wikibase\SiteLink( $enwiki, "Emmy2" ); - $new->addSiteLink( $link, 'set' ); - $changes['change-enwiki-sitelink'] = EntityChange::newFromUpdate( EntityChange::UPDATE, $old, $new ); - $old = $new->copy(); - - $new->removeSiteLink( 'dewiki', false ); - $changes['remove-dewiki-sitelink'] = EntityChange::newFromUpdate( EntityChange::UPDATE, $old, $new ); - $old = $new->copy(); - - // - - $new->setLabel( "de", "dummy" ); - $ch
[MediaWiki-commits] [Gerrit] Fix misleading output of Special:DispatchStats. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Fix misleading output of Special:DispatchStats. .. Fix misleading output of Special:DispatchStats. Previously, the notions of "touched time" (time since last dispatch) was confused with the "lag time" (time between last dispatched change and most recent change). Change-Id: I914bbf5aa7965a6d98d2033e5b1ef83da340cb15 --- M repo/Wikibase.i18n.php M repo/includes/specials/SpecialDispatchStats.php M repo/includes/store/sql/DispatchStats.php M repo/tests/phpunit/includes/store/sql/DispatchStatsTest.php 4 files changed, 142 insertions(+), 79 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 176aaa0..096a4ed 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -179,8 +179,11 @@ 'wikibase-dispatchstats-oldest-change' => 'Oldest', 'wikibase-dispatchstats-newest-change' => 'Newest', 'wikibase-dispatchstats-site-id' => 'Site', + 'wikibase-dispatchstats-pos' => 'Position', 'wikibase-dispatchstats-lag-num' => 'Pending', 'wikibase-dispatchstats-lag-time' => 'Lag', + 'wikibase-dispatchstats-touched' => 'Touched', + 'wikibase-dispatchstats-large-lag' => '(very large)', 'wikibase-dispatchstats-freshest' => 'Freshest', 'wikibase-dispatchstats-stalest' => 'Stalest', 'wikibase-dispatchstats-median' => 'Median', @@ -717,9 +720,12 @@ {{Identical|Newest}}', 'wikibase-dispatchstats-site-id' => 'Column header for site IDs. {{Identical|Site}}', + 'wikibase-dispatchstats-pos' => 'Column header for dispatch position (given as change ID).', 'wikibase-dispatchstats-lag-num' => 'Column header for the number of changes not yet dispatched to this client wiki. {{Identical|Pending}}', - 'wikibase-dispatchstats-lag-time' => 'Column header for the time since a dispatcher visited this client wiki', + 'wikibase-dispatchstats-lag-time' => 'Column header for the time since between the change last dispatched to the client and the latest known change on the repo.', + 'wikibase-dispatchstats-touched' => 'Column header for the time a dispatcher last visited this client wiki', + 'wikibase-dispatchstats-large-lag' => 'Shown instead of the actual lag if the lag is so large that the relevant change records were already pruned', 'wikibase-dispatchstats-freshest' => 'Row header for the freshest (most recently updated) client wiki. See also: @@ -2613,11 +2619,13 @@ 'wikibase-dispatchstats-oldest-change' => 'Älteste', 'wikibase-dispatchstats-newest-change' => 'Neueste', 'wikibase-dispatchstats-site-id' => 'Website', + 'wikibase-dispatchstats-pos' => 'Stand', 'wikibase-dispatchstats-lag-num' => 'Ausstehend', - 'wikibase-dispatchstats-lag-time' => 'Verzögerung', + 'wikibase-dispatchstats-lag-time' => 'Rückstand', + 'wikibase-dispatchstats-touched' => 'Letzte Verarbeitung', 'wikibase-dispatchstats-freshest' => 'Neueste', 'wikibase-dispatchstats-stalest' => 'Älteste', - 'wikibase-dispatchstats-median' => 'Mittel', + 'wikibase-dispatchstats-median' => 'Zentralwert', 'wikibase-dispatchstats-average' => 'Durchschnitt', 'special-listdatatypes' => 'Liste aller verfügbaren Datentypen', 'wikibase-listdatatypes-intro' => 'Dies ist eine Liste aller Datentypen, die derzeit in dieser Installation verwendet werden:', diff --git a/repo/includes/specials/SpecialDispatchStats.php b/repo/includes/specials/SpecialDispatchStats.php index 2acfc3a..3273d3c 100644 --- a/repo/includes/specials/SpecialDispatchStats.php +++ b/repo/includes/specials/SpecialDispatchStats.php @@ -61,9 +61,15 @@ $this->outputRow( array( $label, - isset( $state->chd_site ) ? $state->chd_site : '', - $lang->formatNum( $state->chd_dist ), - $lang->formatDuration( $state->chd_lag ), + isset( $state->chd_site ) ? $state->chd_site : '-', + isset( $state->chd_seen ) ? $state->chd_seen : '-', + $lang->formatNum( $state->chd_pending ), + $state->chd_lag === null + ? wfMessage( 'wikibase-dispatchstats-large-lag' )->text() + : $lang->formatDuration( $state->chd_lag, array( 'days', 'hours', 'minutes' ) ), + isset( $state->chd_touched ) + ? $lang->timeanddate( $state->chd_touched ) + : '-', ) ); } @@ -118,8 +124,10 @@ $this->outputRow( array( '', $this->msg(
[MediaWiki-commits] [Gerrit] (bug 46565) Don't prune undispatched changes. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (bug 46565) Don't prune undispatched changes. .. (bug 46565) Don't prune undispatched changes. This makes the pruneChanges script consider which changes have been dispatched yet. Change-Id: Ic7663a6153a75548c3984a9d61664ff85c934f3d --- M repo/maintenance/pruneChanges.php 1 file changed, 92 insertions(+), 14 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/maintenance/pruneChanges.php b/repo/maintenance/pruneChanges.php index 9ee56b6..0cbe081 100644 --- a/repo/maintenance/pruneChanges.php +++ b/repo/maintenance/pruneChanges.php @@ -33,14 +33,37 @@ * @ingroup Maintenance */ class PruneChanges extends Maintenance { + + /** +* @var int the minimum number of seconds to keep changes for. +*/ + protected $keepSeconds = 0; + + /** +* @var int the minimum number of seconds after dispatching to keep changes for. +*/ + protected $graceSeconds = 0; + + /** +* @var bool whether the dispatch time should be ignored +*/ + protected $ignoreDispatch = false; + public function __construct() { parent::__construct(); $this->mDescription = "Prune the Wikibase changes table to a maximum number of entries"; - $this->addOption( 'number-of-days', 'Number of days to keep entries in the table after the ' - . 'maintenance script has been run (default: 7)', false, true, 'n' ); + $this->addOption( 'number-of-days', 'Keep changes at least N days (deprecated).', false, true, 'n' ); + $this->addOption( 'keep-days', 'Keep changes at least N days.', false, true, 'd' ); + $this->addOption( 'keep-hours', 'Keep changes at least N hours.', false, true, 'h' ); + $this->addOption( 'keep-minutes', 'Keep changes at least N minutes.', false, true, 'm' ); + $this->addOption( 'grace-minutes', 'Keep changes at least N more minutes after they have been dispatched.', false, true, 'g' ); + $this->addOption( 'force', 'Run regardless of whether the PID file says it is running already.', false, false, 'f' ); + + $this->addOption( 'ignore-dispatch', 'Ignore whether changes have been dispatched or not.', + false, false, 'D' ); } public function execute() { @@ -49,7 +72,6 @@ exit; } - $numDays = intval( $this->getOption( 'number-of-days', 7 ) ); $force = $this->getOption( 'force', false ); $pidfile = Utils::makePidFilename( 'WBpruneChanges', wfWikiID() ); @@ -58,28 +80,84 @@ exit( 5 ); } - $this->pruneChanges( $numDays ); + $this->ignoreDispatch = $this->getOption( 'ignore-dispatch', false ); - $this->output( date( 'H:i:s' ) . " done, exiting\n" ); + $this->keepSeconds = 0; + $this->keepSeconds += intval( $this->getOption( 'number-of-days', 0 ) ) * 24 * 60 * 60; + $this->keepSeconds += intval( $this->getOption( 'keep-days', 0 ) ) * 24 * 60 * 60; + $this->keepSeconds += intval( $this->getOption( 'keep-hours', 0 ) ) * 60 * 60; + $this->keepSeconds += intval( $this->getOption( 'keep-minutes', 0 ) ) * 60; + + if ( $this->keepSeconds === 0 ) { + // one day + $this->keepSeconds = 1 * 24 * 60 * 60; + } + + $this->graceSeconds = 0; + $this->graceSeconds += intval( $this->getOption( 'grace-minutes', 0 ) ) * 60; + + if ( $this->graceSeconds === 0 ) { + // one hour + $this->graceSeconds = 1 * 60 * 60; + } + + $until = $this->getCutoffTimestamp(); + $this->output( date( 'H:i:s' ) . " pruning entries older than " + . wfTimestamp( TS_ISO_8601, $until ) . "\n" ); + + $deleted = $this->pruneChanges( $until ); + $this->output( date( 'H:i:s' ) . " $deleted rows pruned.\n" ); + unlink( $pidfile ); // delete lockfile on normal exit } - public function pruneChanges( $numDays ) { + /** +* Calculates the timestamp up to which changes can be pruned. +* +* @return int timstamp up to which changes can be pruned (as unix period) +*/ + protected function getCutoffTimestamp() { + $until = time() - $this->keepSeconds; + + if ( !$this->ignoreDispatch ) { +
[MediaWiki-commits] [Gerrit] Rename TermCache to TermIndex. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Rename TermCache to TermIndex. .. Rename TermCache to TermIndex. Includes minor restructuring of test cases and factory. Change-Id: I8d8c4b0430e42ac3acdf95d14cc966640dd4e885 --- M repo/Wikibase.hooks.php M repo/Wikibase.php M repo/config/Wikibase.default.php M repo/includes/EditEntity.php M repo/includes/LabelDescriptionDuplicateDetector.php M repo/includes/api/SearchEntities.php M repo/includes/content/EntityContent.php M repo/includes/content/EntityContentFactory.php M repo/includes/store/Store.php R repo/includes/store/TermIndex.php M repo/includes/store/sql/SqlStore.php M repo/includes/store/sql/TermSearchKeyBuilder.php R repo/includes/store/sql/TermSqlIndex.php M repo/includes/updates/EntityDeletionUpdate.php M repo/includes/updates/EntityModificationUpdate.php M repo/maintenance/rebuildTermsSearchKey.php M repo/tests/phpunit/includes/content/EntityContentTest.php M repo/tests/phpunit/includes/content/ItemContentTest.php M repo/tests/phpunit/includes/content/PropertyContentTest.php M repo/tests/phpunit/includes/store/StoreTest.php R repo/tests/phpunit/includes/store/TermIndexTest.php M repo/tests/phpunit/includes/store/sql/TermSearchKeyBuilderTest.php R repo/tests/phpunit/includes/store/sql/TermSqlIndexTest.php 23 files changed, 118 insertions(+), 121 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 03e2167..5072483 100755 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -200,10 +200,9 @@ 'store/IdGenerator', 'store/StoreFactory', 'store/Store', - 'store/TermCache', 'store/sql/SqlIdGenerator', - 'store/sql/TermSqlCache', + 'store/sql/TermSqlIndex', 'store/sql/TermSearchKeyBuilder', 'updates/ItemDeletionUpdate', diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 794651d..ad42325 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -185,7 +185,7 @@ $wgAutoloadClasses['Wikibase\IdGenerator'] = $dir . 'includes/store/IdGenerator.php'; $wgAutoloadClasses['Wikibase\Store'] = $dir . 'includes/store/Store.php'; $wgAutoloadClasses['Wikibase\StoreFactory']= $dir . 'includes/store/StoreFactory.php'; -$wgAutoloadClasses['Wikibase\TermCache'] = $dir . 'includes/store/TermCache.php'; +$wgAutoloadClasses['Wikibase\TermIndex'] = $dir . 'includes/store/TermIndex.php'; $wgAutoloadClasses['Wikibase\TermCombinationMatchFinder'] = $dir . 'includes/store/TermCombinationMatchFinder.php'; $wgAutoloadClasses['Wikibase\TermMatchScoreCalculator'] = $dir . 'includes/store/TermMatchScoreCalculator.php'; $wgAutoloadClasses['Wikibase\TermSearchKeyBuilder'] = $dir . 'includes/store/sql/TermSearchKeyBuilder.php'; @@ -193,7 +193,7 @@ // includes/store/sql $wgAutoloadClasses['Wikibase\SqlIdGenerator'] = $dir . 'includes/store/sql/SqlIdGenerator.php'; $wgAutoloadClasses['Wikibase\SqlStore']= $dir . 'includes/store/sql/SqlStore.php'; -$wgAutoloadClasses['Wikibase\TermSqlCache']= $dir . 'includes/store/sql/TermSqlCache.php'; +$wgAutoloadClasses['Wikibase\TermSqlIndex']= $dir . 'includes/store/sql/TermSqlIndex.php'; $wgAutoloadClasses['Wikibase\EntityPerPageTable'] = $dir . 'includes/store/sql/EntityPerPageTable.php'; $wgAutoloadClasses['Wikibase\DispatchStats'] = $dir . 'includes/store/sql/DispatchStats.php'; @@ -210,10 +210,12 @@ // tests $wgAutoloadClasses['Wikibase\Test\TestItemContents'] = $dir . 'tests/phpunit/TestItemContents.php'; $wgAutoloadClasses['Wikibase\Test\ActionTestCase'] = $dir . 'tests/phpunit/includes/actions/ActionTestCase.php'; -$wgAutoloadClasses['Wikibase\Test\Api\ModifyItemBase'] = $dir . 'tests/phpunit/includes/api/ModifyItemBase.php'; +$wgAutoloadClasses['Wikibase\Test\Api\ModifyItemBase'] = $dir . 'tests/phpunit/includes/api/ModifyItemBase.php'; $wgAutoloadClasses['Wikibase\Test\Api\LangAttributeBase'] = $dir . 'tests/phpunit/includes/api/LangAttributeBase.php'; $wgAutoloadClasses['Wikibase\Test\EntityContentTest'] = $dir . 'tests/phpunit/includes/content/EntityContentTest.php'; $wgAutoloadClasses['Wikibase\Test\EntityHandlerTest'] = $dir . 'tests/phpunit/includes/content/EntityHandlerTest.php'; +$wgAutoloadClasses['Wikibase\Test\SpecialPageTestBase']= $dir . 'tests/phpunit/includes/specials/SpecialPageT
[MediaWiki-commits] [Gerrit] Move SpecialPageTestBase from repo - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/56120 Change subject: Move SpecialPageTestBase from repo .. Move SpecialPageTestBase from repo This base class is in lib and it creates a fatal error to try to look it up on repo. Change-Id: I71393ca2eec974f06b1d5c3ea77f971fddc43543 --- M repo/Wikibase.php 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/20/56120/1 diff --git a/repo/Wikibase.php b/repo/Wikibase.php index ad42325..868882c 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -214,7 +214,6 @@ $wgAutoloadClasses['Wikibase\Test\Api\LangAttributeBase'] = $dir . 'tests/phpunit/includes/api/LangAttributeBase.php'; $wgAutoloadClasses['Wikibase\Test\EntityContentTest'] = $dir . 'tests/phpunit/includes/content/EntityContentTest.php'; $wgAutoloadClasses['Wikibase\Test\EntityHandlerTest'] = $dir . 'tests/phpunit/includes/content/EntityHandlerTest.php'; -$wgAutoloadClasses['Wikibase\Test\SpecialPageTestBase']= $dir . 'tests/phpunit/includes/specials/SpecialPageTestBase.php'; $wgAutoloadClasses['Wikibase\Test\TermIndexTest'] = $dir . 'tests/phpunit/includes/store/TermIndexTest.php'; // API module registration -- To view, visit https://gerrit.wikimedia.org/r/56120 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71393ca2eec974f06b1d5c3ea77f971fddc43543 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move TermIndex to lib. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Move TermIndex to lib. .. Move TermIndex to lib. This is in preparation for direct access to the term index from the client, for use with finding properties by label. Change-Id: Ia212cd0d57cc97310f49f6c5d56f9dcf90860789 --- M lib/WikibaseLib.php R lib/includes/store/TermCombinationMatchFinder.php R lib/includes/store/TermIndex.php R lib/includes/store/TermMatchScoreCalculator.php R lib/includes/store/sql/TermSqlIndex.php M repo/Wikibase.php M repo/includes/store/Store.php 7 files changed, 6 insertions(+), 6 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php index b9c0071..9bcfa5a 100644 --- a/lib/WikibaseLib.php +++ b/lib/WikibaseLib.php @@ -184,6 +184,10 @@ $wgAutoloadClasses['Wikibase\PropertyLookup'] = $dir . 'includes/store/PropertyLookup.php'; $wgAutoloadClasses['Wikibase\SiteLinkCache'] = $dir . 'includes/store/SiteLinkCache.php'; $wgAutoloadClasses['Wikibase\SiteLinkLookup'] = $dir . 'includes/store/SiteLinkLookup.php'; +$wgAutoloadClasses['Wikibase\TermIndex'] = $dir . 'includes/store/TermIndex.php'; +$wgAutoloadClasses['Wikibase\TermCombinationMatchFinder'] = $dir . 'includes/store/TermCombinationMatchFinder.php'; +$wgAutoloadClasses['Wikibase\TermMatchScoreCalculator'] = $dir . 'includes/store/TermMatchScoreCalculator.php'; +$wgAutoloadClasses['Wikibase\TermSqlIndex']= $dir . 'includes/store/sql/TermSqlIndex.php'; // includes/store/sql $wgAutoloadClasses['Wikibase\CachingEntityLoader'] = $dir . 'includes/store/sql/CachingEntityLoader.php'; diff --git a/repo/includes/store/TermCombinationMatchFinder.php b/lib/includes/store/TermCombinationMatchFinder.php similarity index 100% rename from repo/includes/store/TermCombinationMatchFinder.php rename to lib/includes/store/TermCombinationMatchFinder.php diff --git a/repo/includes/store/TermIndex.php b/lib/includes/store/TermIndex.php similarity index 100% rename from repo/includes/store/TermIndex.php rename to lib/includes/store/TermIndex.php diff --git a/repo/includes/store/TermMatchScoreCalculator.php b/lib/includes/store/TermMatchScoreCalculator.php similarity index 100% rename from repo/includes/store/TermMatchScoreCalculator.php rename to lib/includes/store/TermMatchScoreCalculator.php diff --git a/repo/includes/store/sql/TermSqlIndex.php b/lib/includes/store/sql/TermSqlIndex.php similarity index 100% rename from repo/includes/store/sql/TermSqlIndex.php rename to lib/includes/store/sql/TermSqlIndex.php diff --git a/repo/Wikibase.php b/repo/Wikibase.php index ad42325..793b41c 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -185,17 +185,13 @@ $wgAutoloadClasses['Wikibase\IdGenerator'] = $dir . 'includes/store/IdGenerator.php'; $wgAutoloadClasses['Wikibase\Store'] = $dir . 'includes/store/Store.php'; $wgAutoloadClasses['Wikibase\StoreFactory']= $dir . 'includes/store/StoreFactory.php'; -$wgAutoloadClasses['Wikibase\TermIndex'] = $dir . 'includes/store/TermIndex.php'; -$wgAutoloadClasses['Wikibase\TermCombinationMatchFinder'] = $dir . 'includes/store/TermCombinationMatchFinder.php'; -$wgAutoloadClasses['Wikibase\TermMatchScoreCalculator'] = $dir . 'includes/store/TermMatchScoreCalculator.php'; -$wgAutoloadClasses['Wikibase\TermSearchKeyBuilder'] = $dir . 'includes/store/sql/TermSearchKeyBuilder.php'; // includes/store/sql $wgAutoloadClasses['Wikibase\SqlIdGenerator'] = $dir . 'includes/store/sql/SqlIdGenerator.php'; $wgAutoloadClasses['Wikibase\SqlStore']= $dir . 'includes/store/sql/SqlStore.php'; -$wgAutoloadClasses['Wikibase\TermSqlIndex']= $dir . 'includes/store/sql/TermSqlIndex.php'; $wgAutoloadClasses['Wikibase\EntityPerPageTable'] = $dir . 'includes/store/sql/EntityPerPageTable.php'; $wgAutoloadClasses['Wikibase\DispatchStats'] = $dir . 'includes/store/sql/DispatchStats.php'; +$wgAutoloadClasses['Wikibase\TermSearchKeyBuilder']= $dir . 'includes/store/sql/TermSearchKeyBuilder.php'; // includes/updates $wgAutoloadClasses['Wikibase\EntityDeletionUpdate']= $dir . 'includes/updates/EntityDeletionUpdate.php'; diff --git a/repo/includes/store/Store.php b/repo/includes/store/Store.php index 0692913..b61037a 100644 --- a/repo/includes/store/Store.php +++ b/repo/includes/store/Store.php @@ -62,7 +62,7 @@ /** * Returns a TermIndex for this store. * -* @since 0.1 +* @since 0.4 * * @return TermIndex */ -- To view, visit https://gerrit.wikimedia.org/r/55897 T
[MediaWiki-commits] [Gerrit] be-tarask translation for namespaces - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: be-tarask translation for namespaces .. be-tarask translation for namespaces Change-Id: I4e34821a5450c5592f69c8f3c5cbaa7c0ca66f8c --- M repo/Wikibase.i18n.namespaces.php 1 file changed, 14 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/Wikibase.i18n.namespaces.php b/repo/Wikibase.i18n.namespaces.php index 2c2a0cd..dda4936 100644 --- a/repo/Wikibase.i18n.namespaces.php +++ b/repo/Wikibase.i18n.namespaces.php @@ -67,6 +67,20 @@ WB_NS_QUERY_TALK => 'Query_talk', ); +$namespaceNames['be-tarask'] = array( + WB_NS_DATA => 'Зьвесткі', // legacy + WB_NS_DATA_TALK => 'Абмеркаваньне_зьвестак', // legacy + + WB_NS_ITEM => 'Аб’ект', + WB_NS_ITEM_TALK => 'Абмеркаваньне_аб’екта', + + WB_NS_PROPERTY => 'Уласьцівасьць', + WB_NS_PROPERTY_TALK => 'Абмеркаваньне_ўласьцівасьці', + + WB_NS_QUERY => 'Запыт', + WB_NS_QUERY_TALK => 'Абмеркаваньне_запыту', +); + $namespaceNames['de'] = array( WB_NS_DATA => 'Daten', // legacy WB_NS_DATA_TALK => 'Datendiskussion', // legacy -- To view, visit https://gerrit.wikimedia.org/r/55492 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4e34821a5450c5592f69c8f3c5cbaa7c0ca66f8c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Wizardist Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Siebrand Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add profiling to dispatchChanges script. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Add profiling to dispatchChanges script. .. Add profiling to dispatchChanges script. Change-Id: Iebe11848b9ce0414e56c31d43c5f217d379725cd --- M lib/includes/ChangeNotificationJob.php M lib/maintenance/dispatchChanges.php 2 files changed, 68 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/lib/includes/ChangeNotificationJob.php b/lib/includes/ChangeNotificationJob.php index 85150bc..f265dc9 100644 --- a/lib/includes/ChangeNotificationJob.php +++ b/lib/includes/ChangeNotificationJob.php @@ -46,6 +46,7 @@ */ public static function newFromChanges( array $changes, $repo = '', $params = false ) { static $dummyTitle = null; + wfProfileIn( __METHOD__ ); // Note: we don't really care about the title and will use a dummy if ( $dummyTitle === null ) { @@ -75,7 +76,10 @@ $params ); - return new ChangeNotificationJob( $dummyTitle, $params ); + $job = new ChangeNotificationJob( $dummyTitle, $params ); + + wfProfileOut( __METHOD__ ); + return $job; } /** @@ -106,6 +110,8 @@ */ public function getChanges() { if ( $this->changes === null ) { + wfProfileIn( __METHOD__ . '#load' ); + $params = $this->getParams(); $ids = $params['changeIds']; @@ -126,6 +132,8 @@ . " Some changes were lost, possibly due to premature pruning.", E_USER_WARNING ); } + + wfProfileOut( __METHOD__ . '#load' ); } return $this->changes; diff --git a/lib/maintenance/dispatchChanges.php b/lib/maintenance/dispatchChanges.php index 3f2f42e..599cd86 100644 --- a/lib/maintenance/dispatchChanges.php +++ b/lib/maintenance/dispatchChanges.php @@ -297,6 +297,8 @@ * @return int The number of changes dispatched */ public function dispatchTo( $wikiState ) { + wfProfileIn( __METHOD__ ); + $wikiDB = $wikiState['chd_db']; $siteID = $wikiState['chd_site']; $after = intval( $wikiState['chd_seen'] ); @@ -329,6 +331,7 @@ . "Next ID is $continueAfter." ); } + wfProfileOut( __METHOD__ ); return $n; } @@ -353,6 +356,8 @@ * @see releaseWiki() */ protected function selectClient() { + wfProfileIn( __METHOD__ ); + $candidates = $this->getCandidateClients(); while ( $candidates ) { @@ -366,6 +371,7 @@ if ( $state ) { // got one + wfProfileOut( __METHOD__ ); return $state; } @@ -373,6 +379,7 @@ } // we ran out of candidates + wfProfileOut( __METHOD__ ); return null; } @@ -385,6 +392,7 @@ * @see selectClient() */ protected function getCandidateClients() { + wfProfileIn( __METHOD__ ); $db = $this->getRepoMaster(); // XXX: subject to clock skew. Use DB based "now" time? @@ -435,6 +443,7 @@ $candidates[] = $row['chd_site']; } + wfProfileOut( __METHOD__ ); return $candidates; } @@ -443,6 +452,7 @@ * that are in the configuration but not yet in the dispatch table. */ protected function initStateTable() { + wfProfileIn( __METHOD__ ); $db = $this->getRepoMaster(); $res = $db->select( $this->stateTable, @@ -480,6 +490,8 @@ } $this->releaseRepoMaster( $db ); + + wfProfileOut( __METHOD__ ); } /** @@ -501,6 +513,7 @@ ."consider removing it from the " . $this->stateTable ); } + wfProfileIn( __METHOD__ ); $wikiDB = $this->clientWikis[ $siteID ]; $this->trace( "Trying $siteID" ); @@ -522,6 +535,8 @@ if ( !$state ) { $this->log( "ERROR: $siteID is not in the dispatch table." ); + + wfProfileOut( __METHOD__ ); return false; } else { // turn the row object into an array @@ -
[MediaWiki-commits] [Gerrit] Fix a test that keeps on creeping back - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/56133 Change subject: Fix a test that keeps on creeping back .. Fix a test that keeps on creeping back DIE! DIE! DIE! Change-Id: Ic1f167d8a2c07ea421011c13fb3ea9bf90b6d7c5 --- M client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/33/56133/1 diff --git a/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php b/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php index 9529ac9..b5b9289 100644 --- a/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php +++ b/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php @@ -85,7 +85,7 @@ return array( array( 'foo', array( "page_title >= 'Foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), array( ':foo', array( "page_title >= 'Foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), - array( 'en:foo', array( "page_title >= 'foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), + array( 'en:foo', array( "page_title >= 'En:foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), array( 'user:foo', array( "page_title >= 'Foo'", "page_namespace = 2", 'page_namespace IN (0)' ) ), array( 'user talk:foo', array( "page_title >= 'Foo'", "page_namespace = 3", 'page_namespace IN (0)' ) ), ); -- To view, visit https://gerrit.wikimedia.org/r/56133 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic1f167d8a2c07ea421011c13fb3ea9bf90b6d7c5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix a test that keeps on creeping back - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Fix a test that keeps on creeping back .. Fix a test that keeps on creeping back DIE! DIE! DIE! Change-Id: Ic1f167d8a2c07ea421011c13fb3ea9bf90b6d7c5 --- M client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php b/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php index 9529ac9..b5b9289 100644 --- a/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php +++ b/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php @@ -85,7 +85,7 @@ return array( array( 'foo', array( "page_title >= 'Foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), array( ':foo', array( "page_title >= 'Foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), - array( 'en:foo', array( "page_title >= 'foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), + array( 'en:foo', array( "page_title >= 'En:foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), array( 'user:foo', array( "page_title >= 'Foo'", "page_namespace = 2", 'page_namespace IN (0)' ) ), array( 'user talk:foo', array( "page_title >= 'Foo'", "page_namespace = 3", 'page_namespace IN (0)' ) ), ); -- To view, visit https://gerrit.wikimedia.org/r/56133 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic1f167d8a2c07ea421011c13fb3ea9bf90b6d7c5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] More profiling in ChangeHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: More profiling in ChangeHandler .. More profiling in ChangeHandler Change-Id: If35eb8fd70ab7931667fd5c55777e667eca1923f --- M client/includes/ChangeHandler.php 1 file changed, 30 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/includes/ChangeHandler.php b/client/includes/ChangeHandler.php index f46441b..2f34574 100644 --- a/client/includes/ChangeHandler.php +++ b/client/includes/ChangeHandler.php @@ -110,6 +110,8 @@ SiteLinkLookup $siteLinkLookup = null, \Site $localSite = null ) { + wfProfileIn( __METHOD__ ); + $this->sites = \Sites::singleton(); // TODO: get from param if ( !$updater ) { @@ -155,6 +157,8 @@ $this->dataTransclusionAllowed = Settings::get( 'allowDataTransclusion' ); $this->actionMask = 0x; //TODO: use changeHanderActions setting + + wfProfileOut( __METHOD__ ); } /** @@ -189,6 +193,7 @@ * entity ID is the list of changes performed on that entity. */ public function groupChangesByEntity( array $changes ) { + wfProfileIn( __METHOD__ ); $groups = array(); foreach ( $changes as $change ) { @@ -201,6 +206,7 @@ $groups[$id][] = $change; } + wfProfileOut( __METHOD__ ); return $groups; } @@ -225,6 +231,8 @@ } else if ( count( $changes ) === 1 ) { return reset( $changes ); } + + wfProfileIn( __METHOD__ ); // we now assume that we have a list if EntityChanges, // all done by the same user on the same entity. @@ -296,6 +304,7 @@ $info['changes'] = $changes; $change->setField( 'info', $info ); + wfProfileOut( __METHOD__ ); return $change; } @@ -313,6 +322,8 @@ * @return EntityChange[] grouped changes */ public function coalesceRuns( array $changes ) { + wfProfileIn( __METHOD__ ); + $coalesced = array(); $currentRun = array(); @@ -379,6 +390,7 @@ } } + wfProfileOut( __METHOD__ ); return $coalesced; } @@ -392,6 +404,7 @@ * @return Change[] grouped changes */ public function coalesceChanges( array $changes ) { + wfProfileIn( __METHOD__ ); $coalesced = array(); $changesByEntity = $this->groupChangesByEntity( $changes ); @@ -405,6 +418,7 @@ wfDebugLog( __CLASS__, __METHOD__ . ": coalesced " . count( $changes ) . " into " . count( $coalesced ) . " changes" ); + wfProfileOut( __METHOD__ ); return $coalesced; } @@ -444,6 +458,8 @@ * @param Change[] $changes */ public function handleChanges( array $changes ) { + wfProfileIn( __METHOD__ ); + $changes = $this->coalesceChanges( $changes ); if ( !wfRunHooks( 'WikibaseHandleChanges', array( $changes ) ) ) { @@ -457,6 +473,8 @@ $this->handleChange( $change ); } + + wfProfileOut( __METHOD__ ); } /** @@ -523,6 +541,8 @@ * @return \Title[] the titles of the pages to update */ public function getPagesToUpdate( Change $change ) { + wfProfileIn( __METHOD__ ); + $pagesToUpdate = array(); if ( $change instanceof ItemChange ) { @@ -576,6 +596,7 @@ $titlesToUpdate[] = $title; } + wfProfileOut( __METHOD__ ); return $titlesToUpdate; } @@ -698,6 +719,8 @@ * @return int actions to take, as a bit field using the XXX_ACTION flags */ public function getActions( Change $change ) { + wfProfileIn( __METHOD__ ); + $actions = 0; if ( $change instanceof ItemChange ) { @@ -725,6 +748,7 @@ $actions = $actions & $this->actionMask; + wfProfileOut( __METHOD__ ); return $actions; } @@ -740,6 +764,8 @@ * @return array|null|string */ public function getEditComment( Change $change, \Title $title ) { + wfProfileIn( __METHOD__ ); + if ( $change instanceof EntityChange ) { $siteLinkDiff = ( $change instanceof ItemChange ) ? $change->get
[MediaWiki-commits] [Gerrit] Move formatter stuff out of property parser function class - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Move formatter stuff out of property parser function class .. Move formatter stuff out of property parser function class - some of the functionality is generic and may be useful in other parts of the code. - todo: move stuff to ValueFormatters extension that is not Wikibase-specific Change-Id: I9473ac43c3acbd87702eec63c6da3774b42053e4 --- M client/includes/parserhooks/PropertyParserFunction.php M lib/WikibaseLib.php M lib/config/WikibaseLib.default.php A lib/includes/formatters/EntityIdFormatter.php D lib/includes/formatters/ItemFormatter.php A lib/includes/formatters/SnakFormatter.php A lib/includes/formatters/WikibaseFormatterFactory.php A lib/tests/phpunit/formatters/WikibaseFormatterFactoryTest.php 8 files changed, 429 insertions(+), 114 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/includes/parserhooks/PropertyParserFunction.php b/client/includes/parserhooks/PropertyParserFunction.php index c6c6949..05160bf 100644 --- a/client/includes/parserhooks/PropertyParserFunction.php +++ b/client/includes/parserhooks/PropertyParserFunction.php @@ -1,7 +1,6 @@ language = $language; $this->entityLookup = $entityLookup; $this->propertyLookup = $propertyLookup; $this->errorFormatter = $errorFormatter; - $this->availableDataTypes = $dataTypes; + $this->formatterFactory = $formatterFactory; } /** -* Get value of EntityId DataValue +* Format a data value * * @since 0.4 * -* @param EntityId $entityId -* -* @return string -*/ - protected function getEntityIdValue( EntityId $entityId ) { - wfProfileIn( __METHOD__ ); - - // @todo we could use the terms table to lookup label - // we would need to have some store lookup code in WikibaseLib - $entity = $this->entityLookup->getEntity( $entityId ); - $label = $entity->getLabel( $this->language->getCode() ); - - // @todo ick! handle when there is no label... - $labelValue = $label !== false ? $label : ''; - - wfProfileOut( __METHOD__ ); - return $labelValue; - } - - /** -* @since 0.4 -* -* @param Snak $snak +* @param DataValue $dataValue * * @return string */ public function formatDataValue( DataValue $dataValue ) { - wfProfileIn( __METHOD__ ); $dataType = $dataValue->getType(); - // @fixme why is $dataType inconsistent with data type settings? - if ( !in_array( $dataType, $this->availableDataTypes ) && $dataType !== 'wikibase-entityid' ) { - // @todo error handling, data type not supported - return ''; - } + $options = array( 'wikibase-entityid' => array( + 'entityLookup' => $this->entityLookup, + 'labelFallback' => 'emptyString' + ) ); - $formatterOptions = new FormatterOptions( array( 'lang' => $this->language->getCode() ) ); - $formattedValue = ''; - - if ( $dataType === 'wikibase-entityid' ) { - $valueFormatter = new ItemFormatter( $formatterOptions, $this->entityLookup ); - $formattedValue = $valueFormatter->format( $dataValue ); - } else if ( in_array( $dataType, array( 'commonsMedia', 'string' ) ) ) { - $valueFormatter = new StringFormatter( $formatterOptions ); - $formattedValue = $valueFormatter->format( $dataValue ); - } + $valueFormatter = $this->formatterFactory->newValueFormatterForDataType( $dataType, $options ); + $formattedValue = $valueFormatter->format( $dataValue ); wfProfileOut( __METHOD__ ); return $formattedValue; } /** +* Formats data values in a SnakList as comma separated list +* @todo this belongs elsewhere, such as with formatters +* * @since 0.4 * * @param SnakList $snakList @@ -219,8 +189,10 @@ // returns lookup with full label and id lookup (experimental) or just id lookup $propertyLookup = ClientStoreFactory::getStore()->getPropertyLookup(); - $instance = new self( $targetLanguage, $entityLookup, $propertyLookup, - $errorFormatter, Settings::get( 'dataTypes' ) ); + $formatterFactory = new WikibaseFormatterFactory( Settings::get( 'dataTypeFormatters' ), + $G
[MediaWiki-commits] [Gerrit] (bug 46597) avoid namespace checker error, check variable type - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (bug 46597) avoid namespace checker error, check variable type .. (bug 46597) avoid namespace checker error, check variable type - if ns is not an int, then return false and not exception, but put debug log there instead. Patchset ?: Fixed a test Change-Id: I4083e13db627bacbdd96c8bd8626cffbf2e24f1c --- M client/includes/ChangeHandler.php M client/includes/NamespaceChecker.php M client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php 3 files changed, 6 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/includes/ChangeHandler.php b/client/includes/ChangeHandler.php index f46441b..76d9201 100644 --- a/client/includes/ChangeHandler.php +++ b/client/includes/ChangeHandler.php @@ -569,7 +569,9 @@ continue; } - if ( !$this->namespaceChecker->isWikibaseEnabled( $title->getNamespace() ) ) { + $ns = $title->getNamespace(); + + if ( !is_int( $ns ) || !$this->namespaceChecker->isWikibaseEnabled( $ns ) ) { continue; } diff --git a/client/includes/NamespaceChecker.php b/client/includes/NamespaceChecker.php index d22107e..961fc84 100644 --- a/client/includes/NamespaceChecker.php +++ b/client/includes/NamespaceChecker.php @@ -56,12 +56,12 @@ * * @param int $namespace * -* @throws \MWException * @return bool */ public function isWikibaseEnabled( $namespace ) { if( !is_int( $namespace ) ) { - throw new \MWException( __METHOD__ . " expected a namespace ID." ); + wfDebugLog( __CLASS__, __METHOD__ . " expected a namespace ID." ); + return false; } if ( $this->isExcluded( $namespace ) ) { diff --git a/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php b/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php index 9529ac9..b5b9289 100644 --- a/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php +++ b/client/tests/phpunit/includes/specials/SpecialUnconnectedPagesTest.php @@ -85,7 +85,7 @@ return array( array( 'foo', array( "page_title >= 'Foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), array( ':foo', array( "page_title >= 'Foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), - array( 'en:foo', array( "page_title >= 'foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), + array( 'en:foo', array( "page_title >= 'En:foo'", "page_namespace = 0", 'page_namespace IN (0)' ) ), array( 'user:foo', array( "page_title >= 'Foo'", "page_namespace = 2", 'page_namespace IN (0)' ) ), array( 'user talk:foo', array( "page_title >= 'Foo'", "page_namespace = 3", 'page_namespace IN (0)' ) ), ); -- To view, visit https://gerrit.wikimedia.org/r/56122 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4083e13db627bacbdd96c8bd8626cffbf2e24f1c Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude Gerrit-Reviewer: Daniel Kinzler Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix clock ticks in test - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/56152 Change subject: Fix clock ticks in test .. Fix clock ticks in test If the time is picked up several different places and compared there can be a "race condition" where the clock ticks and the tests fails because the time isn't equal anymore. This fixes one such case. Change-Id: I11e08591f24404825df22d2613db4b407e75803b --- M lib/tests/phpunit/changes/ChangeRowTest.php 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/52/56152/1 diff --git a/lib/tests/phpunit/changes/ChangeRowTest.php b/lib/tests/phpunit/changes/ChangeRowTest.php index 17edf91..81f6ead 100644 --- a/lib/tests/phpunit/changes/ChangeRowTest.php +++ b/lib/tests/phpunit/changes/ChangeRowTest.php @@ -152,9 +152,9 @@ * @dataProvider instanceProvider */ public function testGetAge( $changeRow ) { - $this->assertEquals( - time() - (int)wfTimestamp( TS_UNIX, '2013010100' ), - $changeRow->getAge() + // Don't assert on equalness due to clock ticks! + $this->assertTrue( + abs( time() - (int)wfTimestamp( TS_UNIX, '2013010100' ) - $changeRow->getAge() ) <= 1 ); } -- To view, visit https://gerrit.wikimedia.org/r/56152 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I11e08591f24404825df22d2613db4b407e75803b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix clock ticks in test - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Fix clock ticks in test .. Fix clock ticks in test If the time is picked up several different places and compared there can be a "race condition" where the clock ticks and the tests fails because the time isn't equal anymore. This fixes one such case. Change-Id: I11e08591f24404825df22d2613db4b407e75803b --- M lib/tests/phpunit/changes/ChangeRowTest.php 1 file changed, 5 insertions(+), 3 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/lib/tests/phpunit/changes/ChangeRowTest.php b/lib/tests/phpunit/changes/ChangeRowTest.php index 17edf91..8db9111 100644 --- a/lib/tests/phpunit/changes/ChangeRowTest.php +++ b/lib/tests/phpunit/changes/ChangeRowTest.php @@ -152,9 +152,11 @@ * @dataProvider instanceProvider */ public function testGetAge( $changeRow ) { - $this->assertEquals( - time() - (int)wfTimestamp( TS_UNIX, '2013010100' ), - $changeRow->getAge() + // Don't assert on equalness because all previous code takes time! + $this->assertTrue( + // the time used is one above the minimum run time (4s) for the test, + // still the normal difference to observe would be 1s. + abs( ( time() - (int)wfTimestamp( TS_UNIX, '2013010100' ) ) - $changeRow->getAge() ) <= 5 ); } -- To view, visit https://gerrit.wikimedia.org/r/56152 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I11e08591f24404825df22d2613db4b407e75803b Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad Gerrit-Reviewer: Denny Vrandecic Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Introduced support for sub properties in SomeProperty descri... - change (mediawiki...Ask)
John Erling Blad has submitted this change and it was merged. Change subject: Introduced support for sub properties in SomeProperty description .. Introduced support for sub properties in SomeProperty description Change-Id: Icf9295a700cb32f98877f1755cd752ad9bcbc434 --- M includes/Ask/Language/Description/SomeProperty.php M tests/phpunit/Language/Description/SomePropertyTest.php 2 files changed, 81 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Ask/Language/Description/SomeProperty.php b/includes/Ask/Language/Description/SomeProperty.php index d851776..88c5166 100644 --- a/includes/Ask/Language/Description/SomeProperty.php +++ b/includes/Ask/Language/Description/SomeProperty.php @@ -3,6 +3,7 @@ namespace Ask\Language\Description; use DataValues\PropertyValue; +use InvalidArgumentException; /** * Description of a set of instances that have an attribute with some value @@ -40,6 +41,8 @@ final class SomeProperty extends Description implements \Ask\Immutable { /** +* The property that should be present. +* * @since 0.1 * * @var PropertyValue @@ -47,11 +50,27 @@ private $property; /** +* The description the properties value should match. +* * @since 0.1 * * @var Description */ private $description; + + /** +* If the property is a sub property or not. +* +* For instance in the Wikibase Claim context, +* a non-sub property would point to the property +* of the main snak, while a sub property would +* point to a qualifier. +* +* @since 0.1 +* +* @var boolean +*/ + private $isSubProperty; /** * Cache for the hash. @@ -69,10 +88,19 @@ * * @param PropertyValue $property * @param Description $description +* @param boolean $isSubProperty +* +* @throws InvalidArgumentException */ - public function __construct( PropertyValue $property, Description $description ) { + public function __construct( PropertyValue $property, Description $description, $isSubProperty = false ) { $this->property = $property; $this->description = $description; + + if ( !is_bool( $isSubProperty ) ) { + throw new InvalidArgumentException( '$isSubProperty must be of type boolean' ); + } + + $this->isSubProperty = $isSubProperty; } /** @@ -95,6 +123,17 @@ */ public function getProperty() { return $this->property; + } + + /** +* Returns if the property is a sub property. +* +* @since 0.1 +* +* @return boolean +*/ + public function isSubProperty() { + return $this->isSubProperty; } /** @@ -141,6 +180,7 @@ return array( 'property' => $this->property->toArray(), 'description' => $this->description->toArray(), + 'issubproperty' => $this->isSubProperty ); } @@ -155,6 +195,7 @@ */ public function equals( $mixed ) { return $mixed instanceof SomeProperty + && $this->isSubProperty === $mixed->isSubProperty() && $this->property->equals( $mixed->getProperty() ) && $this->description->equals( $mixed->getDescription() ); } @@ -168,7 +209,12 @@ */ public function getHash() { if ( $this->hash === null ) { - $this->hash = sha1( $this->getType() . $this->property->getHash() . $this->description->getHash() ); + $this->hash = sha1( + $this->getType() . + $this->property->getHash() . + $this->description->getHash() . + $this->isSubProperty + ); } return $this->hash; diff --git a/tests/phpunit/Language/Description/SomePropertyTest.php b/tests/phpunit/Language/Description/SomePropertyTest.php index ba7f39a..141da69 100644 --- a/tests/phpunit/Language/Description/SomePropertyTest.php +++ b/tests/phpunit/Language/Description/SomePropertyTest.php @@ -43,6 +43,8 @@ $instances[] = new SomeProperty( new PropertyValue( '_geo' ), new \Ask\Language\Description\AnyValue() ); $instances[] = new SomeProperty( new PropertyValue( 'p42' ), new \Ask\Language\Description\Conjunction( array() ) ); + $instances[] = new SomeProperty( n
[MediaWiki-commits] [Gerrit] Added docs to make danwe happy - change (mediawiki...Ask)
John Erling Blad has submitted this change and it was merged. Change subject: Added docs to make danwe happy .. Added docs to make danwe happy Change-Id: I91499981b27ebf2e76c2e756e66b9c91ee879ecf --- M includes/Ask/Language/Description/DescriptionCollection.php M includes/Ask/Language/Description/ValueDescription.php M includes/Ask/Language/Query.php M includes/Ask/Language/Selection/PropertySelection.php 4 files changed, 18 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Ask/Language/Description/DescriptionCollection.php b/includes/Ask/Language/Description/DescriptionCollection.php index 58c21c6..0547302 100644 --- a/includes/Ask/Language/Description/DescriptionCollection.php +++ b/includes/Ask/Language/Description/DescriptionCollection.php @@ -33,6 +33,8 @@ abstract class DescriptionCollection extends Description implements \Ask\Immutable { /** +* The descriptions that make up this collection of descriptions. +* * @since 0.1 * * @var Description[] diff --git a/includes/Ask/Language/Description/ValueDescription.php b/includes/Ask/Language/Description/ValueDescription.php index 072d8f7..58e0e0c 100644 --- a/includes/Ask/Language/Description/ValueDescription.php +++ b/includes/Ask/Language/Description/ValueDescription.php @@ -52,6 +52,8 @@ const COMP_GRTR = 8; // Strictly more than /** +* The value to compare to. +* * @since 0.1 * * @var DataValue @@ -59,6 +61,8 @@ protected $value; /** +* The comparator to use to determine if the value matches. +* * @since 0.1 * * @var int diff --git a/includes/Ask/Language/Query.php b/includes/Ask/Language/Query.php index 3992f58..6147347 100644 --- a/includes/Ask/Language/Query.php +++ b/includes/Ask/Language/Query.php @@ -39,6 +39,10 @@ const OPT_SORT = 'sort'; /** +* The query's description. +* This is the selection criterion of the query that determines which entities match. +* It is conceptually similar to the WHERE clause in an SQL query. +* * @since 0.1 * * @var Description @@ -46,6 +50,10 @@ protected $description; /** +* The query's selection requests. +* These determine which information should be selected from the matching entities. +* It is conceptually similar to the SELECT clause in an SQL query. +* * @since 0.1 * * @var SelectionRequest[] @@ -53,6 +61,8 @@ protected $selectionRequests; /** +* The query's options. +* * @since 0.1 * * @var QueryOptions diff --git a/includes/Ask/Language/Selection/PropertySelection.php b/includes/Ask/Language/Selection/PropertySelection.php index e41051a..41f410d 100644 --- a/includes/Ask/Language/Selection/PropertySelection.php +++ b/includes/Ask/Language/Selection/PropertySelection.php @@ -32,6 +32,8 @@ final class PropertySelection extends SelectionRequest implements \Ask\Immutable { /** +* The property for which to select values. +* * @since 0.1 * * @var PropertyValue -- To view, visit https://gerrit.wikimedia.org/r/50010 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I91499981b27ebf2e76c2e756e66b9c91ee879ecf Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Ask Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added getArrayValue to Query object - change (mediawiki...Ask)
John Erling Blad has submitted this change and it was merged. Change subject: Added getArrayValue to Query object .. Added getArrayValue to Query object Change-Id: I7b7cf5e5766f851f1c82e22cb25bbd5283da675f --- M includes/Ask/Language/Option/SortOptions.php M includes/Ask/Language/Query.php M tests/phpunit/AskTestCase.php M tests/phpunit/Language/QueryTest.php 4 files changed, 53 insertions(+), 5 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/includes/Ask/Language/Option/SortOptions.php b/includes/Ask/Language/Option/SortOptions.php index 39bd4de..e2ec3a5 100644 --- a/includes/Ask/Language/Option/SortOptions.php +++ b/includes/Ask/Language/Option/SortOptions.php @@ -70,8 +70,7 @@ */ public function getArrayValue() { return array( - // TODO: order of expressions is relevant - 'expressions' => array_map( + 'expressions' => (object)array_map( function( SortExpression $expression ) { return $expression->toArray(); }, diff --git a/includes/Ask/Language/Query.php b/includes/Ask/Language/Query.php index 6147347..3ae785b 100644 --- a/includes/Ask/Language/Query.php +++ b/includes/Ask/Language/Query.php @@ -32,7 +32,7 @@ * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > */ -class Query implements \Ask\Immutable { +class Query implements \Ask\Immutable, \Ask\ArrayValueProvider { const OPT_LIMIT = 'limit'; const OPT_OFFSET = 'offset'; @@ -117,4 +117,24 @@ return $this->options; } + /** +* @see ArrayValueProvider::getArrayValue +* +* @since 0.1 +* +* @return array|null|bool|int|float|string +*/ + public function getArrayValue() { + return array( + 'description' => $this->description->toArray(), + 'options' => $this->options->getArrayValue(), + 'selectionrequests' => (object)array_map( + function( SelectionRequest $selectionRequest ) { + return $selectionRequest->toArray(); + }, + $this->selectionRequests + ), + ); + } + } diff --git a/tests/phpunit/AskTestCase.php b/tests/phpunit/AskTestCase.php index e67e38c..143a408 100644 --- a/tests/phpunit/AskTestCase.php +++ b/tests/phpunit/AskTestCase.php @@ -51,7 +51,10 @@ } protected function assertPrimitiveStructure( $value ) { - if ( is_array( $value ) ) { + if ( is_array( $value ) || is_object( $value ) ) { + // TODO: would be good if we could reject objects that are not simple maps + $value = (array)$value; + if ( empty( $value ) ) { $this->assertTrue( true ); } @@ -61,7 +64,6 @@ } } else { - $this->assertFalse( is_object( $value ), 'Value should not be an object' ); $this->assertFalse( is_resource( $value ), 'Value should not be a resource' ); } } diff --git a/tests/phpunit/Language/QueryTest.php b/tests/phpunit/Language/QueryTest.php index eb46d6a..c606b14 100644 --- a/tests/phpunit/Language/QueryTest.php +++ b/tests/phpunit/Language/QueryTest.php @@ -86,4 +86,31 @@ $this->assertEquals( $selectionRequests, $obtainedRequests ); } + public function instanceProvider() { + $instances = array(); + + $instances[] = new Query( + new \Ask\Language\Description\AnyValue(), + array( + new \Ask\Language\Selection\PropertySelection( new \DataValues\PropertyValue( 'q42' ) ), + new \Ask\Language\Selection\PropertySelection( new \DataValues\PropertyValue( '_geo' ) ), + ), + new QueryOptions( 100, 0 ) + ); + + return $this->arrayWrap( $instances ); + } + + /** +* @dataProvider instanceProvider +* +* @since 0.1 +* +* @param Query $object +*/ + public function testReturnTypeOfGetArrayValue( Query $object ) { + $array = $object->getArrayValue(); + $this->assertPrimitiveStructure( $array ); + } + } -- To view, visit https://gerrit.wikimedia.org/r/50013 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged
[MediaWiki-commits] [Gerrit] Added normal-looking entry point so Jenkins is happy - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added normal-looking entry point so Jenkins is happy .. Added normal-looking entry point so Jenkins is happy Change-Id: Id92fbcf8997b607d2e4a1b854ca0af3953fb4633 --- A Wikibase.php 1 file changed, 33 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/Wikibase.php b/Wikibase.php new file mode 100644 index 000..9f46de0 --- /dev/null +++ b/Wikibase.php @@ -0,0 +1,33 @@ + + */ + +// @codeCoverageIgnoreStart +//call_user_func( function() { + $components = array( + 'lib/WikibaseLib', + 'client/WikibaseClient', + 'repo/Wikibase', + ); + + foreach ( $components as $component ) { + // Load extensions in non-global scope. + require_once __DIR__ . '/' . $component . '.php'; + } + +//} ); +// @codeCoverageIgnoreEnd -- To view, visit https://gerrit.wikimedia.org/r/44863 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id92fbcf8997b607d2e4a1b854ca0af3953fb4633 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Daniel Kinzler Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: Hashar Gerrit-Reviewer: Hoo man Gerrit-Reviewer: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Adding query definition to query entity - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Adding query definition to query entity .. Adding query definition to query entity Change-Id: Ide39070bed8262cb5846200137919ea771cdc381 --- M lib/includes/query/Query.php M lib/tests/phpunit/query/QueryTest.php 2 files changed, 64 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/lib/includes/query/Query.php b/lib/includes/query/Query.php index fd8e0d1..1e31712 100644 --- a/lib/includes/query/Query.php +++ b/lib/includes/query/Query.php @@ -2,6 +2,9 @@ namespace Wikibase; +use Ask\Language\Query as QueryDefinition; +use MWException; + /** * Represents a single Wikibase query. * @@ -24,6 +27,7 @@ * * @file * @ingroup WikibaseLib + * @ingroup WikibaseQuery * * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > @@ -33,6 +37,45 @@ const ENTITY_TYPE = 'query'; /** +* @since 0.4 +* +* @var QueryDefinition|null +*/ + protected $queryDefinition = null; + + /** +* Returns the QueryDefinition of the query entity. +* +* @since 0.4 +* +* @return QueryDefinition +* @throws MWException +*/ + public function getQueryDefinition() { + if ( $this->queryDefinition === null ) { + if ( array_key_exists( 'querydefinition', $this->data ) ) { + // TODO + } + else { + throw new MWException( 'The QueryDefinition of the query is not known' ); + } + } + + return $this->queryDefinition; + } + + /** +* Sets the QueryDefinition of the query entity. +* +* @since 0.4 +* +* @param QueryDefinition $queryDefinition +*/ + public function setQueryDefinition( QueryDefinition $queryDefinition ) { + $this->queryDefinition = $queryDefinition; + } + + /** * @see Entity::newFromArray * * @since 0.1 diff --git a/lib/tests/phpunit/query/QueryTest.php b/lib/tests/phpunit/query/QueryTest.php index cca8b6c..7589057 100644 --- a/lib/tests/phpunit/query/QueryTest.php +++ b/lib/tests/phpunit/query/QueryTest.php @@ -1,7 +1,8 @@ setQueryDefinition( $queryDefinition ); + + $obtainedDefinition = $query->getQueryDefinition(); + + $this->assertInstanceOf( 'Ask\Language\Query', $obtainedDefinition ); + $this->assertEquals( $queryDefinition, $obtainedDefinition ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/48819 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ide39070bed8262cb5846200137919ea771cdc381 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] More query store code prototyping - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: More query store code prototyping .. More query store code prototyping Code still not registered Now making use of MessageReporter interface, see https://gerrit.wikimedia.org/r/#/c/50042/ Change-Id: If7432fb5336e1128043b0c503c10ed2e7ceb4ae1 --- M repo/includes/Database/TableBuilder.php M repo/includes/Query/QueryStore.php M repo/includes/Query/SQLStore/Setup.php M repo/includes/Query/SQLStore/Store.php 4 files changed, 144 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/TableBuilder.php b/repo/includes/Database/TableBuilder.php index d288b0a..14f25e7 100644 --- a/repo/includes/Database/TableBuilder.php +++ b/repo/includes/Database/TableBuilder.php @@ -2,6 +2,8 @@ namespace Wikibase\Repo\Database; +use MessageReporter; + /** * Object that can create a table in a database given a table definition. * @@ -30,12 +32,56 @@ */ class TableBuilder { - public function __construct( QueryInterface $queryInterface ) { + /** +* @since 0.4 +* +* @var QueryInterface +*/ + private $db; + /** +* @since 0.4 +* +* @var MessageReporter|null +*/ + private $messageReporter; + + /** +* Constructor. +* +* @since 0.4 +* +* @param QueryInterface $queryInterface +*/ + public function __construct( QueryInterface $queryInterface, MessageReporter $messageReporter = null ) { + $this->db = $queryInterface; + $this->messageReporter = $messageReporter; } - public function createTable( TableDefinition $table ) { + /** +* @since 0.4 +* +* @param string $message +*/ + private function report( $message ) { + if ( $this->messageReporter !== null ) { + $this->messageReporter->reportMessage( $message ); + } + } + /** +* Creates a table if it does not exist yet. +* +* @since 0.4 +* +* @param TableDefinition $table +*/ + public function createTable( TableDefinition $table ) { + if ( $this->db->tableExists( $table->getName() ) ) { + $this->report( 'Table "' . $table->getName() . '" exists already, skipping.' ); + } + + // TODO } } \ No newline at end of file diff --git a/repo/includes/Query/QueryStore.php b/repo/includes/Query/QueryStore.php index 870945a..7d2768e 100644 --- a/repo/includes/Query/QueryStore.php +++ b/repo/includes/Query/QueryStore.php @@ -6,4 +6,11 @@ // TODO + /** +* @since 0.4 +* +* @return string +*/ + public function getName(); + } \ No newline at end of file diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 01864c5..174595e 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -2,8 +2,76 @@ namespace Wikibase\Repo\Query\SQLStore; +use Wikibase\Repo\Database\TableBuilder; +use MessageReporter; + class Setup { + /** +* @var Store +*/ + private $store; + + /** +* @var TableBuilder +*/ + private $tableBuilder; + + /** +* @since 0.4 +* +* @var MessageReporter|null +*/ + private $messageReporter; + + /** +* @since 0.4 +* +* @param Store $sqlStore +* @param TableBuilder $tableBuilder +*/ + public function __construct( Store $sqlStore, TableBuilder $tableBuilder, MessageReporter $messageReporter = null ) { + $this->store = $sqlStore; + $this->tableBuilder = $tableBuilder; + } + + /** +* @since 0.4 +* +* @param string $message +*/ + private function report( $message ) { + if ( $this->messageReporter !== null ) { + $this->messageReporter->reportMessage( $message ); + } + } + + /** +* Run the setup. +* +* @since 0.4 +*/ + public function run() { + $this->report( 'Starting setup of ' . $this->store->getName() ); + + $this->setupTables(); + + // TODO + + $this->report( 'Finished setup of ' . $this->store->getName() ); + } + + /** +* Sets up the tables of the store. +* +* @since 0.4 +*/ + private function setupTables() { + foreach ( $this->store->getTables() as $table ) { + $this->tableBuilder->createTable( $table ); + }
[MediaWiki-commits] [Gerrit] Only load lib and repo - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Only load lib and repo .. Only load lib and repo Also removed attempt to load from function scope as this does not work with current Wikibase code Change-Id: I6fdeae73567c22986ae0531436b9c681665bc760 --- M Wikibase.php 1 file changed, 2 insertions(+), 15 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/Wikibase.php b/Wikibase.php index 9f46de0..06bd8e0 100644 --- a/Wikibase.php +++ b/Wikibase.php @@ -16,18 +16,5 @@ * @author Jeroen De Dauw < jeroended...@gmail.com > */ -// @codeCoverageIgnoreStart -//call_user_func( function() { - $components = array( - 'lib/WikibaseLib', - 'client/WikibaseClient', - 'repo/Wikibase', - ); - - foreach ( $components as $component ) { - // Load extensions in non-global scope. - require_once __DIR__ . '/' . $component . '.php'; - } - -//} ); -// @codeCoverageIgnoreEnd +require_once __DIR__ . '/lib/WikibaseLib.php'; +require_once __DIR__ . '/repo/Wikibase.php'; -- To view, visit https://gerrit.wikimedia.org/r/50162 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6fdeae73567c22986ae0531436b9c681665bc760 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Set entity field as expected - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Set entity field as expected .. Set entity field as expected Fixes this failing test 1) Wikibase\Test\EntityCacheUpdaterTest::testHandleChange MWException: The provided Change does not contain full entity data! /home/j/www/phase3/extensions/Wikibase/client/includes/EntityCacheUpdater.php:50 /home/j/www/phase3/extensions/Wikibase/client/tests/phpunit/includes/EntityCacheUpdaterTest.php:71 /home/j/www/phase3/tests/phpunit/MediaWikiTestCase.php:116 /home/j/www/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php:63 /home/j/www/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php:47 Change-Id: Ic498d01aac986f060ffeaa95bc57813dc974d5cd --- M lib/includes/changes/EntityChange.php 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/lib/includes/changes/EntityChange.php b/lib/includes/changes/EntityChange.php index 71e8a40..1b16a22 100644 --- a/lib/includes/changes/EntityChange.php +++ b/lib/includes/changes/EntityChange.php @@ -316,6 +316,7 @@ $diff = $oldEntity->getDiff( $newEntity ); $instance = self::newForEntity( $action, $theEntity->getId(), $fields ); $instance->setDiff( $diff ); + $instance->setEntity( $theEntity ); return $instance; } -- To view, visit https://gerrit.wikimedia.org/r/50290 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic498d01aac986f060ffeaa95bc57813dc974d5cd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Daniel Kinzler Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove empty test cases - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Remove empty test cases .. Remove empty test cases Change-Id: I11bbd3160748b22bacac1d8df7167c6ad2a5a38b --- M client/WikibaseClient.hooks.php D client/tests/phpunit/includes/store/CachingSqlStoreTest.php D client/tests/phpunit/includes/store/DirectSqlStoreTest.php 3 files changed, 0 insertions(+), 78 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index cd42d86..198f95b 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -86,8 +86,6 @@ 'includes/api/ApiClientInfo', 'includes/store/EntityCacheTable', - 'includes/store/CachingSqlStore', - 'includes/store/DirectSqlStore', 'MockRepository', ); diff --git a/client/tests/phpunit/includes/store/CachingSqlStoreTest.php b/client/tests/phpunit/includes/store/CachingSqlStoreTest.php deleted file mode 100644 index 5b9d67a..000 --- a/client/tests/phpunit/includes/store/CachingSqlStoreTest.php +++ /dev/null @@ -1,38 +0,0 @@ -http://www.gnu.org/copyleft/gpl.html - * - * @file - * @since 0.3 - * - * @ingroup WikibaseClient - * @ingroup Test - * - * @group Wikibase - * @group WikibaseClient - * @group WikibaseEntityLookup - * - * @licence GNU GPL v2+ - * @author Daniel Kinzler - */ -class CachingSqlStoreTest extends \MediaWikiTestCase { - -} diff --git a/client/tests/phpunit/includes/store/DirectSqlStoreTest.php b/client/tests/phpunit/includes/store/DirectSqlStoreTest.php deleted file mode 100644 index 1dcdacd..000 --- a/client/tests/phpunit/includes/store/DirectSqlStoreTest.php +++ /dev/null @@ -1,38 +0,0 @@ -http://www.gnu.org/copyleft/gpl.html - * - * @file - * @since 0.3 - * - * @ingroup WikibaseClient - * @ingroup Test - * - * @group Wikibase - * @group WikibaseClient - * @group WikibaseEntityLookup - * - * @licence GNU GPL v2+ - * @author Daniel Kinzler - */ -class DirectSqlStoreTest extends \MediaWikiTestCase { - -} -- To view, visit https://gerrit.wikimedia.org/r/50294 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I11bbd3160748b22bacac1d8df7167c6ad2a5a38b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Kinzler Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45111) Fix the squashing of whitespace and control chars - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/50365 Change subject: (Bug 45111) Fix the squashing of whitespace and control chars .. (Bug 45111) Fix the squashing of whitespace and control chars Change-Id: Icc9e48d33b9f5c4ae0a3fd8000c4c54d2883b66d --- M lib/includes/Term.php M lib/includes/Utils.php M lib/tests/phpunit/UtilsTest.php M repo/includes/Autocomment.php M repo/includes/api/ApiEditEntity.php M repo/includes/api/ApiGetEntities.php M repo/includes/api/ApiModifyEntity.php M repo/includes/api/ApiSetAliases.php M repo/includes/api/ApiSetDescription.php M repo/includes/api/ApiSetLabel.php M repo/includes/api/ApiSetSiteLink.php M repo/includes/specials/SpecialCreateEntity.php A repo/maintenance/rebuildSummaryPerEntity.php 13 files changed, 139 insertions(+), 49 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/65/50365/1 diff --git a/lib/includes/Term.php b/lib/includes/Term.php index 3de40f3..dbfaad2 100644 --- a/lib/includes/Term.php +++ b/lib/includes/Term.php @@ -233,7 +233,7 @@ // But that requires us to load ALL the language objects, // which loads ALL the messages, which makes us run out // of RAM (see bug 41103). - return mb_strtolower( Utils::squashToNFC( $text ) ); + return mb_strtolower( Utils::trimToNFC( $text ) ); } /** diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php index d9dcf5b..ac5f5d8 100644 --- a/lib/includes/Utils.php +++ b/lib/includes/Utils.php @@ -179,17 +179,27 @@ } /** -* Trim initial and trailing whitespace, and compress internal ones. +* Trim initial and trailing whitespace and control chars, and optionally compress internal ones. * * @since 0.1 * * @param string $inputString The actual string to process. +* @param boolean $squashInternal If the internal spaces should also be fixed. * * @return string where whitespace possibly are removed. */ - static public function squashWhitespace( $inputString ) { - $trimmed = preg_replace( '/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $inputString ); - return preg_replace('/[\pZ\pC]+/u', ' ', $trimmed ); + static public function trimWhitespace( $inputString, $squashInternal = true ) { + // strip initial/trailing whitespace and control chars + $trimmed = preg_replace( '/^[\p{Z}\p{Cc}]+|[\p{Z}\p{Cc}]+$/u', '', $inputString ); + if ( $squashInternal === true ) { + // replace inner space and control chars with space + $trimmed = preg_replace( '/[\p{Z}\p{Cc}]+/u', ' ', $trimmed ); + } + else { + // replace inner space and control chars with space + $trimmed = preg_replace( '/[\p{Cc}]/u', ' ', $trimmed ); + } + return $trimmed; } /** @@ -211,11 +221,12 @@ * @since 0.1 * * @param string $inputString +* @param boolean $squashInternal If the internal spaces should also be fixed. * * @return string on NFC form */ - static public function squashToNFC( $inputString ) { - return self::cleanupToNFC( self::squashWhitespace( $inputString ) ); + static public function trimToNFC( $inputString, $squashInternal = true ) { + return self::cleanupToNFC( self::trimWhitespace( $inputString, $squashInternal ) ); } /** diff --git a/lib/tests/phpunit/UtilsTest.php b/lib/tests/phpunit/UtilsTest.php index 819c015..b786c58 100644 --- a/lib/tests/phpunit/UtilsTest.php +++ b/lib/tests/phpunit/UtilsTest.php @@ -46,21 +46,28 @@ /** * @group WikibaseUtils -* @dataProvider providerSquashWhitespace +* @dataProvider providerTrimWhitespace */ - public function testSquashWhitespace( $string, $expected ) { - $this->assertEquals( $expected, Utils::squashWhitespace( $string ) ); + public function testTrimWhitespace( $string, $squashInner, $expected ) { + $this->assertEquals( $expected, Utils::trimWhitespace( $string, $squashInner ) ); } - public static function providerSquashWhitespace() { + public static function providerTrimWhitespace() { return array( - array( 'foo bar', 'foo bar'), - array( ' foo bar ', 'foo bar'), - array( ' foo bar ', 'foo bar'), - array( "foo\tbar", 'foo bar'), - array( "foo\nbar", 'foo bar'), - array( "foo\rbar", 'foo bar'), - array( "\r
[MediaWiki-commits] [Gerrit] Add Special:ItemsWithoutSitelinks that list all items withou... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Add Special:ItemsWithoutSitelinks that list all items without any site link .. Add Special:ItemsWithoutSitelinks that list all items without any site link Edits also the label of Special:EntitiesWithoutLabel to be consistent with the others special page names. Change-Id: I032208726699d104c8ee76ef97e3f61b5f78f334 --- M repo/Wikibase.i18n.alias.php M repo/Wikibase.i18n.php M repo/Wikibase.php M repo/includes/specials/SpecialEntitiesWithoutLabel.php A repo/includes/specials/SpecialItemsWithoutSitelinks.php M repo/includes/store/EntityPerPage.php M repo/includes/store/sql/EntityPerPageTable.php 7 files changed, 158 insertions(+), 6 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/Wikibase.i18n.alias.php b/repo/Wikibase.i18n.alias.php index 3e652a7..ab4fc8d 100644 --- a/repo/Wikibase.i18n.alias.php +++ b/repo/Wikibase.i18n.alias.php @@ -26,6 +26,7 @@ 'SetDescription' => array( 'SetDescription' ), 'SetAliases' => array( 'SetAliases' ), 'EntitiesWithoutLabel' => array( 'EntitiesWithoutLabel' ), + 'ItemsWithoutSitelinks' => array( 'ItemsWithoutSitelinks' ), ); /** Arabic (العربية) */ @@ -195,4 +196,4 @@ 'ItemDisambiguation' => array( '项目消歧义' ), 'ListDatatypes' => array( '列出数据类型' ), 'SetLabel' => array( '设置标签' ), -); \ No newline at end of file +); diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index a98c028..224f97c 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -172,11 +172,12 @@ 'wikibase-listdatatypes-intro' => 'This is a list of all datatypes currently in use on this installation:', 'wikibase-history-title-with-label' => 'Revision history of "$2" ($1)', 'wikibase-history-title-without-label' => 'Revision history of ($1)', - 'special-entitieswithoutlabel' => 'List of entities without label', + 'special-entitieswithoutlabel' => 'Entities without label', 'wikibase-entitieswithoutlabel-legend' => 'Get list of entities without label', 'wikibase-entitieswithoutlabel-label-language' => 'Language:', 'wikibase-entitieswithoutlabel-submit' => 'Find', 'wikibase-entitieswithoutlabel-invalid-language' => '"$1" is not a valid language code.', + 'special-itemswithoutsitelinks' => 'Items without sitelinks', 'special-entitydata' => 'Entity data', 'wikibase-entitydata-not-found' => "No entity with ID $1 was found.", 'wikibase-entitydata-bad-revision' => "Can't show revision $2 of entity $1.", @@ -585,6 +586,7 @@ 'wikibase-entitieswithoutlabel-label-language' => 'Label for the input field to change the language.', 'wikibase-entitieswithoutlabel-submit' => 'Label for the button that activate the action.', 'wikibase-entitieswithoutlabel-invalid-language' => 'Error message shown when the language code passed in parameter is invalid. $1 is invalid language code.', + 'special-itemswithoutsitelinks' => 'This special page returns a list of items without any site link', 'special-entitydata' => 'Title for special page that provides a linked data interface and easy way to get the JSON data representation for an entity.', 'wikibase-entitydata-not-found' => 'Error shown when no entity with the given ID could be found. Paramters: * $1 is the given ID', diff --git a/repo/Wikibase.php b/repo/Wikibase.php index cb3eae7..2111cee 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -157,6 +157,8 @@ $wgAutoloadClasses['Wikibase\ItemHandler'] = $dir . 'includes/content/ItemHandler.php'; $wgAutoloadClasses['Wikibase\PropertyContent'] = $dir . 'includes/content/PropertyContent.php'; $wgAutoloadClasses['Wikibase\PropertyHandler'] = $dir . 'includes/content/PropertyHandler.php'; +$wgAutoloadClasses['Wikibase\QueryContent']= $dir . 'includes/content/QueryContent.php'; +$wgAutoloadClasses['Wikibase\QueryHandler']= $dir . 'includes/content/QueryHandler.php'; // includes/specials $wgAutoloadClasses['SpecialCreateEntity'] = $dir . 'includes/specials/SpecialCreateEntity.php'; @@ -170,6 +172,7 @@ $wgAutoloadClasses['SpecialSetDescription']= $dir . 'includes/specials/SpecialSetDescription.php'; $wgAutoloadClasses['SpecialSetAliases']= $dir . 'includes/specials/SpecialSetAliases.php'; $wgAutoloadClasses['SpecialEntitiesWithoutLabel'] = $dir . 'includes/specials/SpecialEntitiesWithoutLabel.php'; +$wgAutoloadClasses['SpecialItemsWithoutSitelinks'] = $dir . 'includes/specials/SpecialItemsWithoutSitelinks.php'; $wgAutoloadClasses['SpecialListDatatypes'] =
[MediaWiki-commits] [Gerrit] Use anon function to not polute global scope with function d... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Use anon function to not polute global scope with function definition .. Use anon function to not polute global scope with function definition Change-Id: I9fd07173ab18b78a8e1b91b138401acfee0e80d2 --- M lib/WikibaseLib.php 1 file changed, 2 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php index 6502323..abe0c98 100644 --- a/lib/WikibaseLib.php +++ b/lib/WikibaseLib.php @@ -221,9 +221,7 @@ $wgAutoloadClasses['Wikibase\Lib\Test\Serializers\UnserializerBaseTest'] = $dir . 'tests/phpunit/serializers/UnserializerBaseTest.php'; // TODO: this is not nice, figure out a better design -$wgExtensionFunctions[] = 'efWikibaseLib'; - -function efWikibaseLib() { +$wgExtensionFunctions[] = function() { global $wgDataTypes; $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); @@ -236,7 +234,7 @@ \Wikibase\TemplateRegistry::singleton()->addTemplates( include( __DIR__ . "/resources/templates.php" ) ); return true; -} +}; $wgValueParsers['wikibase-entityid'] = 'Wikibase\Lib\EntityIdParser'; $wgDataValues['wikibase-entityid'] = 'Wikibase\EntityId'; -- To view, visit https://gerrit.wikimedia.org/r/50493 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9fd07173ab18b78a8e1b91b138401acfee0e80d2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cleanup client example settings - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Cleanup client example settings .. Cleanup client example settings * Config now in config directory as done in repo * Example settings no longer include client and lib entrypoint Change-Id: I9f3670f16fb32019463a5c5b8cdc4d2ee147d848 --- M client/ExampleSettings.php A client/config/WikibaseClient.example.php 2 files changed, 121 insertions(+), 91 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/client/ExampleSettings.php b/client/ExampleSettings.php index fe2b338..dd9aa91 100644 --- a/client/ExampleSettings.php +++ b/client/ExampleSettings.php @@ -1,94 +1,5 @@ http://repo.example.org/wiki/"; -// This can be protocol relative, such as "//wikidata.org" -$wgWBSettings['repoUrl'] = "http://repo.example.org";; - -// This setting is optional if you have the same type of setup for your -// repo and client. It will default to using the client's $wgArticlePath setting, -// and if you do not have $wgArticlePath set anywhere, MediaWiki has a default for it. -$wgWBSettings['repoArticlePath'] = "/wiki/$1"; - -// Assuming your wiki is setup with such script path as "http://repo.example.org/w/api.php"; -// This should be the same as the $wgScriptPath setting if you have it set in your repo -// If $wgScriptPath is not set, then MediaWiki assumes a default. -// -// If your client and repo are setup in the same way, then the below setting is optional -// and will default to what you have $wgScriptPath set in the client. -$wgWBSettings['repoScriptPath'] = "/w"; - -// The global site ID by which this wiki is known on the repo. -$wgWBSettings['siteGlobalID'] = "mywiki"; - -// Database name of the repository, for use by the pollForChanges script. -// This requires the given database name to be known to LBFactory, see -// $wgLBFactoryConf below. -$wgWBSettings['changesDatabase'] = "repo"; - -$wgWBSettings['injectRecentChanges'] = true; -$wgWBSettings['showExternalRecentChanges'] = true; - -$wgLBFactoryConf = array( - // In order to seamlessly access a remote wiki, as the pollForChanges script needs to do, - // LBFactory_Multi must be used. - 'class' => 'LBFactory_Multi', - - // Connect to all databases using the same credentials. - 'serverTemplate' => array( - 'dbname' => $wgDBname, - 'user'=> $wgDBuser, - 'password'=> $wgDBpassword, - 'type'=> 'mysql', - 'flags' => DBO_DEFAULT | DBO_DEBUG, - ), - - // Configure two sections, one for the repo and one for the client. - // Each section contains only one server. - 'sectionLoads' => array( - 'DEFAULT' => array( - 'localhost' => 1, - ), - 'repo' => array( - 'local1' => 1, - ), - ), - - // Map the wiki database names to sections. Database names must be unique, - // i.e. may not exist in more than one section. - 'sectionsByDB' => array( - $wgDBname => 'DEFAULT', - 'repowiki' => 'repo', - ), - - // Map host names to IP addresses to bypass DNS. - // - // NOTE: Even if all sections run on the same MySQL server (typical for a test setup), - // they must use different IP addresses, and MySQL must listen on all of them. - // The easiest way to do this is to set bind-address = 0.0.0.0 in the MySQL - // configuration. Beware that this makes MySQL listen on you ethernet port too. - // Safer alternatives include setting up mysql-proxy or mysqld_multi. - // - // For this setup to work a valid user must be set up for each of the addresses you use, - // that is grant access to the wikiuser for each of them. Failure to do so will make the - // MySQL server refuse access. - 'hostsByName' => array( - 'localhost' => '127.0.0.1:3306', - 'local1' => '127.0.2.1', - 'local2' => '127.0.2.2', - 'local3' => '127.0.2.3', - ), - - // Set up as fake master, because there are no slaves. - 'masterTemplateOverrides' => array( 'fakeMaster' => true ), -); - +include_once( __DIR__ . '/config/WikibaseClient.example.php' ); diff --git a/client/config/WikibaseClient.example.php b/client/config/WikibaseClient.example.php new file mode 100644 index 000..161fada --- /dev/null +++ b/client/config/WikibaseClient.example.php @@ -0,0 +1,119 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since 0.4 + * + * @file + * @ingroup WikibaseClient + * + * @licence GNU GPL v2+ + * @author Daniel Kinzler + */ + +if ( !defined( 'WB_CLIENT_EXAMPLE_ENTRY' ) ) { + die( 'Not an entry point.' ); +} + +// Base URL for building links to the repository. +// Assumes your wiki
[MediaWiki-commits] [Gerrit] Add composer to make the project accessible from packagist/c... - change (mediawiki...DataValues)
John Erling Blad has submitted this change and it was merged. Change subject: Add composer to make the project accessible from packagist/composer .. Add composer to make the project accessible from packagist/composer Change-Id: I6269adce9ee2833a412cced6b1aad3fbab0907d3 --- A composer.json 1 file changed, 11 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/composer.json b/composer.json new file mode 100644 index 000..d3342fa --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ +"name": "mediawiki/data-values", +"type": "mediawiki-extension", +"description": "A collection of objects representing various kinds of values.", +"homepage": "http://www.mediawiki.org/wiki/Extension:DataValues";, +"license" : "GPL-2.0+", + +"require": { +"composer/installers" : "*" +} +} -- To view, visit https://gerrit.wikimedia.org/r/50483 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6269adce9ee2833a412cced6b1aad3fbab0907d3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Fale Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] dv.util.inherit has new parameter for defining a constructor... - change (mediawiki...DataValues)
John Erling Blad has submitted this change and it was merged. Change subject: dv.util.inherit has new parameter for defining a constructor's name .. dv.util.inherit has new parameter for defining a constructor's name - patch set 2: filter malicious characters from name given to inherit() Change-Id: I78bbf26d8d241574773888a3aa28bc12d34f1b46 --- M DataValues/resources/dataValues.util.js M DataValues/tests/qunit/dataValues.util.inherit.tests.js 2 files changed, 94 insertions(+), 19 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved Henning Snater: Verified jenkins-bot: Checked diff --git a/DataValues/resources/dataValues.util.js b/DataValues/resources/dataValues.util.js index 8788167..d64c70d 100644 --- a/DataValues/resources/dataValues.util.js +++ b/DataValues/resources/dataValues.util.js @@ -2,7 +2,7 @@ * @file * @ingroup DataValues * @licence GNU GPL v2+ - * @author Daniel Werner + * @author Daniel Werner < daniel.wer...@wikimedia.de > */ ( function( $, dv ) { 'use strict'; @@ -18,16 +18,25 @@ * Helper for prototypical inheritance. * @since 0.1 * -* @param {Function} base Constructor which will be used for the prototype chain. +* @param {string} name (optional) The name of the new constructor. This is handy for debugging +*purposes since instances of the constructor might be displayed under that name. +* @param {Function} base Constructor which will be used for the prototype chain. This function +*will not be the constructor returned by the function but will be called by it. * @param {Function} [constructor] for overwriting base constructor. Can be omitted. * @param {Object} [members] properties overwriting or extending those of the base. * @return Function Constructor of the new, extended type. +* +* @throws {Error} In case a malicious function name is given or a reserved word is used */ - dv.util.inherit = function( base, constructor, members ) { - // allow to omit constructor since it can be inherited directly. But if given, require it as - // second parameter for readability. If no constructor, second parameter is the prototype - // extension object. - if( members === undefined ) { + dv.util.inherit = function( name, base, constructor, members ) { + // the name is optional + if( typeof name !== 'string' ) { + members = constructor; constructor = base; base = name; name = false; + } + + // allow to omit constructor since it can be inherited directly. But if given, require it as second parameter + // for readability. If no constructor, second parameter is the prototype extension object. + if( !members ) { if( $.isFunction( constructor ) ) { members = {}; } else { @@ -35,7 +44,22 @@ constructor = false; } } - var NewConstructor = constructor || function() { base.apply( this, arguments ); }; + // if no name is given, find suitable constructor's name + name = name || constructor.name || ( base.name ? base.name + '_SubProto' : 'SomeInherited' ); + // make sure name is just a function name and not some executable JavaScript + name = name.replace( /(?:(^\d+)|[^\w$])/ig, '' ); + + if( !name ) { // only bad characters were in the name! + throw new Error( 'Bad constructor name given. Only word characters and $ are allowed.' ); + } + + // function we execute in our real constructor created by evil eval: + var evilsSeed = constructor || base, + NewConstructor; + + // for creating a named function with a variable name, there is just no other way... + eval( 'NewConstructor = function ' + name + + '(){ evilsSeed.apply( this, arguments ); }' ); var NewPrototype = function(){}; // new constructor for avoiding base constructor and with it any side-effects NewPrototype.prototype = base.prototype; diff --git a/DataValues/tests/qunit/dataValues.util.inherit.tests.js b/DataValues/tests/qunit/dataValues.util.inherit.tests.js index d09b35f..a301bdd 100644 --- a/DataValues/tests/qunit/dataValues.util.inherit.tests.js +++ b/DataValues/tests/qunit/dataValues.util.inherit.tests.js @@ -8,7 +8,7 @@ * @licence GNU GPL v2+ * @author Daniel Werner */ -( function( dv, $, QUnit, undefined ) { +( function( dv, $, QUnit ) { 'use strict'; QUnit.module( 'dataValues.uti
[MediaWiki-commits] [Gerrit] Add MessageReporter since core CR is slow as usual - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Add MessageReporter since core CR is slow as usual .. Add MessageReporter since core CR is slow as usual Change-Id: I8575626363e2e57e66016ee5448df4249ab4e9f1 --- M repo/config/Wikibase.experimental.php A repo/includes/MessageReporter.php 2 files changed, 132 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index bb3a70c..e2c7650 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -45,6 +45,13 @@ $wgAutoloadClasses['Wikibase\QueryContent']= $dir . 'includes/content/QueryContent.php'; $wgAutoloadClasses['Wikibase\QueryHandler']= $dir . 'includes/content/QueryHandler.php'; + +if ( !class_exists( 'MessageReporter' ) ) { + $wgAutoloadClasses['MessageReporter'] = $dir . 'includes/MessageReporter.php'; + $wgAutoloadClasses['ObservableMessageReporter'] = $dir . 'includes/MessageReporter.php'; +} + + $wgAPIModules['wbremovequalifiers']= 'Wikibase\Repo\Api\RemoveQualifiers'; $wgAPIModules['wbsetqualifier']= 'Wikibase\Repo\Api\SetQualifier'; $wgAPIModules['wbsetstatementrank']= 'Wikibase\Api\SetStatementRank'; diff --git a/repo/includes/MessageReporter.php b/repo/includes/MessageReporter.php new file mode 100644 index 000..fd13294 --- /dev/null +++ b/repo/includes/MessageReporter.php @@ -0,0 +1,125 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since 1.21 + * @file + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +interface MessageReporter { + + /** +* Report the provided message. +* +* @since 1.21 +* +* @param string $message +*/ + public function reportMessage( $message ); + +} + +/** + * Message reporter that reports messages by passing them along to all + * registered handlers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @since 1.21 + * @file + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class ObservableMessageReporter implements MessageReporter { + + /** +* @since 1.21 +* +* @var MessageReporter[] +*/ + protected $reporters = array(); + + /** +* @since 1.21 +* +* @var callable[] +*/ + protected $callbacks = array(); + + /** +* @see MessageReporter::report +* +* @since 1.21 +* +* @param string $message +*/ + public function reportMessage( $message ) { + foreach ( $this->reporters as $reporter ) { + $reporter->reportMessage( $message ); + } + + foreach ( $this->callbacks as $callback ) { + call_user_func( $callback, $message ); + } + } + + /** +* Register a new message reporter. +* +* @since 1.21 +* +* @param MessageReporter $reporter +*/ + public function registerMessageReporter( MessageReporter $reporter ) { + $this->reporters[] = $reporter; + } + + /** +* Register a callback as message reporter. +* +* @since 1.21 +* +* @param callable $handler +*/ + public function registerReporterCallback( $handler ) { + $this->callbacks[] = $handler; + } + +} -- To view, visit https://gerrit.wikimedia.org/r/50629 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8575626363e2e57e66016ee5448df4249ab4e9f1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Daniel Kinzler Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: Jens Ohlig Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot
[MediaWiki-commits] [Gerrit] Registered Wikibase\Repo\Database classes and added test for... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Registered Wikibase\Repo\Database classes and added test for FieldDefinition .. Registered Wikibase\Repo\Database classes and added test for FieldDefinition Change-Id: I97f40f5b51f6a39e9deaa286b5fdcd4f9b7498a7 --- M repo/Wikibase.hooks.php M repo/config/Wikibase.experimental.php M repo/includes/Database/FieldDefinition.php M repo/includes/Query/SQLStore/Setup.php A repo/tests/phpunit/includes/Database/FieldDefinitionTest.php 5 files changed, 133 insertions(+), 3 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index c1c7b88..002f238 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -185,6 +185,8 @@ 'content/PropertyContent', 'content/PropertyHandler', + 'Database/FieldDefinition', + 'specials/SpecialCreateItem', 'specials/SpecialItemDisambiguation', 'specials/SpecialItemByTitle', diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index e2c7650..57d6fb5 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -46,6 +46,18 @@ $wgAutoloadClasses['Wikibase\QueryHandler']= $dir . 'includes/content/QueryHandler.php'; + +foreach ( array( + 'Wikibase\Repo\Database\FieldDefinition', + 'Wikibase\Repo\Database\MediaWikiQueryInterface', + 'Wikibase\Repo\Database\QueryInterface', + 'Wikibase\Repo\Database\TableBuilder', + 'Wikibase\Repo\Database\TableDefinition', + ) as $class ) { + + $wgAutoloadClasses[$class] = $dir . 'includes' . str_replace( '\\', '/', substr( $class, 13 ) ) . '.php'; +} + if ( !class_exists( 'MessageReporter' ) ) { $wgAutoloadClasses['MessageReporter'] = $dir . 'includes/MessageReporter.php'; $wgAutoloadClasses['ObservableMessageReporter'] = $dir . 'includes/MessageReporter.php'; diff --git a/repo/includes/Database/FieldDefinition.php b/repo/includes/Database/FieldDefinition.php index 9672d3d..01f3024 100644 --- a/repo/includes/Database/FieldDefinition.php +++ b/repo/includes/Database/FieldDefinition.php @@ -70,7 +70,7 @@ /** * @since 0.4 * -* @var string +* @var string|null */ private $index; @@ -96,7 +96,7 @@ * @param mixed $default * @param string|null $attributes * @param boolean $null -* @param string $index +* @param string|null $index * @param boolean $autoIncrement * * @throws InvalidArgumentException @@ -114,7 +114,7 @@ throw new InvalidArgumentException( 'The $null parameter needs to be a boolean' ); } - if ( !is_string( $autoIncrement ) ) { + if ( !is_null( $index ) && !is_string( $index ) ) { throw new InvalidArgumentException( 'The $index parameter needs to be a string' ); } diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 174595e..489026c 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -29,6 +29,7 @@ * * @param Store $sqlStore * @param TableBuilder $tableBuilder +* @param MessageReporter|null $messageReporter */ public function __construct( Store $sqlStore, TableBuilder $tableBuilder, MessageReporter $messageReporter = null ) { $this->store = $sqlStore; diff --git a/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php b/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php new file mode 100644 index 000..29943f8 --- /dev/null +++ b/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php @@ -0,0 +1,115 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since 0.4 + * + * @ingroup WikibaseRepoTest + * + * @group Wikibase + * @group WikibaseRepo + * @group WikibaseDatabase + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class FieldDefinitionTest extends \MediaWikiTestCase { + + public function instanceProvider() { + $instances = array(); + + $instances[] = new FieldDefinition( + 'names', + FieldDefinition::TYPE_TEXT + ); + + $instances[] = new FieldDefinition( + 'numbers', + FieldDefinition::TYPE_FLOAT + ); + + $instances[] = new FieldDefinition( +
[MediaWiki-commits] [Gerrit] Added TableDefinitionTest - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added TableDefinitionTest .. Added TableDefinitionTest Change-Id: Ibdf324d85c3f3093aa46af2d4407a77936711322 --- M repo/Wikibase.hooks.php A repo/tests/phpunit/includes/Database/TableDefinitionTest.php 2 files changed, 98 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 002f238..5f3e700 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -186,6 +186,7 @@ 'content/PropertyHandler', 'Database/FieldDefinition', + 'Database/TableDefinition', 'specials/SpecialCreateItem', 'specials/SpecialItemDisambiguation', diff --git a/repo/tests/phpunit/includes/Database/TableDefinitionTest.php b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php new file mode 100644 index 000..aa7681e --- /dev/null +++ b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php @@ -0,0 +1,97 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since 0.4 + * + * @ingroup WikibaseRepoTest + * + * @group Wikibase + * @group WikibaseRepo + * @group WikibaseDatabase + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class TableDefinitionTest extends \MediaWikiTestCase { + + public function instanceProvider() { + $instances = array(); + + $instances[] = new TableDefinition( + 'snaks', + array( + new FieldDefinition( 'omnomnom', FieldDefinition::TYPE_TEXT ) + ) + ); + + $instances[] = new TableDefinition( + 'spam', + array( + new FieldDefinition( 'o', FieldDefinition::TYPE_TEXT ), + new FieldDefinition( 'h', FieldDefinition::TYPE_TEXT ), + new FieldDefinition( 'i', FieldDefinition::TYPE_INTEGER, 42 ), + ) + ); + + return $this->arrayWrap( $instances ); + } + + /** +* @dataProvider instanceProvider +* +* @param TableDefinition $table +*/ + public function testReturnValueOfGetName( TableDefinition $table ) { + $this->assertInternalType( 'string', $table->getName() ); + + $newTable = new TableDefinition( $table->getName(), $table->getFields() ); + + $this->assertEquals( + $table->getName(), + $newTable->getName(), + 'The TableDefinition name is set and obtained correctly' + ); + } + + /** +* @dataProvider instanceProvider +* +* @param TableDefinition $table +*/ + public function testReturnValueOfGetFields( TableDefinition $table ) { + $this->assertInternalType( 'array', $table->getFields() ); + $this->assertContainsOnlyInstancesOf( 'Wikibase\Repo\Database\FieldDefinition', $table->getFields() ); + + $newTable = new TableDefinition( $table->getName(), $table->getFields() ); + + $this->assertEquals( + $table->getFields(), + $newTable->getFields(), + 'The TableDefinition fields are set and obtained correctly' + ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/50634 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibdf324d85c3f3093aa46af2d4407a77936711322 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: Jens Ohlig Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added TableBuilderTest - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added TableBuilderTest .. Added TableBuilderTest Change-Id: Ie172ebaf146495941f10e6d265433fe2577e5325 --- M repo/Wikibase.hooks.php M repo/tests/phpunit/includes/Database/FieldDefinitionTest.php A repo/tests/phpunit/includes/Database/TableBuilderTest.php M repo/tests/phpunit/includes/Database/TableDefinitionTest.php 4 files changed, 139 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 5f3e700..55587e8 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -186,6 +186,7 @@ 'content/PropertyHandler', 'Database/FieldDefinition', + 'Database/TableBuilder', 'Database/TableDefinition', 'specials/SpecialCreateItem', diff --git a/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php b/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php index 29943f8..122cbfb 100644 --- a/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php +++ b/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php @@ -5,7 +5,7 @@ use Wikibase\Repo\Database\FieldDefinition; /** - * Unit test Wikibase\Repo\Database\FieldDefinitionTest class. + * Unit test Wikibase\Repo\Database\FieldDefinition class. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/repo/tests/phpunit/includes/Database/TableBuilderTest.php b/repo/tests/phpunit/includes/Database/TableBuilderTest.php new file mode 100644 index 000..aa2d33f --- /dev/null +++ b/repo/tests/phpunit/includes/Database/TableBuilderTest.php @@ -0,0 +1,136 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since 0.4 + * + * @ingroup WikibaseRepoTest + * + * @group Wikibase + * @group WikibaseRepo + * @group WikibaseDatabase + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class TableBuilderTest extends \MediaWikiTestCase { + + public function tableNameProvider() { + return $this->arrayWrap( + array( + 'foo', + 'bar', + 'o', + 'foo_bar_baz', + 'foobarbaz', + ) + ); + } + + /** +* @dataProvider tableNameProvider +*/ + public function testCreateTableCallsTableExists( $tableName ) { + $table = new TableDefinition( + $tableName, + array( new FieldDefinition( 'foo', FieldDefinition::TYPE_TEXT ) ) + ); + + $reporter = new NullMessageReporter(); + + $queryInterface = new ObservableQueryInterface(); + + $assertEquals = array( $this, 'assertEquals' ); + $callCount = 0; + + $queryInterface->registerCallback( + 'tableExists', + function( $tableName ) use ( $table, &$callCount, $assertEquals ) { + call_user_func( $assertEquals, $table->getName(), $tableName ); + $callCount += 1; + } + ); + + $builder = new TableBuilder( $queryInterface, $reporter ); + + $builder->createTable( $table ); + $this->assertEquals( 1, $callCount ); + } + +} + +use Wikibase\Repo\Database\QueryInterface; + +class ObservableQueryInterface implements QueryInterface { + + /** +* @var callable[] +*/ + private $callbacks = array(); + + /** +* @param string $method +* @param callable $callback +*/ + public function registerCallback( $method, $callback ) { + $this->callbacks[$method] = $callback; + } + + private function runCallbacks( $method, $args ) { + if ( array_key_exists( $method, $this->callbacks ) ) { + call_user_func_array( $this->callbacks[$method], $args ); + } + } + + /** +* @see QueryInterface::tableExists +* +* @param string $tableName +* +* @return boolean +*/ + public function tableExists( $tableName ) { + $this->runCallbacks( __FUNCTION__, func_get_args() ); + } + +} + +use MessageReporter; + +class NullMessageReporter implements MessageReporter { + + /** +* @see MessageReporter::reportMessage +* +* @since 0.4 +* +* @param string $message +*/ + public function reportMessag
[MediaWiki-commits] [Gerrit] Move registration of tests for experimental code to experime... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Move registration of tests for experimental code to experimental file .. Move registration of tests for experimental code to experimental file Change-Id: I8c3154ca384bcf29b6c0dfb86118bab11c6092fe --- M repo/Wikibase.hooks.php M repo/config/Wikibase.experimental.php 2 files changed, 4 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 55587e8..c1c7b88 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -185,10 +185,6 @@ 'content/PropertyContent', 'content/PropertyHandler', - 'Database/FieldDefinition', - 'Database/TableBuilder', - 'Database/TableDefinition', - 'specials/SpecialCreateItem', 'specials/SpecialItemDisambiguation', 'specials/SpecialItemByTitle', diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 57d6fb5..d7f23b9 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -96,6 +96,10 @@ 'content/QueryContent', 'content/QueryHandler', + 'Database/FieldDefinition', + 'Database/TableBuilder', + 'Database/TableDefinition', + 'specials/SpecialEntityData', ); -- To view, visit https://gerrit.wikimedia.org/r/50715 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8c3154ca384bcf29b6c0dfb86118bab11c6092fe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45353) Add ItemDisambiguation to the list of special pages - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/50749 Change subject: (Bug 45353) Add ItemDisambiguation to the list of special pages .. (Bug 45353) Add ItemDisambiguation to the list of special pages Changes so ItemDisambiguation and ItemByTitle can be added tothe list of special pages. Also some minor changes to the messages used for those pages. Change-Id: Id197c49dd52c482eb162f56522e5f0db0256b90a --- M repo/Wikibase.i18n.php M repo/Wikibase.php M repo/includes/specials/SpecialItemByTitle.php M repo/includes/specials/SpecialItemDisambiguation.php M repo/includes/specials/SpecialItemResolver.php 5 files changed, 18 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/49/50749/1 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index d98eb6d..03e756a 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -112,7 +112,7 @@ 'wikibase-itemlink-title' => '$1 | $2', // Special pages - 'special-itembytitle' => 'Item by title', + 'special-itembytitle' => 'Item by sitelink', 'wikibase-itembytitle-lookup-fieldset' => 'Search for items by site and title', 'wikibase-itembytitle-lookup-site' => 'Site:', 'wikibase-itembytitle-lookup-page' => 'Page:', @@ -121,8 +121,8 @@ 'wikibase-itembytitle-invalid-site' => 'The previous query could not be used for a search. Please provide a valid site identifier.', 'wikibase-itembytitle-description' => 'Site is an identifier code, such as "enwiki".', 'wikibase-itembytitle-create' => 'You can also [{{fullurl:Special:CreateItem|site=$1&page=$2}} create an item].', - 'special-itemdisambiguation' => 'Disambiguation: Items with the same label', - 'wikibase-itemdisambiguation-lookup-fieldset' => 'Search for items by label', + 'special-itemdisambiguation' => 'Item disambiguation', + 'wikibase-itemdisambiguation-lookup-fieldset' => 'Search for items by language and label', 'wikibase-itemdisambiguation-lookup-language' => 'Language:', 'wikibase-itemdisambiguation-lookup-label' => 'Label:', 'wikibase-itemdisambiguation-submit' => 'Search', diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 2111cee..f578609 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -228,29 +228,29 @@ // Special page registration $wgSpecialPages['CreateItem'] = 'SpecialCreateItem'; +$wgSpecialPages['EntitiesWithoutLabel']= 'SpecialEntitiesWithoutLabel'; $wgSpecialPages['ItemByTitle'] = 'SpecialItemByTitle'; $wgSpecialPages['ItemDisambiguation'] = 'SpecialItemDisambiguation'; -$wgSpecialPages['SetLabel']= 'SpecialSetLabel'; -$wgSpecialPages['SetDescription'] = 'SpecialSetDescription'; -$wgSpecialPages['SetAliases'] = 'SpecialSetAliases'; -$wgSpecialPages['EntitiesWithoutLabel']= 'SpecialEntitiesWithoutLabel'; $wgSpecialPages['ItemsWithoutSitelinks'] = 'SpecialItemsWithoutSitelinks'; -$wgSpecialPages['NewProperty'] = 'SpecialNewProperty'; $wgSpecialPages['ListDatatypes'] = 'SpecialListDatatypes'; +$wgSpecialPages['NewProperty'] = 'SpecialNewProperty'; +$wgSpecialPages['SetAliases'] = 'SpecialSetAliases'; +$wgSpecialPages['SetDescription'] = 'SpecialSetDescription'; +$wgSpecialPages['SetLabel']= 'SpecialSetLabel'; // Special page groups $wgSpecialPageGroups['CreateItem'] = 'wikibaserepo'; -$wgSpecialPageGroups['NewProperty']= 'wikibaserepo'; -$wgSpecialPageGroups['ItemByTitle']= 'wikibaserepo'; -$wgSpecialPageGroups['ItemDisambiguation'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetLabel'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetDescription'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetAliases'] = 'wikibaserepo'; $wgSpecialPageGroups['EntitiesWithoutLabel'] = 'wikibaserepo'; $wgSpecialPageGroups['EntityData'] = 'wikibaserepo'; +$wgSpecialPageGroups['ItemByTitle']= 'wikibaserepo'; +$wgSpecialPageGroups['ItemDisambiguation'] = 'wikibaserepo'; $wgSpecialPageGroups['Items
[MediaWiki-commits] [Gerrit] (Bug 44762) Change ml constraints - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/50770 Change subject: (Bug 44762) Change ml constraints .. (Bug 44762) Change ml constraints Changed from a buggy detection of ML constraints to a simpler one that is only checking length on save. It could be that something smarter must be introduced later on because there are some overly long strings in the database. Change-Id: I9709521049d7a67e6c760d2ea702c16b76ae002d --- M repo/Wikibase.hooks.php M repo/Wikibase.i18n.php M repo/Wikibase.php M repo/config/Wikibase.default.php M repo/includes/EditEntity.php D repo/includes/MultiLangConstraintDetector.php M repo/includes/api/ApiModifyLangAttribute.php M repo/includes/api/ApiSetAliases.php D repo/tests/phpunit/includes/MultiLangConstraintDetectorTest.php 9 files changed, 19 insertions(+), 367 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/70/50770/1 diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index c1c7b88..6ecd88b 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -155,7 +155,6 @@ 'ItemView', 'LabelDescriptionDuplicateDetector', 'LazyDBConnectionProvider', - 'MultiLangConstraintDetector', 'NamespaceUtils', 'actions/EditEntityAction', diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 03e756a..c4c4e43 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -96,10 +96,7 @@ 'wikibase-move-error' => 'You cannot move pages that are in the data namespace, and you cannot move pages into it.', - 'wikibase-warning-constraint-violation-length' => 'A length constraint is triggered for language code "$1".', - 'wikibase-error-constraint-violation-label' => 'There is {{PLURAL:$1|a constraint|constraints}} violation for {{PLURAL:$1|label|labels}} "$3" for {{PLURAL:$1|language code|language codes}} "$2".', - 'wikibase-error-constraint-violation-description' => 'There is {{PLURAL:$1|a constraint|constraints}} violation for {{PLURAL:$1|description|descriptions}} "$3" for {{PLURAL:$1|language code|language codes}} "$2".', - 'wikibase-error-constraint-violation-aliases' => 'There is {{PLURAL:$1|a constraint|constraints}} violation for {{PLURAL:$1|alias|aliases}} "$3" for {{PLURAL:$1|language code|language codes}} "$2".', + 'wikibase-constraint-violation' => 'A limit constraint is triggered for language code "$1.', 'wikibase-error-sitelink-already-used' => 'Site link [[$1:$2]] already used by item [[$3]].', 'wikibase-error-label-not-unique-wikibase-property' => 'Another property ($3) already has label "$1" associated with language code $2', @@ -447,16 +444,8 @@ 'wikibase-restrictionedit-tooltip-message' => 'When editing a page (a data item) is restricted for the current user, this message is displayed in a tooltip bubble when hovering a tooltip anchor next to an input element, an edit button or any other button (add, save, remove) that might trigger an action altering the data item.', 'wikibase-blockeduser-tooltip-message' => 'When the current user is blocked from editing a page (a data item), this message is displayed in a tooltip bubble when hovering a tooltip anchor next to an input element, an edit button or any other button (add, save, remove) that might trigger an action altering the data item or creating a new item.', 'wikibase-move-error' => 'The data namespace is blocked against moving pages within it and moving pages into it, because that will make the content inconsistent both within it and on external wikis. The message uses "pages" in this case as name for whats moved, but within the data namespace usually contains "items". See also Wikidatas glossary on [[m:Wikidata/Glossary#page|page]] and [[m:Wikidata/Glossary#item|item]].', - 'wikibase-warning-constraint-violation-length' => 'A warning message that a length constraint is triggered. This will usually come together with a fatal error message. + 'wikibase-constraint-violation' => 'A warning message that a length constraint is triggered. This will usually come together with a fatal error message. * $1 is the language code', - 'wikibase-error-constraint-violation-label' => 'Error message shown when a user tries to save a multilabel label that has some constraint violation. -* $1 is the count of violating languages -* $2 is the violating languages -* $3 is the violating string, but this is usually not very useful as the message is usually given in an edit window', - 'wikibase-error-constraint-violation-description' => 'Error message shown when a user tries to save a multilabel description that has some constraint violation. -* $1 is the count of violatin
[MediaWiki-commits] [Gerrit] Added a bunch of docs and stub classes - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added a bunch of docs and stub classes .. Added a bunch of docs and stub classes Change-Id: Icaddb6ab2b00bcf16639be7b47b4a937fbdec088 --- M repo/includes/Database/FieldDefinition.php M repo/includes/Database/MediaWikiQueryInterface.php M repo/includes/Database/QueryInterface.php M repo/includes/Database/TableBuilder.php M repo/includes/Database/TableDefinition.php M repo/includes/Query/QueryEngine.php M repo/includes/Query/QueryEngineResult.php M repo/includes/Query/QueryStore.php A repo/includes/Query/SQLStore/DataValueHandler.php A repo/includes/Query/SQLStore/Engine.php D repo/includes/Query/SQLStore/QueryEngine.php M repo/includes/Query/SQLStore/Setup.php M repo/includes/Query/SQLStore/Store.php 13 files changed, 263 insertions(+), 54 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/FieldDefinition.php b/repo/includes/Database/FieldDefinition.php index 01f3024..e1d3301 100644 --- a/repo/includes/Database/FieldDefinition.php +++ b/repo/includes/Database/FieldDefinition.php @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @since 0.4 + * @since wd.db * * @file * @ingroup WikibaseRepo @@ -33,49 +33,49 @@ class FieldDefinition implements \Immutable { /** -* @since 0.4 +* @since wd.db * * @var string */ private $name; /** -* @since 0.4 +* @since wd.db * * @var string */ private $type; /** -* @since 0.4 +* @since wd.db * * @var mixed */ private $default; /** -* @since 0.4 +* @since wd.db * * @var string|null */ private $attributes; /** -* @since 0.4 +* @since wd.db * * @var boolean */ private $null; /** -* @since 0.4 +* @since wd.db * * @var string|null */ private $index; /** -* @since 0.4 +* @since wd.db * * @var boolean */ diff --git a/repo/includes/Database/MediaWikiQueryInterface.php b/repo/includes/Database/MediaWikiQueryInterface.php index 64f0469..a4a5e6d 100644 --- a/repo/includes/Database/MediaWikiQueryInterface.php +++ b/repo/includes/Database/MediaWikiQueryInterface.php @@ -23,7 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @since 0.4 + * @since wd.db * * @file * @ingroup WikibaseRepo diff --git a/repo/includes/Database/QueryInterface.php b/repo/includes/Database/QueryInterface.php index 56f10c9..7619f9b 100644 --- a/repo/includes/Database/QueryInterface.php +++ b/repo/includes/Database/QueryInterface.php @@ -20,7 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @since 0.4 + * @since wd.db * * @file * @ingroup WikibaseRepo diff --git a/repo/includes/Database/TableBuilder.php b/repo/includes/Database/TableBuilder.php index 5a819dd..490d7e9 100644 --- a/repo/includes/Database/TableBuilder.php +++ b/repo/includes/Database/TableBuilder.php @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @since 0.4 + * @since wd.db * * @file * @ingroup WikibaseRepo @@ -33,14 +33,14 @@ class TableBuilder { /** -* @since 0.4 +* @since wd.db * * @var QueryInterface */ private $db; /** -* @since 0.4 +* @since wd.db * * @var MessageReporter|null */ @@ -49,7 +49,7 @@ /** * Constructor. * -* @since 0.4 +* @since wd.db * * @param QueryInterface $queryInterface * @param MessageReporter|null $messageReporter @@ -60,7 +60,7 @@ } /** -* @since 0.4 +* @since wd.db * * @param string $message */ @@ -73,7 +73,7 @@ /** * Creates a table if it does not exist yet. * -* @since 0.4 +* @since wd.db * * @param TableDefinition $table */ diff --git a/repo/includes/Database/TableDefinition.php b/repo/includes/Database/TableDefinition.php index d1ccce9..37e9006 100644 --- a/repo/includes/Database/TableDefinition.php +++ b/repo/includes/Database/TableDefinition.php @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @since 0.4 + * @since wd.db * * @file * @ingroup WikibaseRepo @@ -33,1
[MediaWiki-commits] [Gerrit] Regsiter Query classes - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Regsiter Query classes .. Regsiter Query classes Change-Id: I272c4ff3f95bb350a29fd50a1c42d2fb3c2a0ad7 --- M repo/config/Wikibase.experimental.php 1 file changed, 10 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index d7f23b9..b6a3501 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -53,6 +53,16 @@ 'Wikibase\Repo\Database\QueryInterface', 'Wikibase\Repo\Database\TableBuilder', 'Wikibase\Repo\Database\TableDefinition', + + 'Wikibase\Repo\Query\QueryEngine', + 'Wikibase\Repo\Query\QueryEngineResult', + 'Wikibase\Repo\Query\QueryResult', + 'Wikibase\Repo\Query\QueryStore', + + 'Wikibase\Repo\Query\SQLStore\DataValueHandler', + 'Wikibase\Repo\Query\SQLStore\Engine', + 'Wikibase\Repo\Query\SQLStore\Setup', + 'Wikibase\Repo\Query\SQLStore\Store', ) as $class ) { $wgAutoloadClasses[$class] = $dir . 'includes' . str_replace( '\\', '/', substr( $class, 13 ) ) . '.php'; -- To view, visit https://gerrit.wikimedia.org/r/50940 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I272c4ff3f95bb350a29fd50a1c42d2fb3c2a0ad7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added test stubs for new Query code - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added test stubs for new Query code .. Added test stubs for new Query code Change-Id: Ib8c3c700ad7db8510dd91b8101693efc09368ffe --- M repo/config/Wikibase.experimental.php M repo/tests/phpunit/includes/Database/FieldDefinitionTest.php M repo/tests/phpunit/includes/Database/TableBuilderTest.php M repo/tests/phpunit/includes/Database/TableDefinitionTest.php A repo/tests/phpunit/includes/Query/QueryEngineResultTest.php A repo/tests/phpunit/includes/Query/QueryEngineTest.php A repo/tests/phpunit/includes/Query/QueryStoreTest.php A repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php A repo/tests/phpunit/includes/Query/SQLStore/SetupTest.php A repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php 10 files changed, 279 insertions(+), 25 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index b6a3501..ac88acf 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -46,33 +46,45 @@ $wgAutoloadClasses['Wikibase\QueryHandler']= $dir . 'includes/content/QueryHandler.php'; +$classes = array( + 'Wikibase\Repo\Database\FieldDefinition', + 'Wikibase\Repo\Database\MediaWikiQueryInterface', + 'Wikibase\Repo\Database\QueryInterface', + 'Wikibase\Repo\Database\TableBuilder', + 'Wikibase\Repo\Database\TableDefinition', -foreach ( array( - 'Wikibase\Repo\Database\FieldDefinition', - 'Wikibase\Repo\Database\MediaWikiQueryInterface', - 'Wikibase\Repo\Database\QueryInterface', - 'Wikibase\Repo\Database\TableBuilder', - 'Wikibase\Repo\Database\TableDefinition', + 'Wikibase\Repo\Query\QueryEngine', + 'Wikibase\Repo\Query\QueryEngineResult', + 'Wikibase\Repo\Query\QueryResult', + 'Wikibase\Repo\Query\QueryStore', - 'Wikibase\Repo\Query\QueryEngine', - 'Wikibase\Repo\Query\QueryEngineResult', - 'Wikibase\Repo\Query\QueryResult', - 'Wikibase\Repo\Query\QueryStore', + 'Wikibase\Repo\Query\SQLStore\DataValueHandler', + 'Wikibase\Repo\Query\SQLStore\Engine', + 'Wikibase\Repo\Query\SQLStore\Setup', + 'Wikibase\Repo\Query\SQLStore\Store', +); - 'Wikibase\Repo\Query\SQLStore\DataValueHandler', - 'Wikibase\Repo\Query\SQLStore\Engine', - 'Wikibase\Repo\Query\SQLStore\Setup', - 'Wikibase\Repo\Query\SQLStore\Store', - ) as $class ) { - +foreach ( $classes as $class ) { + // This enforces partial PSR-0 compliance $wgAutoloadClasses[$class] = $dir . 'includes' . str_replace( '\\', '/', substr( $class, 13 ) ) . '.php'; } + +unset( $classes ); if ( !class_exists( 'MessageReporter' ) ) { $wgAutoloadClasses['MessageReporter'] = $dir . 'includes/MessageReporter.php'; $wgAutoloadClasses['ObservableMessageReporter'] = $dir . 'includes/MessageReporter.php'; } +if ( defined( 'MW_PHPUNIT_TEST' ) ) { + $wgAutoloadClasses['Wikibase\Repo\Test\Query\QueryEngineTest'] + = $dir . 'tests/phpunit/includes/Query/QueryEngineTest.php'; + + $wgAutoloadClasses['Wikibase\Repo\Test\Query\QueryStoreTest'] + = $dir . 'tests/phpunit/includes/Query/QueryStoreTest.php'; +} + +unset( $dir ); $wgAPIModules['wbremovequalifiers']= 'Wikibase\Repo\Api\RemoveQualifiers'; $wgAPIModules['wbsetqualifier']= 'Wikibase\Repo\Api\SetQualifier'; @@ -82,8 +94,6 @@ $wgSpecialPages['EntityData'] = 'SpecialEntityData'; $wgContentHandlers[CONTENT_MODEL_WIKIBASE_QUERY] = '\Wikibase\QueryHandler'; - -unset( $dir ); /** * Hook to add PHPUnit test cases. @@ -110,6 +120,12 @@ 'Database/TableBuilder', 'Database/TableDefinition', + 'Query/QueryEngineResult', + + 'Query/SQLStore/Engine', + 'Query/SQLStore/Setup', + 'Query/SQLStore/Store', + 'specials/SpecialEntityData', ); diff --git a/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php b/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php index 122cbfb..5566a95 100644 --- a/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php +++ b/repo/tests/phpunit/includes/Database/FieldDefinitionTest.php @@ -5,7 +5,7 @@ use Wikibase\Repo\Database\FieldDefinition; /** - * Unit test Wikibase\Repo\Database\FieldDefinition class. + * Unit tests for th
[MediaWiki-commits] [Gerrit] Added to QueryStoreTest - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added to QueryStoreTest .. Added to QueryStoreTest Change-Id: I2527d2763a88caa0efac4fa88e9dbd15b1b55494 --- M repo/tests/phpunit/includes/Query/QueryStoreTest.php M repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php 2 files changed, 36 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/tests/phpunit/includes/Query/QueryStoreTest.php b/repo/tests/phpunit/includes/Query/QueryStoreTest.php index ba166ab..21209b9 100644 --- a/repo/tests/phpunit/includes/Query/QueryStoreTest.php +++ b/repo/tests/phpunit/includes/Query/QueryStoreTest.php @@ -2,6 +2,8 @@ namespace Wikibase\Repo\Test\Query; +use Wikibase\Repo\Query\QueryStore; + /** * Base test class for Wikibase\Repo\Query\QueryStore implementing classes. * @@ -30,6 +32,29 @@ */ abstract class QueryStoreTest extends \MediaWikiTestCase { - // TODO + /** +* @since wd.qe +* +* @return QueryStore[] +*/ + protected abstract function getInstances(); + + /** +* @since wd.qe +* +* @return QueryStore[][] +*/ + public function instanceProvider() { + return $this->arrayWrap( $this->getInstances() ); + } + + /** +* @dataProvider instanceProvider +* +* @param QueryStore $queryStore +*/ + public function testGetNameReturnType( QueryStore $queryStore ) { + $this->assertInternalType( 'string', $queryStore->getName() ); + } } diff --git a/repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php b/repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php index c3c1cc7..55edecc 100644 --- a/repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php +++ b/repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php @@ -37,6 +37,15 @@ */ class StoreTest extends QueryStoreTest { - // TODO + /** +* @see QueryStoreTest::getInstances +*/ + protected function getInstances() { + $instances = array(); + + $instances[] = new Store( 'foo', array() ); + + return $instances; + } } -- To view, visit https://gerrit.wikimedia.org/r/51036 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2527d2763a88caa0efac4fa88e9dbd15b1b55494 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added to QueryEngineTest - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added to QueryEngineTest .. Added to QueryEngineTest Change-Id: I21a14a23e5bc5ca1453d4556dce7cb07fb5a38df --- M repo/tests/phpunit/includes/Query/QueryEngineResultTest.php M repo/tests/phpunit/includes/Query/QueryEngineTest.php M repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php 3 files changed, 41 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php b/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php index 09639fc..1d3c620 100644 --- a/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php +++ b/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php @@ -34,7 +34,7 @@ * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > */ -class QueryEngineResultTest extends QueryEngineTest { +class QueryEngineResultTest extends \MediaWikiTestCase { // TODO diff --git a/repo/tests/phpunit/includes/Query/QueryEngineTest.php b/repo/tests/phpunit/includes/Query/QueryEngineTest.php index 8ec86d0..c1c3171 100644 --- a/repo/tests/phpunit/includes/Query/QueryEngineTest.php +++ b/repo/tests/phpunit/includes/Query/QueryEngineTest.php @@ -2,7 +2,7 @@ namespace Wikibase\Repo\Test\Query; -use Wikibase\Repo\Database\FieldDefinition; +use Wikibase\Repo\Query\QueryEngine; /** * Base test class for Wikibase\Repo\Query\QueryEngine implementing classes. @@ -32,6 +32,34 @@ */ abstract class QueryEngineTest extends \MediaWikiTestCase { - // TODO + /** +* @since wd.qe +* +* @return QueryEngine[] +*/ + protected abstract function getInstances(); + + /** +* @since wd.qe +* +* @return QueryEngine[][] +*/ + public function instanceProvider() { + return $this->arrayWrap( $this->getInstances() ); + } + + /** +* @dataProvider instanceProvider +* +* @param QueryEngine $queryEngine +*/ + public function testGetNameReturnType( QueryEngine $queryEngine ) { + // TODO + +// $query = new \Ask\Language\Query( ); +// $this->assertInstanceOf( 'Wikibase\Repo\Query\QueryEngineResult', $queryEngine->runQuery() ); + + $this->assertTrue( true ); + } } diff --git a/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php b/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php index 9576889..b63ec59 100644 --- a/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php +++ b/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php @@ -37,6 +37,15 @@ */ class EngineTest extends QueryEngineTest { - // TODO + /** +* @see QueryEngineTest::getInstances +*/ + protected function getInstances() { + $instances = array(); + + $instances[] = new Engine(); + + return $instances; + } } -- To view, visit https://gerrit.wikimedia.org/r/51037 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I21a14a23e5bc5ca1453d4556dce7cb07fb5a38df Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added to QueryEngineResultTest - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added to QueryEngineResultTest .. Added to QueryEngineResultTest Change-Id: I5f2902d0e25f9ac10384571dab4812235bf177d5 --- M repo/includes/Query/QueryEngineResult.php M repo/tests/phpunit/includes/Query/QueryEngineResultTest.php 2 files changed, 35 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Query/QueryEngineResult.php b/repo/includes/Query/QueryEngineResult.php index 6991bd4..e90b648 100644 --- a/repo/includes/Query/QueryEngineResult.php +++ b/repo/includes/Query/QueryEngineResult.php @@ -31,10 +31,13 @@ class QueryEngineResult { /** +* @since wd.qe +* * @return QueryResult */ public function getQueryResult() { - + // TODO + return new QueryResult(); } } \ No newline at end of file diff --git a/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php b/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php index 1d3c620..72f190c 100644 --- a/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php +++ b/repo/tests/phpunit/includes/Query/QueryEngineResultTest.php @@ -36,6 +36,36 @@ */ class QueryEngineResultTest extends \MediaWikiTestCase { - // TODO + /** +* @since wd.qe +* +* @return QueryEngineResult[] +*/ + protected function getInstances() { + $instances = array(); + + $instances[] = new QueryEngineResult(); + + return $instances; + } + + /** +* @since wd.qe +* +* @return QueryEngineResult[][] +*/ + public function instanceProvider() { + return $this->arrayWrap( $this->getInstances() ); + } + + /** +* @dataProvider instanceProvider +* +* @param QueryEngineResult $engineResult +*/ + public function testGetResultReturnType( QueryEngineResult $engineResult ) { + // TODO: switch type check to real object + $this->assertInstanceOf( 'Wikibase\Repo\Query\QueryResult', $engineResult->getQueryResult() ); + } } -- To view, visit https://gerrit.wikimedia.org/r/51038 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5f2902d0e25f9ac10384571dab4812235bf177d5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added DataValueHandlerTest stub - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added DataValueHandlerTest stub .. Added DataValueHandlerTest stub Change-Id: Iecdf201655f3cae35b77add0c61017211774adba --- M repo/config/Wikibase.experimental.php A repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php 2 files changed, 42 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index ac88acf..406379c 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -122,6 +122,7 @@ 'Query/QueryEngineResult', + 'Query/SQLStore/DataValueHandler', 'Query/SQLStore/Engine', 'Query/SQLStore/Setup', 'Query/SQLStore/Store', diff --git a/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php b/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php new file mode 100644 index 000..1744f97 --- /dev/null +++ b/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php @@ -0,0 +1,41 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since wd.qe + * + * @ingroup WikibaseRepoTest + * + * @group Wikibase + * @group WikibaseRepo + * @group WikibaseQuery + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class DataValueHandlerTest extends \MediaWikiTestCase { + + // TODO + +} -- To view, visit https://gerrit.wikimedia.org/r/51039 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iecdf201655f3cae35b77add0c61017211774adba Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Daniel Werner Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Improve class refs - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Improve class refs .. Improve class refs Change-Id: If7a1d9fb558e2e30295e7db696a086897237589e --- M repo/includes/api/CreateClaim.php M repo/includes/api/GetClaims.php M repo/includes/api/GetEntities.php M repo/includes/api/RemoveClaims.php M repo/includes/api/RemoveQualifiers.php M repo/includes/api/RemoveReferences.php M repo/includes/api/SetClaim.php M repo/includes/api/SetClaimValue.php M repo/includes/api/SetQualifier.php M repo/includes/api/SetReference.php M repo/includes/api/SetStatementRank.php 11 files changed, 34 insertions(+), 35 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/api/CreateClaim.php b/repo/includes/api/CreateClaim.php index 1e54235..780e6fa 100644 --- a/repo/includes/api/CreateClaim.php +++ b/repo/includes/api/CreateClaim.php @@ -11,7 +11,6 @@ use Wikibase\SnakFactory; use Wikibase\LibRegistry; use Wikibase\Claim; -use Wikibase\ClaimSerializer; use Wikibase\Autocomment; use Wikibase\Settings; @@ -164,7 +163,7 @@ /** * @since 0.2 * -* @return \Wikibase\EntityContent +* @return EntityContent */ protected function getEntityContent() { $params = $this->extractRequestParams(); @@ -185,7 +184,7 @@ /** * @since 0.2 * -* @return \Wikibase\Snak +* @return Snak * @throws MWException */ protected function getSnakInstance() { @@ -210,7 +209,7 @@ /** * @since 0.3 * -* @param \Wikibase\Claim $claim +* @param Claim $claim */ protected function outputClaim( Claim $claim ) { $serializerFactory = new \Wikibase\Lib\Serializers\SerializerFactory(); diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php index 0806811..3bd8fc1 100644 --- a/repo/includes/api/GetClaims.php +++ b/repo/includes/api/GetClaims.php @@ -2,15 +2,17 @@ namespace Wikibase\Api; -use ApiBase, MWException; -use Wikibase\Lib\Serializers\ClaimSerializer; -use Wikibase\Lib\Serializers\ClaimsSerializer; +use ApiBase; +use MWException; +use Wikibase\Lib\Serializers\ClaimSerializer; +use Wikibase\Lib\Serializers\SerializerFactory; use Wikibase\EntityId; use Wikibase\Entity; use Wikibase\EntityContentFactory; use Wikibase\Statement; use Wikibase\Claims; +use Wikibase\Claim; /** * API module for getting claims. @@ -75,7 +77,7 @@ protected function outputClaims( array $claims ) { $claims = new Claims( $claims ); - $serializerFactory = new \Wikibase\Lib\Serializers\SerializerFactory(); + $serializerFactory = new SerializerFactory(); $serializer = $serializerFactory->newSerializerForObject( $claims ); // TODO: hold into account props parameter @@ -93,9 +95,9 @@ /** * @since 0.3 * -* @param \Wikibase\EntityId $id +* @param EntityId $id * -* @return \Wikibase\Entity +* @return Entity */ protected function getEntity( EntityId $id ) { $content = EntityContentFactory::singleton()->getFromId( $id ); @@ -110,7 +112,7 @@ /** * @since 0.3 * -* @param \Wikibase\Entity $entity +* @param Entity $entity * @param null|string $claimGuid * * @return Claim[] diff --git a/repo/includes/api/GetEntities.php b/repo/includes/api/GetEntities.php index e02ee89..3511648 100644 --- a/repo/includes/api/GetEntities.php +++ b/repo/includes/api/GetEntities.php @@ -2,11 +2,10 @@ namespace Wikibase\Api; -use ApiBase, MWException; -use Wikibase\Lib\Serializers\EntitySerializer; -use Wikibase\Lib\Serializers\SerializationOptions; -use Wikibase\Lib\Serializers\EntitySerializationOptions; +use ApiBase; +use MWException; +use Wikibase\Lib\Serializers\EntitySerializationOptions; use Wikibase\Utils; use Wikibase\StoreFactory; use Wikibase\EntityId; @@ -175,7 +174,7 @@ $entity = $entityContent->getEntity(); - $options = new \Wikibase\Lib\Serializers\EntitySerializationOptions(); + $options = new EntitySerializationOptions(); $options->setLanguages( $params['languages'] ); $options->setSortDirection( $params['dir'] ); $options->setProps( $props ); diff --git a/repo/includes/api/RemoveClaims.php b/repo/includes/api/RemoveClaims.php index b208cf2..3f33420 100644 --- a/repo/includes/api/RemoveClaims.php +++ b/repo/includes/api/RemoveClaims.php @@ -2,7 +2,8 @@ namespace Wikibase\Api; -use ApiBase, MWException; +use ApiBase; +use MW
[MediaWiki-commits] [Gerrit] Added to SetupTest and moved mock service object implementio... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added to SetupTest and moved mock service object implementions to non-test code .. Added to SetupTest and moved mock service object implementions to non-test code Change-Id: I88a96b633aa29d0b7e4d6fe5fa2ecd472fad28a6 --- M repo/config/Wikibase.experimental.php A repo/includes/Database/ObservableQueryInterface.php M repo/includes/MessageReporter.php M repo/tests/phpunit/includes/Database/TableBuilderTest.php M repo/tests/phpunit/includes/Query/SQLStore/SetupTest.php 5 files changed, 147 insertions(+), 54 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index aac93cd..57193a5 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -49,6 +49,7 @@ $classes = array( 'Wikibase\Repo\Database\FieldDefinition', 'Wikibase\Repo\Database\MediaWikiQueryInterface', + 'Wikibase\Repo\Database\ObservableQueryInterface', 'Wikibase\Repo\Database\QueryInterface', 'Wikibase\Repo\Database\TableBuilder', 'Wikibase\Repo\Database\TableDefinition', @@ -74,6 +75,7 @@ if ( !class_exists( 'MessageReporter' ) ) { $wgAutoloadClasses['MessageReporter'] = $dir . 'includes/MessageReporter.php'; $wgAutoloadClasses['ObservableMessageReporter'] = $dir . 'includes/MessageReporter.php'; + $wgAutoloadClasses['NullMessageReporter'] = $dir . 'includes/MessageReporter.php'; } if ( defined( 'MW_PHPUNIT_TEST' ) ) { diff --git a/repo/includes/Database/ObservableQueryInterface.php b/repo/includes/Database/ObservableQueryInterface.php new file mode 100644 index 000..c4b9b56 --- /dev/null +++ b/repo/includes/Database/ObservableQueryInterface.php @@ -0,0 +1,66 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.db + * + * @file + * @ingroup WikibaseRepo + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class ObservableQueryInterface implements QueryInterface { + + /** +* @var callable[] +*/ + private $callbacks = array(); + + /** +* @param string $method +* @param callable $callback +*/ + public function registerCallback( $method, $callback ) { + $this->callbacks[$method] = $callback; + } + + private function runCallbacks( $method, $args ) { + if ( array_key_exists( $method, $this->callbacks ) ) { + call_user_func_array( $this->callbacks[$method], $args ); + } + } + + /** +* @see QueryInterface::tableExists +* +* @param string $tableName +* +* @return boolean +*/ + public function tableExists( $tableName ) { + $this->runCallbacks( __FUNCTION__, func_get_args() ); + } + +} diff --git a/repo/includes/MessageReporter.php b/repo/includes/MessageReporter.php index fd13294..7d69eeb 100644 --- a/repo/includes/MessageReporter.php +++ b/repo/includes/MessageReporter.php @@ -123,3 +123,43 @@ } } + +/** + * Mock implementation of the MessageReporter interface that + * does nothing with messages it receives. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @since 1.21 + * @file + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class NullMessageReporter implements MessageReporter { + + /** +* @see MessageReporter::reportMessage +* +* @since 1.21 +* +* @param string $message +*/ + public function reportMessage( $message ) { + // no-op + } + +} diff --git a/repo/tests/phpunit/includes/Database/TableBuilderTest.php b/repo/tests/phpunit/includes/Database/TableBuilderTest.php index 5fa496c..1f8dfde 100644 --- a/repo/tests/phpunit/includes/Database/TableBuilderTest.php +++ b/repo/tests/phpunit/includes/Database/TableBuilderTest.php @@ -5,6 +5,8 @@ use Wikibase\Repo\Database\TableBuilder; use Wikibase\Repo\Database\FieldDefinition; use Wikibase\Repo\Database\Ta
[MediaWiki-commits] [Gerrit] Defined most of the DataValueHandler interface - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Defined most of the DataValueHandler interface .. Defined most of the DataValueHandler interface Change-Id: I8db83806520372f7fc479b1fce207e2c99d2e3e8 --- M repo/includes/Database/TableDefinition.php M repo/includes/Query/SQLStore/DataValueHandler.php M repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php 3 files changed, 143 insertions(+), 6 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/Database/TableDefinition.php b/repo/includes/Database/TableDefinition.php index 37e9006..f558738 100644 --- a/repo/includes/Database/TableDefinition.php +++ b/repo/includes/Database/TableDefinition.php @@ -47,6 +47,10 @@ private $fields; /** +* Constructor. +* +* @since wd.db +* * @param string $name * @param FieldDefinition[] $fields * @@ -66,6 +70,10 @@ } /** +* Returns the name of the table. +* +* @since wd.db +* * @return string */ public function getName() { @@ -73,10 +81,16 @@ } /** +* Returns the fields that make up this table. +* +* @since wd.db +* * @return FieldDefinition[] */ public function getFields() { return $this->fields; } + // TODO: multiple field indices + } \ No newline at end of file diff --git a/repo/includes/Query/SQLStore/DataValueHandler.php b/repo/includes/Query/SQLStore/DataValueHandler.php index 86f5045..2f10e0b 100644 --- a/repo/includes/Query/SQLStore/DataValueHandler.php +++ b/repo/includes/Query/SQLStore/DataValueHandler.php @@ -2,6 +2,9 @@ namespace Wikibase\Repo\Query\SQLStore; +use Wikibase\Repo\Database\TableDefinition; +use DataValues\DataValue; + /** * Represents the mapping between a DataValue type and the * associated implementation in the store. @@ -33,4 +36,69 @@ */ abstract class DataValueHandler { + /** +* Returns the definition of a table to hold DataValue objects of +* the type handled by this DataValueHandler. +* +* @since wd.qe +* +* @return TableDefinition +*/ + abstract public function getTableDefinition(); + + /** +* Returns the name of the field that holds the value from which +* a DataValue instance can be (re)constructed. +* +* The field should clearly be part of the table returned +* by @see getTableDefinition. +* +* @since wd.qe +* +* @return string +*/ + abstract public function getValueFieldName(); + + /** +* Return the field used to select this type of DataValue. In +* particular, this identifies the column that is used to sort values +* of this kind. Every type of data returns a non-empty string here. +* +* @since wd.qe +* +* @return string +*/ + abstract public function getSortField(); + + /** +* Create a DataValue from a cell value in the tables value field. +* +* @since wd.qe +* +* @param $dbValue // TODO: mixed or string? +* +* @return DataValue +*/ + abstract public function newDataValueFromDbValue( $dbValue ); + + /** +* Return the label field for this type of DataValue. This should be +* a string column in the database table that can be used for selecting +* values using criteria such as "starts with". The return value can be +* empty if this is not supported. This is preferred for SMWDataItem +* classes that do not have an obvious canonical string writing anyway. +* +* The return value can be a column name or the empty string (if the +* give type of DataValue does not have a label field). +* +* @since wd.qe +* +* @return string|null +*/ + public function getLabelField() { + return null; + } + + // TODO: getInsertValues and getWhereConds + } \ No newline at end of file diff --git a/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php b/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php index 1744f97..8514a7d 100644 --- a/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php +++ b/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php @@ -27,15 +27,70 @@ * * @ingroup WikibaseRepoTest * - * @group Wikibase - * @group WikibaseRepo - * @group WikibaseQuery - * * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > */ -class DataValueHandlerTest extends \MediaWikiTestCase { +abstract class Data
[MediaWiki-commits] [Gerrit] Added DataValueHandler tests - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added DataValueHandler tests .. Added DataValueHandler tests Change-Id: I73160e261668d6d234e6b927866f6d1747d2ba90 --- M repo/includes/Database/TableDefinition.php M repo/includes/Query/SQLStore/DataValueHandler.php M repo/tests/phpunit/includes/Database/TableDefinitionTest.php M repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php 4 files changed, 92 insertions(+), 11 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/TableDefinition.php b/repo/includes/Database/TableDefinition.php index f558738..c333869 100644 --- a/repo/includes/Database/TableDefinition.php +++ b/repo/includes/Database/TableDefinition.php @@ -66,7 +66,16 @@ } $this->name = $name; - $this->fields = $fields; + + $this->fields = array(); + + foreach ( $fields as $field ) { + if ( array_key_exists( $field->getName(), $this->fields ) ) { + throw new InvalidArgumentException( 'A table cannot have two fields with the same name' ); + } + + $this->fields[$field->getName()] = $field; + } } /** @@ -82,6 +91,8 @@ /** * Returns the fields that make up this table. +* The array keys in the returned array correspond to the names +* of the fields defined by the value they point to. * * @since wd.db * @@ -91,6 +102,19 @@ return $this->fields; } + /** +* Returns if the table has a field with the provided name. +* +* @since wd.db +* +* @param string $fieldName +* +* @return boolean +*/ + public function hasFieldWithName( $fieldName ) { + return array_key_exists( $fieldName, $this->fields ); + } + // TODO: multiple field indices } \ No newline at end of file diff --git a/repo/includes/Query/SQLStore/DataValueHandler.php b/repo/includes/Query/SQLStore/DataValueHandler.php index 2f10e0b..a9e30c4 100644 --- a/repo/includes/Query/SQLStore/DataValueHandler.php +++ b/repo/includes/Query/SQLStore/DataValueHandler.php @@ -68,7 +68,7 @@ * * @return string */ - abstract public function getSortField(); + abstract public function getSortFieldName(); /** * Create a DataValue from a cell value in the tables value field. @@ -95,7 +95,7 @@ * * @return string|null */ - public function getLabelField() { + public function getLabelFieldName() { return null; } diff --git a/repo/tests/phpunit/includes/Database/TableDefinitionTest.php b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php index cc1a168..393a795 100644 --- a/repo/tests/phpunit/includes/Database/TableDefinitionTest.php +++ b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php @@ -85,6 +85,14 @@ $this->assertInternalType( 'array', $table->getFields() ); $this->assertContainsOnlyInstancesOf( 'Wikibase\Repo\Database\FieldDefinition', $table->getFields() ); + foreach ( $table->getFields() as $expectedName => $field ) { + $this->assertEquals( + $expectedName, + $field->getName(), + 'The array key matches the corresponding field name' + ); + } + $newTable = new TableDefinition( $table->getName(), $table->getFields() ); $this->assertEquals( @@ -94,4 +102,18 @@ ); } + /** +* @dataProvider instanceProvider +* +* @param TableDefinition $table +*/ + public function testReturnValueOfHasField( TableDefinition $table ) { + foreach ( $table->getFields() as $field ) { + $this->assertTrue( $table->hasFieldWithName( $field->getName() ) ); + } + + $this->assertFalse( $table->hasFieldWithName( 'zsfrcvbxuyiyrewrbmndsrbtfocszdf' ) ); + $this->assertFalse( $table->hasFieldWithName( '' ) ); + } + } diff --git a/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php b/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php index 8514a7d..dd248a2 100644 --- a/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php +++ b/repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php @@ -30,7 +30,7 @@ * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > */ -abstract class DataValueHandlerTest extends \MediaWikiTestCase { +abst
[MediaWiki-commits] [Gerrit] Cleanup in EntityContent.php - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Cleanup in EntityContent.php .. Cleanup in EntityContent.php * Added documentation for how EntityContent::equal behaves since this is not clear from just looking at Content::equals. * Changed code of EntityContent::equal to be more self-explanatory * Changed some comments/documentation to fit into the 100chars per line limit Change-Id: If10c2877c9d4de83880c94e0a79f00a24aea1e91 --- M repo/includes/content/EntityContent.php 1 file changed, 47 insertions(+), 32 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/content/EntityContent.php b/repo/includes/content/EntityContent.php index 22314d3..448c9f3 100644 --- a/repo/includes/content/EntityContent.php +++ b/repo/includes/content/EntityContent.php @@ -125,7 +125,8 @@ public abstract function getEntity(); /** -* @return String a string representing the content in a way useful for building a full text search index. +* @return String a string representing the content in a way useful for building a full text +* search index. */ public function getTextForSearchIndex() { wfProfileIn( __METHOD__ ); @@ -194,15 +195,16 @@ } /** -* @return String the wikitext to include when another page includes this content, or false if the content is not -* includable in a wikitext page. +* @return String the wikitext to include when another page includes this content, or false if +* the content is not includable in a wikitext page. */ public function getWikitextForTransclusion() { return false; } /** -* Returns a textual representation of the content suitable for use in edit summaries and log messages. +* Returns a textual representation of the content suitable for use in edit summaries and log +* messages. * * @param int $maxlength maximum length of the summary text * @return String the summary text @@ -232,7 +234,11 @@ } /** -* @see Content::equals() +* Both contents will be considered equal if they have the same ID and equal Entity data. If +* one of the contents is considered "new", then matching IDs is not a criteria for them to be +* considered equal. +* +* @see Content::equals */ public function equals( \Content $that = null ) { if ( is_null( $that ) ) { @@ -247,24 +253,24 @@ return false; } - $thisId = $this->getEntity()->getPrefixedId(); - $thatId = $that->getEntity()->getPrefixedId(); + $thisEntity = $this->getEntity(); + $thatEntity = $that->getEntity(); - if ( $thisId !== null && $thatId !== null ) { - if ( $thisId !== $thatId ) { - return false; - } + if ( !$this->isNew() && !$that->isNew() + && $thisEntity->getPrefixedId() !== $thatEntity->getPrefixedId() + ) { + return false; } - return $this->getEntity()->equals( $that->getEntity() ); + return $thisEntity->equals( $thatEntity ); } /** * Returns true if this content is countable as a "real" wiki page, provided * that it's also in a countable location (e.g. a current revision in the main namespace). * -* @param boolean $hasLinks: if it is known whether this content contains links, provide this information here, -* to avoid redundant parsing to find out. +* @param boolean $hasLinks: if it is known whether this content contains links, provide this +*information here, to avoid redundant parsing to find out. * @return boolean */ public function isCountable( $hasLinks = null ) { @@ -305,8 +311,8 @@ * * @param String$permission the permission to check * @param null|User $user the user to check for. If omitted, $wgUser is checked. -* @param bool $doExpensiveQueries whether to perform expensive checks (default: true). May be set to false for -* non-critical checks. +* @param bool $doExpensiveQueries whether to perform expensive checks (default: true). May +* be set to false for non-critical checks. * * @return bool True if the user has the given permission, false otherwise. *
[MediaWiki-commits] [Gerrit] Allows to restrict output in Special:EntitiesWithoutLabels t... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Allows to restrict output in Special:EntitiesWithoutLabels to a specific entity type .. Allows to restrict output in Special:EntitiesWithoutLabels to a specific entity type Rebased Change-Id: I1756f2bf26ec2e4682d0a8aa58b3d51794b20e54 --- M repo/Wikibase.i18n.php M repo/includes/specials/SpecialEntitiesWithoutLabel.php 2 files changed, 60 insertions(+), 13 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 5e467da..bc11227 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -175,8 +175,11 @@ 'special-entitieswithoutlabel' => 'Entities without label', 'wikibase-entitieswithoutlabel-legend' => 'Get list of entities without label', 'wikibase-entitieswithoutlabel-label-language' => 'Language:', + 'wikibase-entitieswithoutlabel-label-type' => 'Type:', + 'wikibase-entitieswithoutlabel-label-alltypes' => 'all', 'wikibase-entitieswithoutlabel-submit' => 'Find', 'wikibase-entitieswithoutlabel-invalid-language' => '"$1" is not a valid language code.', + 'wikibase-entitieswithoutlabel-invalid-type' => '"$1" is not a valid entity type.', 'special-itemswithoutsitelinks' => 'Items without sitelinks', 'special-entitydata' => 'Entity data', 'wikibase-entitydata-not-found' => "No entity with ID $1 was found.", @@ -584,9 +587,11 @@ 'special-entitieswithoutlabel' => 'This special page returns a list of entities without label for a given language', 'wikibase-entitieswithoutlabel-legend' => 'Legend of the form that allow to change the language.', 'wikibase-entitieswithoutlabel-label-language' => 'Label for the input field to change the language.', - 'wikibase-entitieswithoutlabel-submit' => 'Label for the button that activate the action. -{{Identical|Find}}', - 'wikibase-entitieswithoutlabel-invalid-language' => 'Error message shown when the language code passed in parameter is invalid. $1 is invalid language code.', + 'wikibase-entitieswithoutlabel-label-type' => 'Label of the entity type selector that allows to restrict the request to one type.', + 'wikibase-entitieswithoutlabel-label-alltypes' => 'Label of the entity type selector entry that allows to output missing labels for all entity types', + 'wikibase-entitieswithoutlabel-submit' => 'Label for the button that activate the action.', + 'wikibase-entitieswithoutlabel-invalid-language' => 'Error message shown when the language code passed in parameter is invalid. $1 is the invalid language code.', + 'wikibase-entitieswithoutlabel-invalid-language' => 'Error message shown when the entity type passed in parameter is invalid. $1 is the invalid type.', 'special-itemswithoutsitelinks' => 'This special page returns a list of items without any site link', 'special-entitydata' => 'Title for special page that provides a linked data interface and easy way to get the JSON data representation for an entity.', 'wikibase-entitydata-not-found' => 'Error shown when no entity with the given ID could be found. Paramters: @@ -5610,6 +5615,7 @@ 'wikibase-sitelinks-add' => 'e Link bäi e Link vum Site derbäisetzen', 'wikibase-remove' => 'ewechhuelen', 'wikibase-propertyedittool-full' => "D'Lëscht vun de Wäerter ass komplett.", + 'wikibase-propertyedittool-counter-pending-pendingsubpart' => '+$1', 'wikibase-disambiguation-title' => 'Homonymie fir "$1"', 'wikibase-aliases-label' => 'Och bekannt als:', 'wikibase-snakview-variations-novalue-label' => 'kee Wäert', diff --git a/repo/includes/specials/SpecialEntitiesWithoutLabel.php b/repo/includes/specials/SpecialEntitiesWithoutLabel.php index db9eb91..19f1205 100644 --- a/repo/includes/specials/SpecialEntitiesWithoutLabel.php +++ b/repo/includes/specials/SpecialEntitiesWithoutLabel.php @@ -63,13 +63,36 @@ $output = $this->getOutput(); $request = $this->getRequest(); - $this->language = $request->getText( 'language', '' ); - if ( $this->language === '' && $subPage !== null ) { - $this->language = $subPage; + $this->language = ''; + $this->type = null; + if ( $subPage !== null ) { + $parts = explode( '/', $subPage ); + if ( count( $parts >= 2 ) ) { + $this->type = $parts[1]; + } + $this->language = $parts[0]; } + + $this->language = $request->getText( 'language', $this->language ); if ( $this->language !== '' && !in_array( $this->language, \Wikibase\Utils::ge
[MediaWiki-commits] [Gerrit] Make language names available in other languages. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Make language names available in other languages. .. Make language names available in other languages. Requires the CLDR extension for full functionality. Change-Id: I7125109c13a351147c0ea8917332d1c08da7096f --- M lib/includes/Utils.php M lib/tests/phpunit/UtilsTest.php 2 files changed, 49 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php index d9dcf5b..9cfe4cd 100644 --- a/lib/includes/Utils.php +++ b/lib/includes/Utils.php @@ -27,8 +27,10 @@ * @ingroup WikibaseLib * * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > * @author Tobias Gritschacher * @author Jens Ohlig < jens.oh...@wikimedia.de > + * @author John Erling Blad < jeb...@gmail.com > */ final class Utils { @@ -56,11 +58,19 @@ * @since 0.1 * * @param string $languageCode +* @param string|null $inLanguage * * @return string */ - public static function fetchLanguageName( $languageCode ) { - $languageName = \Language::fetchLanguageName( str_replace( '_', '-', $languageCode ) ); + public static function fetchLanguageName( $languageCode, $inLanguage = null ) { + $languageCode = str_replace( '_', '-', $languageCode ); + if ( isset( $inLanguage ) ) { + $inLanguage = str_replace( '_', '-', $inLanguage ); + $languageName = \Language::fetchLanguageName( $languageCode, $inLanguage ); + } + else { + $languageName = \Language::fetchLanguageName( $languageCode ); + } if ( $languageName == '' ) { $languageName = $languageCode; } diff --git a/lib/tests/phpunit/UtilsTest.php b/lib/tests/phpunit/UtilsTest.php index 819c015..7c7d38e 100644 --- a/lib/tests/phpunit/UtilsTest.php +++ b/lib/tests/phpunit/UtilsTest.php @@ -102,4 +102,41 @@ ); } + public static function provideFetchLanguageName() { + return array( + array( // #0 + 'en', + null, + 'English' + ), + array( // #1 + 'de', + null, + 'Deutsch' + ), + array( // #2 + 'en', + 'de', + 'Englisch' + ), + array( // #3 + 'de', + 'en', + 'German' + ), + ); + } + + /** +* @dataProvider provideFetchLanguageName +*/ + public function testFetchLanguageName( $lang, $in, $expected ) { + if ( $in !== null && !defined('CLDR_VERSION') ) { + $this->markTestSkipped( "CLDR extension required for full language name support" ); + } + + $name = Utils::fetchLanguageName( $lang, $in ); + $this->assertEquals( $expected, $name ); + } + } -- To view, visit https://gerrit.wikimedia.org/r/49073 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7125109c13a351147c0ea8917332d1c08da7096f Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler Gerrit-Reviewer: Aude Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45352, 45353) Add Special:ItemByTitle and Special:ItemD... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (Bug 45352, 45353) Add Special:ItemByTitle and Special:ItemDisambiguation to Special:SpecialPages .. (Bug 45352, 45353) Add Special:ItemByTitle and Special:ItemDisambiguation to Special:SpecialPages Add Special:ItemByTitle and Special:ItemDisambiguation to Special:SpecialPages Change-Id: Ifc17ae16fb86e451e25b6dba7b03547c1598eba9 --- M repo/includes/specials/SpecialItemResolver.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/specials/SpecialItemResolver.php b/repo/includes/specials/SpecialItemResolver.php index ce77fff..3739203 100644 --- a/repo/includes/specials/SpecialItemResolver.php +++ b/repo/includes/specials/SpecialItemResolver.php @@ -38,7 +38,7 @@ * @param string $name */ public function __construct( $name ) { - parent::__construct( $name, '', false ); + parent::__construct( $name, '' ); } /** -- To view, visit https://gerrit.wikimedia.org/r/50901 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifc17ae16fb86e451e25b6dba7b03547c1598eba9 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Anja Jentzsch Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45607) Add a callback for the hook for reordering of sp... - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/51826 Change subject: (Bug 45607) Add a callback for the hook for reordering of special pages .. (Bug 45607) Add a callback for the hook for reordering of special pages Change-Id: Iab2536c894c350f77e1619315fd8f55a7a1db5ac --- M repo/Wikibase.hooks.php M repo/Wikibase.php 2 files changed, 16 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/26/51826/1 diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 8040b26..a38d7dc 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -590,6 +590,20 @@ } /** +* Reorder the groups for the special pages +* +* @since 0.4 +* +* @param array $groups +* +* @return boolean +*/ + public static function onSpecialPage_reorderPages( &$groups ) { + $groups = array_merge( array( 'wikibaserepo' => null ), $groups ); + return true; + } + + /** * Deletes all the data stored on the repository. * @see https://www.mediawiki.org/wiki/Manual:Hooks/WikibaseDeleteData * diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 56187af..eec22ef 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -252,6 +252,7 @@ $wgSpecialPageGroups['SetLabel'] = 'wikibaserepo'; + // Hooks $wgHooks['BeforePageDisplay'][] = 'Wikibase\RepoHooks::onBeforePageDisplay'; $wgHooks['WikibaseDefaultSettings'][] = 'Wikibase\RepoHooks::onWikibaseDefaultSettings'; @@ -277,6 +278,7 @@ $wgHooks['ShowSearchHit'][]= 'Wikibase\RepoHooks::onShowSearchHit'; $wgHooks['TitleGetRestrictionTypes'][] = 'Wikibase\RepoHooks::onTitleGetRestrictionTypes'; $wgHooks['AbuseFilter-contentToString'][] = 'Wikibase\RepoHooks::onAbuseFilterContentToString'; +$wgHooks['SpecialPage_reorderPages'][] = 'Wikibase\RepoHooks::onSpecialPage_reorderPages'; // Resource Loader Modules: $wgResourceModules = array_merge( $wgResourceModules, include( "$dir/resources/Resources.php" ) ); -- To view, visit https://gerrit.wikimedia.org/r/51826 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iab2536c894c350f77e1619315fd8f55a7a1db5ac Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45607) Add a hook to make it possible to reorder the li... - change (mediawiki/core)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/51827 Change subject: (Bug 45607) Add a hook to make it possible to reorder the list of special pages .. (Bug 45607) Add a hook to make it possible to reorder the list of special pages Change-Id: I0e37563a3b7e9fe6683d386b562b50a5404dc9a8 --- M includes/specials/SpecialSpecialpages.php 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/27/51827/1 diff --git a/includes/specials/SpecialSpecialpages.php b/includes/specials/SpecialSpecialpages.php index d80218f..c37fbdb 100644 --- a/includes/specials/SpecialSpecialpages.php +++ b/includes/specials/SpecialSpecialpages.php @@ -81,6 +81,9 @@ } } + /** Hook for reordering the list of special pages */ + wfRunHooks( 'SpecialPage_reorderPages', array( &$groups ) ); + /** Always move "other" to end */ if( array_key_exists( 'other', $groups ) ) { $other = $groups['other']; -- To view, visit https://gerrit.wikimedia.org/r/51827 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0e37563a3b7e9fe6683d386b562b50a5404dc9a8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45223) URL-escape title before it is used in URL - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/51956 Change subject: (Bug 45223) URL-escape title before it is used in URL .. (Bug 45223) URL-escape title before it is used in URL Change-Id: I2c5dcb997157b36fda6547714b12be7dfa6b4712 --- M client/WikibaseClient.hooks.php 1 file changed, 8 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/56/51956/1 diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index fbe0d19..93058f2 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -377,7 +377,7 @@ ); if ( $itemId !== false ) { - $itemByTitle = 'Special:ItemByTitle/' . $globalId . '/' . $oldTitle->getDBkey(); + $itemByTitle = 'Special:ItemByTitle/' . $globalId . '/' . wfUrlencode( $oldTitle->getDBkey() ); $itemByTitleLink = ClientUtils::repoArticleUrl( $itemByTitle ); $out = $movePage->getOutput(); $out->addModules( 'wikibase.client.page-move' ); @@ -597,12 +597,6 @@ $title = $skin->getContext()->getTitle(); if ( in_array( $title->getNamespace(), Settings::get( 'namespaces' ) ) && $title->exists() ) { - $title = $skin->getContext()->getTitle(); - - // gets the main part of the title, no underscores used in this db table - $titleText = $title->getPrefixedText(); - $siteId = Settings::get( 'siteGlobalID' ); - if ( empty( $template->data['language_urls'] ) && \Action::getActionName( $skin->getContext() ) === 'view' ) { // Placeholder in case the page doesn't have any langlinks yet // self::onBeforePageDisplay adds the JavaScript module which will overwrite this with a link @@ -616,12 +610,18 @@ return true; } + $title = $skin->getContext()->getTitle(); + + // gets the main part of the title, no underscores used in this db table + $titleText = $title->getPrefixedText(); + $siteId = Settings::get( 'siteGlobalID' ); + $itemId = ClientStoreFactory::getStore()->newSiteLinkTable()->getItemIdForLink( $siteId, $titleText ); if ( $itemId ) { // links to the special page $template->data['language_urls'][] = array( - 'href' => ClientUtils::repoArticleUrl( "Special:ItemByTitle/$siteId/$titleText" ), + 'href' => ClientUtils::repoArticleUrl( "Special:ItemByTitle/$siteId/" . wfUrlencode( $titleText ) ), 'text' => wfMessage( 'wikibase-editlinks' )->text(), 'title' => wfMessage( 'wikibase-editlinkstitle' )->text(), 'class' => 'wbc-editpage', -- To view, visit https://gerrit.wikimedia.org/r/51956 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2c5dcb997157b36fda6547714b12be7dfa6b4712 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45627) Add tags for id and revision [DO NOT MERGE] - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/51976 Change subject: (Bug 45627) Add tags for id and revision [DO NOT MERGE] .. (Bug 45627) Add tags for id and revision [DO NOT MERGE] Change-Id: Ied9c25f8ee1ac6d6dbc08db82aa5eb86f3add37f --- M client/WikibaseClient.hooks.php M client/WikibaseClient.php 2 files changed, 40 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/76/51976/1 diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index fbe0d19..dea0e7f 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -723,5 +723,44 @@ return true; } + + /** +* Called at the end of Parser::clearState() +* +* @todo This can be replace with pulling out the item id from the page prop +* +* @since 0.5 +* +* @param $parser \Parser +* @return bool +*/ + +public static function onParserClearState( &$parser ) { + global $wgTitle, $wgOut; + + $titleText = $wgTitle->getPrefixedText(); + $siteId = Settings::get( 'siteGlobalID' ); + + $itemId = ClientStoreFactory::getStore()->newSiteLinkTable()->getItemIdForLink( $siteId, $titleText ); + + if ( $itemId ) { + $wgOut->addHeadItem( 'wikibase-item-id', "" ); + } + + /* + // Something similar to this should produce a meta entry refering to the revision + $entityContentFactory = \Wikibase\EntityContentFactory::singleton(); + $entityId = new \Wikibase\EntityId( Item::ENTITY_TYPE, $id ); + $entityContent = $entityContentFactory->getFromId( $entityId ); + $page = $entityContent->getWikiPage(); + $revisionId = $page->getLatest(); + + if ( $revisionId ) { + $wgOut->addHeadItem( 'wikibase-item-latest', "" ); + } + */ + + return true; + } } diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 29fa870..5620b7e 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -110,6 +110,7 @@ $wgHooks['GetPreferences'][] = '\Wikibase\ClientHooks::onGetPreferences'; $wgHooks['BeforePageDisplay'][]= '\Wikibase\ClientHooks::onBeforePageDisplay'; $wgHooks['SpecialPageBeforeExecute'][] = '\Wikibase\ClientHooks::onSpecialPageBeforeExecute'; +$wgHooks['ParserClearState'][] = '\Wikibase\ClientHooks::onParserClearState'; // extension hooks $wgHooks['WikibasePollHandle'][]= '\Wikibase\ClientHooks::onWikibasePollHandle'; -- To view, visit https://gerrit.wikimedia.org/r/51976 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ied9c25f8ee1ac6d6dbc08db82aa5eb86f3add37f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] (Bug 45682) Add parser function for "label" - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/51977 Change subject: (Bug 45682) Add parser function for "label" .. (Bug 45682) Add parser function for "label" This adds a parser function that prints out the label for a given id. It takes one or more optional languages and will try them in sequence, stopping on the first found label. It can also work without languages and in that case it will use the user language and its global fallback chain. Change-Id: If900b891d9bb85129eda69c36f42163e34488c44 --- M repo/Wikibase.hooks.php A repo/Wikibase.i18n.magic.php M repo/Wikibase.i18n.php M repo/Wikibase.php A repo/includes/parserfunction/Label.php 5 files changed, 228 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/77/51977/1 diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 8040b26..9dd4107 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -980,4 +980,52 @@ return false; } + + /** +* Register parser functions. +* +* @since 0.5 +* +* @param &$parser \Parser +* +* @return bool +*/ + public static function onParserFirstCallInit( &$parser ) { + $parser->setFunctionHook( 'label', '\Wikibase\ParserFunction\Label::handle', SFH_NO_HASH ); + return true; + } + + /** +* Register the magic words. +* +* @since 0.5 +* +* @param &$aCustomVariableIds +* +* @return bool +*/ + public static function onMagicWordwgVariableIDs( &$aCustomVariableIds ) { + $aCustomVariableIds[] = 'label'; + return true; + } + + /** +* Apply the magic word. +* +* @since 0.5 +* +* @param &$parser \Parser +* @param &$cache +* @param &$magicWordId +* @param &$ret +* +* @return bool +*/ + public static function onParserGetVariableValueSwitch( &$parser, &$cache, &$magicWordId, &$ret ) { + if( $magicWordId == 'label' ) { + \Wikibase\ParserFunction\Label::handle( $parser, '' ); + } + + return true; + } } diff --git a/repo/Wikibase.i18n.magic.php b/repo/Wikibase.i18n.magic.php new file mode 100644 index 000..cc5666b --- /dev/null +++ b/repo/Wikibase.i18n.magic.php @@ -0,0 +1,20 @@ + array( 0, 'label' ), +); + diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index ee60bd6..d18f281 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -245,6 +245,12 @@ to find out where it went.', 'wikibase-noentity-createone' => 'You can also [[$1|create a new one]].', + 'wikibase-parserfunction-label-unknown-entity' => 'Label: The entity $1 is unknown', + 'wikibase-parserfunction-label-unkown-content' => 'Label: The type of $1 is unknown', + 'wikibase-parserfunction-label-unkown-serialization' => 'Label: The content of $1 is broken', + 'wikibase-parserfunction-label-found' => '$3', + 'wikibase-parserfunction-label-not-found' => 'Label: No content in $1 for language "$2"', + // item - summary and autocomment 'wikibase-item-summary-wbsetitem' => 'Created a new item', // legacy 'wikibase-item-summary-wbeditentity' => 'Created a new item', // legacy @@ -678,6 +684,21 @@ * $1 is the name of the namespace for which direct editing was denied.', 'wikibase-noentity' => 'Of some reason the user tried to access an entity which then was detected as non-existing. This can happen when an entity is deleted and clients are not yet made aware of this.', 'wikibase-noentity-createone' => 'Put immediately after "wikibase-noentity" if the user has the right to create an entity of the given type. This message tells the user that he can create one and gives a link in $1 to the special page where this can be done.', + + 'wikibase-parserfunction-label-unknown-entity' => 'Failed lookup of a label from the label parser function. In this case something is wrong with the id, perhaps illegal characters are added to the string. +* $1 is the failing item id', + 'wikibase-parserfunction-label-unkown-content' => 'Failed lookup of a label from the label parser function. In this case something was found, but it was not recognized as something of valid type. +* $1 is the actual label', + 'wikibase-parserfunction-label-unkown-serialization' => 'Failed lookup of a label from the label parser function. In this case the unserialization failed, for example due to incompatible versions of the Wikibase extension or because of corrupt database. +* $1 is the actual label', + 'wikibase-parserfunction-label-found' => 'The lookup of a labe
[MediaWiki-commits] [Gerrit] Use American English spelling for behavior - change (mediawiki...Diff)
John Erling Blad has submitted this change and it was merged. Change subject: Use American English spelling for behavior .. Use American English spelling for behavior Change-Id: I58eba0685aadfa60461b7516772c92352640b116 --- M compat/GenericArrayObject.php M includes/differ/ListDiffer.php M includes/patcher/MapPatcher.php 3 files changed, 5 insertions(+), 5 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/compat/GenericArrayObject.php b/compat/GenericArrayObject.php index bf24ab5..2f36042 100644 --- a/compat/GenericArrayObject.php +++ b/compat/GenericArrayObject.php @@ -181,7 +181,7 @@ /** * Returns an array holding all the data that should go into serialization calls. * This is intended to allow overloading without having to reimplement the -* behaviour of this base class. +* behavior of this base class. * * @since 0.1 * diff --git a/includes/differ/ListDiffer.php b/includes/differ/ListDiffer.php index f072dc1..90d6e2c 100644 --- a/includes/differ/ListDiffer.php +++ b/includes/differ/ListDiffer.php @@ -68,7 +68,7 @@ * Takes an argument that determines the diff mode. * By default this is ListDiffer::MODE_STRICT, which causes * computation in @see doDiff to be done via @see arrayDiff. -* If the native behaviour is preferred, ListDiffer::MODE_NATIVE +* If the native behavior is preferred, ListDiffer::MODE_NATIVE * can be specified. * * @since 0.4 @@ -168,4 +168,4 @@ return $notInTwo; } -} \ No newline at end of file +} diff --git a/includes/patcher/MapPatcher.php b/includes/patcher/MapPatcher.php index 9fc5693..955c12c 100644 --- a/includes/patcher/MapPatcher.php +++ b/includes/patcher/MapPatcher.php @@ -80,7 +80,7 @@ * The array is treated as a map, ie keys are held into account. * * It is possible to pass in non-associative diffs (those for which isAssociative) -* returns false, however the likely intended behaviour can be obtained via +* returns false, however the likely intended behavior can be obtained via * @see getPatchedList * * @since 0.4 @@ -146,4 +146,4 @@ return $base; } -} \ No newline at end of file +} -- To view, visit https://gerrit.wikimedia.org/r/52000 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I58eba0685aadfa60461b7516772c92352640b116 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Diff Gerrit-Branch: master Gerrit-Owner: Siebrand Gerrit-Reviewer: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Raimond Spekking Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use American English spelling for behavior - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Use American English spelling for behavior .. Use American English spelling for behavior Change-Id: Id13d1110c08d43d968fc7dad1ae319da14324539 --- M client/tests/phpunit/includes/EntityCacheUpdaterTest.php M client/tests/selenium/interwiki/client_repo_spec.rb M client/tests/selenium/interwiki/interwiki_spec.rb M lib/includes/claim/Claim.php M lib/includes/entity/Entity.php M lib/includes/snak/Snak.php M lib/includes/snak/Snaks.php M lib/resources/wikibase.ui.PropertyEditTool.css M lib/resources/wikibase.ui.Toolbar.EditGroup.js M repo/includes/api/GetEntities.php M repo/includes/store/sql/TermSqlCache.php M repo/includes/updates/EntityDeletionUpdate.php M repo/includes/updates/EntityModificationUpdate.php M repo/tests/phpunit/includes/content/EntityHandlerTest.php M repo/tests/selenium/aliases/aliases_spec.rb M repo/tests/selenium/item/description_spec.rb M repo/tests/selenium/item/edit_conflict_spec.rb M repo/tests/selenium/item/label_spec.rb M repo/tests/selenium/special/create_item_spec.rb M repo/tests/selenium/special/create_property_spec.rb M repo/tests/selenium/statements/references_spec.rb M repo/tests/selenium/statements/statements_spec.rb 22 files changed, 37 insertions(+), 37 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/client/tests/phpunit/includes/EntityCacheUpdaterTest.php b/client/tests/phpunit/includes/EntityCacheUpdaterTest.php index 6345b02..0494461 100644 --- a/client/tests/phpunit/includes/EntityCacheUpdaterTest.php +++ b/client/tests/phpunit/includes/EntityCacheUpdaterTest.php @@ -70,7 +70,7 @@ $cacheUpdater->handleChange( $change ); - // TODO: test if the result matches expected behaviour + // TODO: test if the result matches expected behavior $this->assertTrue( true ); } } diff --git a/client/tests/selenium/interwiki/client_repo_spec.rb b/client/tests/selenium/interwiki/client_repo_spec.rb index dff16e8..d258ef4 100644 --- a/client/tests/selenium/interwiki/client_repo_spec.rb +++ b/client/tests/selenium/interwiki/client_repo_spec.rb @@ -100,7 +100,7 @@ end end - context "client-repo check behaviour on changing connecting sitelink" do + context "client-repo check behavior on changing connecting sitelink" do it "should change the connecting sitelink to a nonexisting article" do on_page(ItemPage) do |page| page.navigate_to_item diff --git a/client/tests/selenium/interwiki/interwiki_spec.rb b/client/tests/selenium/interwiki/interwiki_spec.rb index bcd0051..029b2d9 100644 --- a/client/tests/selenium/interwiki/interwiki_spec.rb +++ b/client/tests/selenium/interwiki/interwiki_spec.rb @@ -43,7 +43,7 @@ page.clientEditLinksLink?.should be_true end end -it "should check correct behaviour of editLinks-Link" do +it "should check correct behavior of editLinks-Link" do on_page(ClientPage) do |page| page.navigate_to_article(article_title) page.clientEditLinksLink @@ -56,7 +56,7 @@ end end - context "Check noexternallanglinks magic word behaviour" do + context "Check noexternallanglinks magic word behavior" do it "should check noexternallanglinks zh|af" do on_page(ClientPage) do |page| page.change_article(article_title, article_text + nell_zhaf) diff --git a/lib/includes/claim/Claim.php b/lib/includes/claim/Claim.php index 1159f60..bcb48fe 100644 --- a/lib/includes/claim/Claim.php +++ b/lib/includes/claim/Claim.php @@ -171,7 +171,7 @@ * Roundtrips with Claim::newFromArray * * This method can be used for serialization when passing the array to for -* instance json_encode which created behaviour similar to +* instance json_encode which created behavior similar to * @see Serializable::serialize but different in that it uses the * type identifiers rather then class names. * @@ -243,4 +243,4 @@ /** * @deprecated since 0.4. Use Claim instead. */ -class ClaimObject extends Claim {} \ No newline at end of file +class ClaimObject extends Claim {} diff --git a/lib/includes/entity/Entity.php b/lib/includes/entity/Entity.php index 1ec56c9..3dce23e 100644 --- a/lib/includes/entity/Entity.php +++ b/lib/includes/entity/Entity.php @@ -104,7 +104,7 @@ public function serialize() { $data = $this->toArray(); - // Add an identifier for the serialization version so we can switch behaviour in + // Add an identifier for the serialization version so we can switch behavior in // the unserializer to avoid breaking compatibility after certain changes. $data['v'] = 1; @@ -869,7 +869,7 @@ * @param
[MediaWiki-commits] [Gerrit] Add debug point for sites data - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Add debug point for sites data .. Add debug point for sites data Change-Id: Ic8606a33931acf1be11a5f52ed75a4583acf8cce --- M repo/includes/specials/SpecialItemByTitle.php 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/specials/SpecialItemByTitle.php b/repo/includes/specials/SpecialItemByTitle.php index acdf604..305b996 100644 --- a/repo/includes/specials/SpecialItemByTitle.php +++ b/repo/includes/specials/SpecialItemByTitle.php @@ -102,6 +102,8 @@ $siteExists = $sites->hasSite( $siteId ); + wfDebugLog( __CLASS__, __FUNCTION__ . ": Site $siteId exists: " . var_export( $siteExists, true ) ); + $this->getOutput()->addModules( 'wikibase.special.itemByTitle' ); $this->getOutput()->addHTML( -- To view, visit https://gerrit.wikimedia.org/r/48481 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic8606a33931acf1be11a5f52ed75a4583acf8cce Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude Gerrit-Reviewer: Anja Jentzsch Gerrit-Reviewer: Daniel Kinzler Gerrit-Reviewer: Denny Vrandecic Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implementing create table in the query interface - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Implementing create table in the query interface .. Implementing create table in the query interface Change-Id: I763305af860c44867b7119769f93f5a4e3b62732 --- M repo/config/Wikibase.experimental.php A repo/includes/Database/MWDB/ExtendedAbstraction.php A repo/includes/Database/MWDB/ExtendedMySQLAbstraction.php M repo/includes/Database/MediaWikiQueryInterface.php M repo/includes/Database/ObservableQueryInterface.php M repo/includes/Database/QueryInterface.php A repo/tests/phpunit/includes/Database/MWDB/ExtendedAbstractionTest.php A repo/tests/phpunit/includes/Database/MWDB/ExtendedMySQLAbstractionTest.php A repo/tests/phpunit/includes/Database/MediaWikiQueryInterfaceTest.php 9 files changed, 657 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 57193a5..483e855 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -47,6 +47,9 @@ $classes = array( + 'Wikibase\Repo\Database\MWDB\ExtendedAbstraction', + 'Wikibase\Repo\Database\MWDB\ExtendedMySQLAbstraction', + 'Wikibase\Repo\Database\FieldDefinition', 'Wikibase\Repo\Database\MediaWikiQueryInterface', 'Wikibase\Repo\Database\ObservableQueryInterface', @@ -84,6 +87,9 @@ $wgAutoloadClasses['Wikibase\Repo\Test\Query\QueryStoreTest'] = $dir . 'tests/phpunit/includes/Query/QueryStoreTest.php'; + + $wgAutoloadClasses['Wikibase\Repo\Test\Database\MWDB\ExtendedAbstractionTest'] + = $dir . 'tests/phpunit/includes/Database/MWDB/ExtendedAbstractionTest.php'; } unset( $dir ); @@ -118,7 +124,10 @@ 'content/QueryContent', 'content/QueryHandler', + 'Database/MWDB/ExtendedMySQLAbstraction', + 'Database/FieldDefinition', + 'Database/MediaWikiQueryInterface', 'Database/TableBuilder', 'Database/TableDefinition', diff --git a/repo/includes/Database/MWDB/ExtendedAbstraction.php b/repo/includes/Database/MWDB/ExtendedAbstraction.php new file mode 100644 index 000..5c06b34 --- /dev/null +++ b/repo/includes/Database/MWDB/ExtendedAbstraction.php @@ -0,0 +1,99 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.db + * + * @file + * @ingroup WikibaseRepo + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +abstract class ExtendedAbstraction { + + /** +* @since wd.db +* +* @var DBConnectionProvider +*/ + private $connectionProvider; + + /** +* @since wd.db +* +* @param DBConnectionProvider $connectionProvider +*/ + public function __construct( DBConnectionProvider $connectionProvider ) { + $this->connectionProvider = $connectionProvider; + } + + /** +* @since wd.db +* +* @return DatabaseBase +* @throws InvalidArgumentException +*/ + public function getDB() { + $db = $this->connectionProvider->getConnection(); + + if ( $db->getType() !== $this->getType() ) { + throw new InvalidArgumentException(); + } + + return $db; + } + + /** +* Create the provided table. +* +* @since wd.db +* +* @param TableDefinition $table +* +* @return boolean Success indicator +*/ + public abstract function createTable( TableDefinition $table ); + + /** +* Returns the type of the supported MW DB abstraction class. +* +* @since wd.db +* +* @return string +*/ + protected abstract function getType(); + +} \ No newline at end of file diff --git a/repo/includes/Database/MWDB/ExtendedMySQLAbstraction.php b/repo/includes/Database/MWDB/ExtendedMySQLAbstraction.php new file mode 100644 index 000..84da264 --- /dev/null +++ b/repo/includes/Database/MWDB/ExtendedMySQLAbstraction.php @@ -0,0 +1,125 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.db + * + * @file + * @ingroup WikibaseRepo + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class ExtendedMySQLAbstraction extends ExtendedAbstraction { + + /** +* @see ExtendedAbstraction::getType +* +* @since wd.db +* +* @return string +*/ + protected function getType() { + return 'mysql'; + } + + /** +* @see ExtendedAbstraction::createTable +* +* @since wd.db +* +* @param TableDefinition $table +* +* @return
[MediaWiki-commits] [Gerrit] Added base of GeoCoordinateHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added base of GeoCoordinateHandler .. Added base of GeoCoordinateHandler Change-Id: Ibdf6679b3a0e657cef65cc77e525aec883bc047f --- M repo/config/Wikibase.experimental.php M repo/includes/Database/FieldDefinition.php A repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php M repo/includes/Query/SQLStore/DataValueHandler.php M repo/tests/phpunit/includes/Database/FieldDefinitionTest.php M repo/tests/phpunit/includes/Database/TableDefinitionTest.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/GeoCoordinateHandlerTest.php M repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php 8 files changed, 182 insertions(+), 17 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 57193a5..e5e52d8 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -59,6 +59,8 @@ 'Wikibase\Repo\Query\QueryResult', 'Wikibase\Repo\Query\QueryStore', + 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', + 'Wikibase\Repo\Query\SQLStore\DataValueHandler', 'Wikibase\Repo\Query\SQLStore\Engine', 'Wikibase\Repo\Query\SQLStore\Setup', @@ -79,6 +81,9 @@ } if ( defined( 'MW_PHPUNIT_TEST' ) ) { + $wgAutoloadClasses['Wikibase\Repo\Test\Query\SQLStore\DataValueHandlerTest'] + = $dir . 'tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php'; + $wgAutoloadClasses['Wikibase\Repo\Test\Query\QueryEngineTest'] = $dir . 'tests/phpunit/includes/Query/QueryEngineTest.php'; @@ -124,6 +129,8 @@ 'Query/QueryEngineResult', + 'Query/SQLStore/DVHandler/GeoCoordinateHandler', + 'Query/SQLStore/DataValueHandler', 'Query/SQLStore/Engine', 'Query/SQLStore/Setup', diff --git a/repo/includes/Database/FieldDefinition.php b/repo/includes/Database/FieldDefinition.php index e1d3301..d280e5c 100644 --- a/repo/includes/Database/FieldDefinition.php +++ b/repo/includes/Database/FieldDefinition.php @@ -93,15 +93,15 @@ /** * @param string $name * @param string $type +* @param boolean $null * @param mixed $default * @param string|null $attributes -* @param boolean $null * @param string|null $index * @param boolean $autoIncrement * * @throws InvalidArgumentException */ - public function __construct( $name, $type, $default = null, $attributes = null, $null = true, $index = null, $autoIncrement = false ) { + public function __construct( $name, $type, $null = true, $default = null, $attributes = null, $index = null, $autoIncrement = false ) { if ( !is_string( $name ) ) { throw new InvalidArgumentException( 'The field $name needs to be a string' ); } diff --git a/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php b/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php new file mode 100644 index 000..62c9d98 --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php @@ -0,0 +1,103 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class GeoCoordinateHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'lat', FieldDefinition::TYPE_FLOAT, false ), + new FieldDefinition( 'lon', FieldDefinition::TYPE_FLOAT, false ), + new FieldDefinition( 'alt', FieldDefinition::TYPE_FLOAT, true ), + new FieldDefinition( 'json', FieldDefinition::TYPE_TEXT, false ), + ); + + return new TableDefinition( 'geo', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'json'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'lat'; + } + + /** +* @see DataValueHandler::newDataValueFromDbValue +* +* @since wd.qe +* +* @param $dbValue //
[MediaWiki-commits] [Gerrit] Added getWhereConditions and getInsertValues to the DVHandlers - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added getWhereConditions and getInsertValues to the DVHandlers .. Added getWhereConditions and getInsertValues to the DVHandlers Change-Id: I99120fe730a1abb2f1e4e01bceef8215b9af1c8f --- M repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php M repo/includes/Query/SQLStore/DataValueHandler.php M repo/tests/phpunit/includes/Query/SQLStore/DVHandler/GeoCoordinateHandlerTest.php M repo/tests/phpunit/includes/Query/SQLStore/DataValueHandlerTest.php 4 files changed, 198 insertions(+), 19 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php b/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php index 62c9d98..5b6c7ca 100644 --- a/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php +++ b/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php @@ -6,6 +6,8 @@ use Wikibase\Repo\Database\TableDefinition; use Wikibase\Repo\Database\FieldDefinition; use DataValues\DataValue; +use DataValues\GeoCoordinateValue; +use InvalidArgumentException; /** * Represents the mapping between DataValues\GeoCoordinateValue and @@ -48,6 +50,7 @@ new FieldDefinition( 'lat', FieldDefinition::TYPE_FLOAT, false ), new FieldDefinition( 'lon', FieldDefinition::TYPE_FLOAT, false ), new FieldDefinition( 'alt', FieldDefinition::TYPE_FLOAT, true ), + new FieldDefinition( 'globe', FieldDefinition::TYPE_TEXT, true ), new FieldDefinition( 'json', FieldDefinition::TYPE_TEXT, false ), ); @@ -77,16 +80,16 @@ } /** -* @see DataValueHandler::newDataValueFromDbValue +* @see DataValueHandler::newDataValueFromValueField * * @since wd.qe * -* @param $dbValue // TODO: mixed or string? +* @param $valueFieldValue // TODO: mixed or string? * * @return DataValue */ - public function newDataValueFromDbValue( $dbValue ) { - // TODO + public function newDataValueFromValueField( $valueFieldValue ) { + return GeoCoordinateValue::newFromArray( json_decode( $valueFieldValue, true ) ); } /** @@ -100,4 +103,61 @@ return null; } + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof GeoCoordinateValue ) ) { + throw new InvalidArgumentException( 'Value is not a GeoCoordinateValue' ); + } + + return array( + // Note: the code in this package is not dependent on MW. + // So do not replace this with FormatJSON::encode. + 'json' => json_encode( $value->getArrayValue() ), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getInsertValues( DataValue $value ) { + if ( !( $value instanceof GeoCoordinateValue ) ) { + throw new InvalidArgumentException( 'Value is not a GeoCoordinateValue' ); + } + + $values = array( + 'lat' => $value->getLatitude(), + 'lon' => $value->getLongitude(), + + // Note: the code in this package is not dependent on MW. + // So do not replace this with FormatJSON::encode. + 'json' => json_encode( $value->getArrayValue() ), + ); + + if ( $value->getAltitude() !== null ) { + $values['alt'] = $value->getAltitude(); + } + + if ( $value->getGlobe() !== null ) { + $values['globe'] = $value->getGlobe(); + } + + return $values; + } + } \ No newline at end of file diff --git a/repo/includes/Query/SQLStore/DataValueHandler.php b/repo/includes/Query/SQLStore/DataValueHandler.php index 7012370..2cbe77a 100644 --- a/repo/includes/Query/SQLStore/DataValueHandler.php +++ b/repo/includes/Query/SQLStore/DataValueHandler.php @@ -9,7 +9,8 @@ * Represents the mapping between a DataValue type and the * associated implementation in the store. * - * Based on SMWDataItemHandler by Nischay Nahata and Markus Kr
[MediaWiki-commits] [Gerrit] Added EntityIdHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added EntityIdHandler .. Added EntityIdHandler Change-Id: Iadc1dc2e42326f1b01f923d56e24860e36f99b22 --- M repo/config/Wikibase.experimental.php A repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/EntityIdHandlerTest.php 3 files changed, 230 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index c9a56ce..2787742 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -62,6 +62,7 @@ 'Wikibase\Repo\Query\QueryResult', 'Wikibase\Repo\Query\QueryStore', + 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', 'Wikibase\Repo\Query\SQLStore\DataValueHandler', @@ -138,6 +139,7 @@ 'Query/QueryEngineResult', + 'Query/SQLStore/DVHandler/EntityIdHandler', 'Query/SQLStore/DVHandler/GeoCoordinateHandler', 'Query/SQLStore/DataValueHandler', diff --git a/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php b/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php new file mode 100644 index 000..a275ef3 --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php @@ -0,0 +1,153 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class EntityIdHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'type', FieldDefinition::TYPE_TEXT, false ), + new FieldDefinition( 'number', FieldDefinition::TYPE_INTEGER, false ), + new FieldDefinition( 'json', FieldDefinition::TYPE_TEXT, false ), + ); + + return new TableDefinition( 'entityid', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'json'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'number'; + } + + /** +* @see DataValueHandler::newDataValueFromValueField +* +* @since wd.qe +* +* @param $valueFieldValue // TODO: mixed or string? +* +* @return DataValue +*/ + public function newDataValueFromValueField( $valueFieldValue ) { + return EntityId::newFromArray( json_decode( $valueFieldValue, true ) ); + } + + /** +* @see DataValueHandler::getLabelFieldName +* +* @since wd.qe +* +* @return string|null +*/ + public function getLabelFieldName() { + return null; + } + + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof EntityId ) ) { + throw new InvalidArgumentException( 'Value is not a EntityId' ); + } + + return array( + // Note: the code in this package is not dependent on MW. + // So do not replace this with FormatJSON::encode. + 'json' => json_encode( $value->getArrayValue() ), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getInsertValues( DataValue $value ) { + if ( !( $value instanceof EntityId ) ) { + throw new InvalidArgumentException( 'Value is not a EntityId' ); + } + + $values = array( + 'type' => $value->getEntityType(), + 'number' => $value->getNumericId(), + + // N
[MediaWiki-commits] [Gerrit] Added StringHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added StringHandler .. Added StringHandler Change-Id: I5a7d4187a7e9df674faf44fecca01a46f7b56444 --- M repo/config/Wikibase.experimental.php A repo/includes/Query/SQLStore/DVHandler/StringHandler.php M repo/tests/phpunit/includes/Query/SQLStore/DVHandler/EntityIdHandlerTest.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/StringHandlerTest.php 4 files changed, 222 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 2787742..10a42a5 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -64,6 +64,7 @@ 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', + 'Wikibase\Repo\Query\SQLStore\DVHandler\StringHandler', 'Wikibase\Repo\Query\SQLStore\DataValueHandler', 'Wikibase\Repo\Query\SQLStore\Engine', @@ -141,6 +142,7 @@ 'Query/SQLStore/DVHandler/EntityIdHandler', 'Query/SQLStore/DVHandler/GeoCoordinateHandler', + 'Query/SQLStore/DVHandler/StringHandler', 'Query/SQLStore/DataValueHandler', 'Query/SQLStore/Engine', diff --git a/repo/includes/Query/SQLStore/DVHandler/StringHandler.php b/repo/includes/Query/SQLStore/DVHandler/StringHandler.php new file mode 100644 index 000..7965876 --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/StringHandler.php @@ -0,0 +1,144 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class StringHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'value', FieldDefinition::TYPE_TEXT, false ), + ); + + return new TableDefinition( 'string', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'value'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'value'; + } + + /** +* @see DataValueHandler::newDataValueFromValueField +* +* @since wd.qe +* +* @param $valueFieldValue // TODO: mixed or string? +* +* @return DataValue +*/ + public function newDataValueFromValueField( $valueFieldValue ) { + return new StringValue( $valueFieldValue ); + } + + /** +* @see DataValueHandler::getLabelFieldName +* +* @since wd.qe +* +* @return string|null +*/ + public function getLabelFieldName() { + return null; + } + + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof StringValue ) ) { + throw new InvalidArgumentException( 'Value is not a StringValue' ); + } + + return array( + 'value' => $value->getValue(), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getInsertValues( DataValue $value ) { + if ( !( $value instanceof StringValue ) ) { + throw new InvalidArgumentException( 'Value is not a StringValue' ); + } + + $values = array( + 'value' => $value->getValue(), + ); + + return $values; + } + +} \ No newline at end of file diff --git a/repo/tests/phpunit/includes/Query/SQLStore/DVHandler/EntityIdHandlerTest.php b/repo/tests/phpunit/includes/Query/SQLStore/DVHandler/EntityIdHandlerTest.php index 9d46833..cb7b9d7 100644 --- a/repo/tests/phpunit/includes/Q
[MediaWiki-commits] [Gerrit] Added some more stub stuff in the sqlstore - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added some more stub stuff in the sqlstore .. Added some more stub stuff in the sqlstore Change-Id: Ibefeadd4f3e1e0c6c0413c1b6037373ef69c0541 --- M repo/config/Wikibase.experimental.php M repo/includes/Query/SQLStore/Engine.php A repo/includes/Query/SQLStore/Writer.php M repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php 4 files changed, 73 insertions(+), 5 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 10a42a5..2853eea 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -70,6 +70,7 @@ 'Wikibase\Repo\Query\SQLStore\Engine', 'Wikibase\Repo\Query\SQLStore\Setup', 'Wikibase\Repo\Query\SQLStore\Store', + 'Wikibase\Repo\Query\SQLStore\Writer', ); foreach ( $classes as $class ) { diff --git a/repo/includes/Query/SQLStore/Engine.php b/repo/includes/Query/SQLStore/Engine.php index ac0bfe9..2c59137 100644 --- a/repo/includes/Query/SQLStore/Engine.php +++ b/repo/includes/Query/SQLStore/Engine.php @@ -34,14 +34,28 @@ */ class Engine implements QueryEngine { - // TODO + /** +* @since wd.qe +* +* @var Store +*/ + private $store; - public function __construct() { - // TODO + /** +* Constructor. +* +* @since wd.qe +* +* @param Store $store +*/ + public function __construct( Store $store ) { + $this->store = $store; } /** * @see QueryEngine::runQuery +* +* @since wd.qe * * @param Query $query * @@ -51,4 +65,4 @@ // TODO } -} \ No newline at end of file +} diff --git a/repo/includes/Query/SQLStore/Writer.php b/repo/includes/Query/SQLStore/Writer.php new file mode 100644 index 000..41907be --- /dev/null +++ b/repo/includes/Query/SQLStore/Writer.php @@ -0,0 +1,53 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class Writer { + + /** +* @since wd.qe +* +* @var Store +*/ + private $store; + + /** +* Constructor. +* +* @since wd.qe +* +* @param Store $store +*/ + public function __construct( Store $store ) { + $this->store = $store; + } + + // TODO: write methods + +} diff --git a/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php b/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php index b63ec59..b2511a4 100644 --- a/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php +++ b/repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php @@ -43,7 +43,7 @@ protected function getInstances() { $instances = array(); - $instances[] = new Engine(); + $instances[] = new Engine( new \Wikibase\Repo\Query\SQLStore\Store( 'foo', array() ) ); return $instances; } -- To view, visit https://gerrit.wikimedia.org/r/52200 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibefeadd4f3e1e0c6c0413c1b6037373ef69c0541 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added NumberHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added NumberHandler .. Added NumberHandler Change-Id: I09f415b8f769f1fa17661fb311fcee041dd3e77f --- M repo/config/Wikibase.experimental.php A repo/includes/Query/SQLStore/DVHandler/NumberHandler.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/NumberHandlerTest.php 3 files changed, 227 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 2853eea..58760d6 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -64,6 +64,7 @@ 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', + 'Wikibase\Repo\Query\SQLStore\DVHandler\NumberHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\StringHandler', 'Wikibase\Repo\Query\SQLStore\DataValueHandler', @@ -143,6 +144,7 @@ 'Query/SQLStore/DVHandler/EntityIdHandler', 'Query/SQLStore/DVHandler/GeoCoordinateHandler', + 'Query/SQLStore/DVHandler/NumberHandler', 'Query/SQLStore/DVHandler/StringHandler', 'Query/SQLStore/DataValueHandler', diff --git a/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php b/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php new file mode 100644 index 000..1e9af3a --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php @@ -0,0 +1,146 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class NumberHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'value', FieldDefinition::TYPE_FLOAT, false ), + new FieldDefinition( 'json', FieldDefinition::TYPE_TEXT, false ), + ); + + return new TableDefinition( 'number', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'json'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'value'; + } + + /** +* @see DataValueHandler::newDataValueFromValueField +* +* @since wd.qe +* +* @param $valueFieldValue // TODO: mixed or string? +* +* @return DataValue +*/ + public function newDataValueFromValueField( $valueFieldValue ) { + return new NumberValue( $valueFieldValue ); + } + + /** +* @see DataValueHandler::getLabelFieldName +* +* @since wd.qe +* +* @return string|null +*/ + public function getLabelFieldName() { + return null; + } + + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof NumberValue ) ) { + throw new InvalidArgumentException( 'Value is not a NumberValue' ); + } + + return array( + 'value' => $value->getValue(), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getInsertValues( DataValue $value ) { + if ( !( $value instanceof NumberValue ) ) { + throw new InvalidArgumentException( 'Value is not a NumberValue' ); + } + + $values = array( + 'json' => $value->getArrayValue(), + 'value' => $value->getValue(), + ); + + return $values; + } + +} \ No newline at end of file diff --git a/repo/tests/phpunit/includes/Query/SQLStore/DVHandler/NumberHandlerTest.php b/repo/tests/phpunit/includes/Query/SQLSto
[MediaWiki-commits] [Gerrit] Implemented getLabelFieldName in the DVHandlers - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Implemented getLabelFieldName in the DVHandlers .. Implemented getLabelFieldName in the DVHandlers Change-Id: I40e3d225923baa9fe7f1235318f671f87e56883b --- M repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php M repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php M repo/includes/Query/SQLStore/DVHandler/NumberHandler.php M repo/includes/Query/SQLStore/DVHandler/StringHandler.php 4 files changed, 2 insertions(+), 24 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php b/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php index a275ef3..8381802 100644 --- a/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php +++ b/repo/includes/Query/SQLStore/DVHandler/EntityIdHandler.php @@ -91,17 +91,6 @@ } /** -* @see DataValueHandler::getLabelFieldName -* -* @since wd.qe -* -* @return string|null -*/ - public function getLabelFieldName() { - return null; - } - - /** * @see DataValueHandler::getWhereConditions * * @since wd.qe diff --git a/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php b/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php index 5b6c7ca..99fa5c1 100644 --- a/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php +++ b/repo/includes/Query/SQLStore/DVHandler/GeoCoordinateHandler.php @@ -93,17 +93,6 @@ } /** -* @see DataValueHandler::getLabelFieldName -* -* @since wd.qe -* -* @return string|null -*/ - public function getLabelFieldName() { - return null; - } - - /** * @see DataValueHandler::getWhereConditions * * @since wd.qe diff --git a/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php b/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php index 1e9af3a..781c548 100644 --- a/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php +++ b/repo/includes/Query/SQLStore/DVHandler/NumberHandler.php @@ -97,7 +97,7 @@ * @return string|null */ public function getLabelFieldName() { - return null; + return 'value'; } /** diff --git a/repo/includes/Query/SQLStore/DVHandler/StringHandler.php b/repo/includes/Query/SQLStore/DVHandler/StringHandler.php index 7965876..db45228 100644 --- a/repo/includes/Query/SQLStore/DVHandler/StringHandler.php +++ b/repo/includes/Query/SQLStore/DVHandler/StringHandler.php @@ -96,7 +96,7 @@ * @return string|null */ public function getLabelFieldName() { - return null; + return 'value'; } /** -- To view, visit https://gerrit.wikimedia.org/r/52208 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I40e3d225923baa9fe7f1235318f671f87e56883b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added BooleanHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added BooleanHandler .. Added BooleanHandler Change-Id: I682e73db0954df2393d07814f89440b6096af9df --- M repo/config/Wikibase.experimental.php A repo/includes/Query/SQLStore/DVHandler/BooleanHandler.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/BooleanHandlerTest.php 3 files changed, 208 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 58760d6..32dc947 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -62,6 +62,7 @@ 'Wikibase\Repo\Query\QueryResult', 'Wikibase\Repo\Query\QueryStore', + 'Wikibase\Repo\Query\SQLStore\DVHandler\BooleanHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\NumberHandler', @@ -142,6 +143,7 @@ 'Query/QueryEngineResult', + 'Query/SQLStore/DVHandler/BooleanHandler', 'Query/SQLStore/DVHandler/EntityIdHandler', 'Query/SQLStore/DVHandler/GeoCoordinateHandler', 'Query/SQLStore/DVHandler/NumberHandler', diff --git a/repo/includes/Query/SQLStore/DVHandler/BooleanHandler.php b/repo/includes/Query/SQLStore/DVHandler/BooleanHandler.php new file mode 100644 index 000..e073cb8 --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/BooleanHandler.php @@ -0,0 +1,133 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class BooleanHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'value', FieldDefinition::TYPE_BOOLEAN, false ), + ); + + return new TableDefinition( 'boolean', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'value'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'value'; + } + + /** +* @see DataValueHandler::newDataValueFromValueField +* +* @since wd.qe +* +* @param $valueFieldValue // TODO: mixed or string? +* +* @return DataValue +*/ + public function newDataValueFromValueField( $valueFieldValue ) { + return new BooleanValue( $valueFieldValue ); + } + + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof BooleanValue ) ) { + throw new InvalidArgumentException( 'Value is not a BooleanValue' ); + } + + return array( + 'value' => $value->getValue(), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getInsertValues( DataValue $value ) { + if ( !( $value instanceof BooleanValue ) ) { + throw new InvalidArgumentException( 'Value is not a BooleanValue' ); + } + + $values = array( + 'value' => $value->getValue(), + ); + + return $values; + } + +} \ No newline at end of file diff --git a/repo/tests/phpunit/includes/Query/SQLStore/DVHandler/BooleanHandlerTest.php b/repo/tests/phpunit/includes/Query/SQLStore/DVHandler/BooleanHandlerTest.php new file mode 100644 index 000..7eaf4d9 --- /dev/null +++ b/repo/tests/phpunit/includes/Query/SQLStore/DVHandler/BooleanHandlerTest.php @@ -0,0 +1,73 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since wd.qe + * + * @ingroup WikibaseRepoTest + * + * @group Wikibase + * @group WikibaseRepo + * @group WikibaseQuery + * +
[MediaWiki-commits] [Gerrit] (Bug 41631) Removed Status objects as dieUsage throws except... - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52238 Change subject: (Bug 41631) Removed Status objects as dieUsage throws exceptions .. (Bug 41631) Removed Status objects as dieUsage throws exceptions Change-Id: I007738464438ca12edc3bec8301d903dbaa869a4 --- M repo/includes/api/EditEntity.php 1 file changed, 5 insertions(+), 25 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/38/52238/1 diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php index 8b14299..f0fccaa 100644 --- a/repo/includes/api/EditEntity.php +++ b/repo/includes/api/EditEntity.php @@ -118,7 +118,7 @@ */ protected function modifyEntity( EntityContent &$entityContent, array $params ) { wfProfileIn( __METHOD__ ); - $status = Status::newGood(); + if ( isset( $params['data'] ) ) { $data = json_decode( $params['data'], true ); if ( is_null( $data ) ) { @@ -193,18 +193,13 @@ } foreach ( $list as $langCode => $arg ) { - $status->merge( $this->checkMultilangArgs( $arg, $langCode, $languages ) ); + $this->checkMultilangArgs( $arg, $langCode, $languages ); if ( array_key_exists( 'remove', $arg ) || $arg['value'] === "" ) { $entityContent->getEntity()->removeLabel( $arg['language'] ); } else { $entityContent->getEntity()->setLabel( $arg['language'], Utils::trimToNFC( $arg['value'] ) ); } - } - - if ( !$status->isOk() ) { - wfProfileOut( __METHOD__ ); - $this->dieUsage( "Contained status: $1", $status->getWikiText() ); } break; @@ -216,18 +211,13 @@ } foreach ( $list as $langCode => $arg ) { - $status->merge( $this->checkMultilangArgs( $arg, $langCode, $languages ) ); + $this->checkMultilangArgs( $arg, $langCode, $languages ); if ( array_key_exists( 'remove', $arg ) || $arg['value'] === "" ) { $entityContent->getEntity()->removeDescription( $arg['language'] ); } else { $entityContent->getEntity()->setDescription( $arg['language'], Utils::trimToNFC( $arg['value'] ) ); } - } - - if ( !$status->isOk() ) { - wfProfileOut( __METHOD__ ); - $this->dieUsage( "Contained status: $1", $status->getWikiText() ); } break; @@ -254,7 +244,7 @@ foreach ( $aliases as $langCode => $args ) { foreach ( $args as $arg ) { - $status->merge( $this->checkMultilangArgs( $arg, $langCode, $languages ) ); + $this->checkMultilangArgs( $arg, $langCode, $languages ); if ( array_key_exists( 'remove', $arg ) ) { $remAliases[$arg['language']][] = Utils::trimToNFC( $arg['value'] ); } @@ -274,11 +264,6 @@ } foreach ( $addAliases as $langCode => $strings ) { $entityContent->getEntity()->addAliases( $langCode, $strings ); - } - - if ( !$status->isOk() ) { - wfProfileOut( __METHOD__ ); -
[MediaWiki-commits] [Gerrit] (Bug 45761) API module wbremoveclaims fail to use baserevid - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52346 Change subject: (Bug 45761) API module wbremoveclaims fail to use baserevid .. (Bug 45761) API module wbremoveclaims fail to use baserevid Base revision id is not pulled in from the params during loading of the content, and due to this the diffs and later patches will be wrong. Change-Id: I77a378b006a6e780b956771d3e16ad6860d1ab49 --- M repo/includes/api/RemoveClaims.php 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/46/52346/1 diff --git a/repo/includes/api/RemoveClaims.php b/repo/includes/api/RemoveClaims.php index 3f33420..cd96931 100644 --- a/repo/includes/api/RemoveClaims.php +++ b/repo/includes/api/RemoveClaims.php @@ -131,6 +131,7 @@ * @return EntityContent[] */ protected function getEntityContents( array $ids ) { + $params = $this->extractRequestParams(); $contents = array(); $baseRevisionId = isset( $params['baserevid'] ) ? intval( $params['baserevid'] ) : null; -- To view, visit https://gerrit.wikimedia.org/r/52346 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I77a378b006a6e780b956771d3e16ad6860d1ab49 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Figured out layout of the QueryStore interface - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Figured out layout of the QueryStore interface .. Figured out layout of the QueryStore interface Change-Id: I97f4c4bfeac1f26e62a8d4cba3f7224179564342 --- M repo/config/Wikibase.experimental.php M repo/includes/Query/QueryStore.php C repo/includes/Query/QueryStoreUpdater.php M repo/includes/Query/SQLStore/Engine.php M repo/includes/Query/SQLStore/Setup.php M repo/includes/Query/SQLStore/Store.php A repo/includes/Query/SQLStore/StoreConfig.php R repo/includes/Query/SQLStore/Updater.php C repo/tests/phpunit/includes/Query/QueryStoreUpdaterTest.php M repo/tests/phpunit/includes/Query/SQLStore/EngineTest.php M repo/tests/phpunit/includes/Query/SQLStore/SetupTest.php A repo/tests/phpunit/includes/Query/SQLStore/StoreConfigTest.php M repo/tests/phpunit/includes/Query/SQLStore/StoreTest.php A repo/tests/phpunit/includes/Query/SQLStore/UpdaterTest.php 14 files changed, 488 insertions(+), 86 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 32dc947..ea3015b 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -61,6 +61,7 @@ 'Wikibase\Repo\Query\QueryEngineResult', 'Wikibase\Repo\Query\QueryResult', 'Wikibase\Repo\Query\QueryStore', + 'Wikibase\Repo\Query\QueryStoreUpdater', 'Wikibase\Repo\Query\SQLStore\DVHandler\BooleanHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', @@ -72,7 +73,8 @@ 'Wikibase\Repo\Query\SQLStore\Engine', 'Wikibase\Repo\Query\SQLStore\Setup', 'Wikibase\Repo\Query\SQLStore\Store', - 'Wikibase\Repo\Query\SQLStore\Writer', + 'Wikibase\Repo\Query\SQLStore\StoreConfig', + 'Wikibase\Repo\Query\SQLStore\Updater', ); foreach ( $classes as $class ) { @@ -97,6 +99,9 @@ $wgAutoloadClasses['Wikibase\Repo\Test\Query\QueryStoreTest'] = $dir . 'tests/phpunit/includes/Query/QueryStoreTest.php'; + + $wgAutoloadClasses['Wikibase\Repo\Test\Query\QueryStoreUpdaterTest'] + = $dir . 'tests/phpunit/includes/Query/QueryStoreUpdaterTest.php'; $wgAutoloadClasses['Wikibase\Repo\Test\Database\MWDB\ExtendedAbstractionTest'] = $dir . 'tests/phpunit/includes/Database/MWDB/ExtendedAbstractionTest.php'; @@ -153,6 +158,8 @@ 'Query/SQLStore/Engine', 'Query/SQLStore/Setup', 'Query/SQLStore/Store', + 'Query/SQLStore/StoreConfig', + 'Query/SQLStore/Updater', 'specials/SpecialEntityData', diff --git a/repo/includes/Query/QueryStore.php b/repo/includes/Query/QueryStore.php index 7bfe7df..bc3342c 100644 --- a/repo/includes/Query/QueryStore.php +++ b/repo/includes/Query/QueryStore.php @@ -2,13 +2,14 @@ namespace Wikibase\Repo\Query; +use MessageReporter; + /** - * Interface for objects that can act as query store. + * Interface for query stores providing access to all needed sub components + * such as updaters, query engines and setup/teardown operations. * - * A query store is a storage interface that indexes information in such - * a way that a query engine can compute query results against it. - * - * TODO: clearly define responsibilities + * This interface somewhat acts as facade to the query component. + * All access to a specific store should typically happen via this interface. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,13 +36,62 @@ */ interface QueryStore { - // TODO + // TODO: create store factory and figure out how to inject dependencies + // for the typical Wikibase repo use case. /** +* Returns the name of the query store. This name can be configuration dependent +* and is thus not always the same for a certain store type. For instance, you can +* have "Wikibase SQL store" and "Wikibase SQL store for update to new config". +* * @since 0.4 * * @return string */ public function getName(); -} \ No newline at end of file + /** +* Returns the query engine for this store. +* The query engine allows running queries against the store. +* +* @since wd.qe +* +* @return QueryEngine +*/ + public function getQueryEngine(); + + /** +* Returns the updater for this store. +* The updater allows for updating the data in the store. +* +* @since wd.qe +* +* @return QueryStoreUpdater +*/ + public function getUpdater(); + + /** +* Sets up the store. +* This mea
[MediaWiki-commits] [Gerrit] Create tables from SQL store setup - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Create tables from SQL store setup .. Create tables from SQL store setup Change-Id: I894011ac284a28505065dd55a4ebdd3b849ce550 --- M repo/includes/Database/TableBuilder.php M repo/includes/Database/TableDefinition.php M repo/includes/Query/SQLStore/Setup.php M repo/includes/Query/SQLStore/Store.php M repo/includes/Query/SQLStore/StoreConfig.php M repo/tests/phpunit/includes/Database/TableDefinitionTest.php M repo/tests/phpunit/includes/Query/SQLStore/SetupTest.php M repo/tests/phpunit/includes/Query/SQLStore/StoreConfigTest.php 8 files changed, 156 insertions(+), 22 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/TableBuilder.php b/repo/includes/Database/TableBuilder.php index 490d7e9..4011509 100644 --- a/repo/includes/Database/TableBuilder.php +++ b/repo/includes/Database/TableBuilder.php @@ -76,13 +76,18 @@ * @since wd.db * * @param TableDefinition $table +* +* @return boolean Success indicator */ public function createTable( TableDefinition $table ) { if ( $this->db->tableExists( $table->getName() ) ) { $this->report( 'Table "' . $table->getName() . '" exists already, skipping.' ); + return true; } - // TODO + $this->report( 'Table "' . $table->getName() . '" not found, creating.' ); + + return $this->db->createTable( $table ); } } \ No newline at end of file diff --git a/repo/includes/Database/TableDefinition.php b/repo/includes/Database/TableDefinition.php index c333869..a280d27 100644 --- a/repo/includes/Database/TableDefinition.php +++ b/repo/includes/Database/TableDefinition.php @@ -115,6 +115,19 @@ return array_key_exists( $fieldName, $this->fields ); } + /** +* Returns a clone of the table, though with the provided name instead. +* +* @since wd.db +* +* @param string $cloneName +* +* @return TableDefinition +*/ + public function getClone( $cloneName ) { + return new self( $cloneName, $this->fields ); + } + // TODO: multiple field indices -} \ No newline at end of file +} diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 9eaf2ca..3a2a670 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -3,6 +3,8 @@ namespace Wikibase\Repo\Query\SQLStore; use Wikibase\Repo\Database\TableBuilder; +use Wikibase\Repo\Database\QueryInterface; +use Wikibase\Repo\Database\TableDefinition; use MessageReporter; /** @@ -34,11 +36,22 @@ class Setup { /** +* @since wd.qe +* * @var StoreConfig */ private $config; /** +* @since wd.qe +* +* @var QueryInterface +*/ + private $queryInterface; + + /** +* @since wd.qe +* * @var TableBuilder */ private $tableBuilder; @@ -54,12 +67,16 @@ * @since wd.qe * * @param StoreConfig $storeConfig +* @param QueryInterface $queryInterface * @param TableBuilder $tableBuilder * @param MessageReporter|null $messageReporter */ - public function __construct( StoreConfig $storeConfig, TableBuilder $tableBuilder, MessageReporter $messageReporter = null ) { + public function __construct( StoreConfig $storeConfig, QueryInterface $queryInterface, +TableBuilder $tableBuilder, MessageReporter $messageReporter = null ) { $this->config = $storeConfig; $this->tableBuilder = $tableBuilder; + $this->queryInterface = $queryInterface; + $this->messageReporter = $messageReporter; } /** @@ -74,36 +91,103 @@ } /** -* Run the setup. +* Install the store. * * @since wd.qe +* +* @return boolean Success indicator */ - public function run() { - $this->report( 'Starting setup of ' . $this->config->getStoreName() ); + public function install() { + $this->report( 'Starting install of ' . $this->config->getStoreName() ); - $this->setupTables(); + $success = $this->setupTables(); // TODO: initialize basic content - $this->report( 'Finished setup of ' . $this->config->getStoreName() ); + $this->report( 'Finished install of ' . $this->config->getStoreName() ); + + return $success; + } + + /** +
[MediaWiki-commits] [Gerrit] Added stubs to QueryStoreUpdater - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added stubs to QueryStoreUpdater .. Added stubs to QueryStoreUpdater Change-Id: I446cbea75417a6834a600ff0adbec31d38b931a8 --- M repo/includes/Query/QueryStoreUpdater.php M repo/includes/Query/SQLStore/Updater.php M repo/tests/phpunit/includes/Query/QueryStoreUpdaterTest.php 3 files changed, 73 insertions(+), 2 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/Query/QueryStoreUpdater.php b/repo/includes/Query/QueryStoreUpdater.php index 533f551..33713d8 100644 --- a/repo/includes/Query/QueryStoreUpdater.php +++ b/repo/includes/Query/QueryStoreUpdater.php @@ -2,6 +2,8 @@ namespace Wikibase\Repo\Query; +use Wikibase\Entity; + /** * Updater for a query store. * Implementing objects provide an interface via which new data can be inserted @@ -32,6 +34,31 @@ */ interface QueryStoreUpdater { - // TODO + /** +* @see QueryStoreUpdater::insertEntity +* +* @since wd.qe +* +* @param Entity $entity +*/ + public function insertEntity( Entity $entity ); + + /** +* @see QueryStoreUpdater::updateEntity +* +* @since wd.qe +* +* @param Entity $entity +*/ + public function updateEntity( Entity $entity ); + + /** +* @see QueryStoreUpdater::deleteEntity +* +* @since wd.qe +* +* @param Entity $entity +*/ + public function deleteEntity( Entity $entity ); } diff --git a/repo/includes/Query/SQLStore/Updater.php b/repo/includes/Query/SQLStore/Updater.php index 06a03d2..15aae88 100644 --- a/repo/includes/Query/SQLStore/Updater.php +++ b/repo/includes/Query/SQLStore/Updater.php @@ -4,6 +4,7 @@ use Wikibase\Repo\Query\QueryStoreUpdater; use Wikibase\Repo\Database\QueryInterface; +use Wikibase\Entity; /** * Class responsible for writing information to the SQLStore. @@ -60,6 +61,39 @@ $this->queryInterface = $queryInterface; } + /** +* @see QueryStoreUpdater::insertEntity +* +* @since wd.qe +* +* @param Entity $entity +*/ + public function insertEntity( Entity $entity ) { + // TODO + } + + /** +* @see QueryStoreUpdater::updateEntity +* +* @since wd.qe +* +* @param Entity $entity +*/ + public function updateEntity( Entity $entity ) { + // TODO + } + + /** +* @see QueryStoreUpdater::deleteEntity +* +* @since wd.qe +* +* @param Entity $entity +*/ + public function deleteEntity( Entity $entity ) { + // TODO + } + // TODO: write methods } diff --git a/repo/tests/phpunit/includes/Query/QueryStoreUpdaterTest.php b/repo/tests/phpunit/includes/Query/QueryStoreUpdaterTest.php index 7eb8675..4db385e 100644 --- a/repo/tests/phpunit/includes/Query/QueryStoreUpdaterTest.php +++ b/repo/tests/phpunit/includes/Query/QueryStoreUpdaterTest.php @@ -48,7 +48,17 @@ return $this->arrayWrap( $this->getInstances() ); } - public function testFoo() { + public function testInsertEntity() { + // TODO + $this->assertTrue( true ); + } + + public function testUpdateEntity() { + // TODO + $this->assertTrue( true ); + } + + public function testDeleteEntity() { // TODO $this->assertTrue( true ); } -- To view, visit https://gerrit.wikimedia.org/r/52362 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I446cbea75417a6834a600ff0adbec31d38b931a8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Jens Ohlig Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Return correct value for getName in the SQL Store - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Return correct value for getName in the SQL Store .. Return correct value for getName in the SQL Store Change-Id: Id04c723c1db73dfd1a9c58bf59f247ded566e3e7 --- M repo/includes/Query/SQLStore/Store.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Query/SQLStore/Store.php b/repo/includes/Query/SQLStore/Store.php index af6fbaa..cec286c 100644 --- a/repo/includes/Query/SQLStore/Store.php +++ b/repo/includes/Query/SQLStore/Store.php @@ -88,7 +88,7 @@ * @return string */ public function getName() { - return 'Wikibase SQL store'; + return $this->config->getStoreName(); } /** -- To view, visit https://gerrit.wikimedia.org/r/52363 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id04c723c1db73dfd1a9c58bf59f247ded566e3e7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Jens Ohlig Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added preliminary definition of two non DV tables of the SQL... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added preliminary definition of two non DV tables of the SQL Store .. Added preliminary definition of two non DV tables of the SQL Store Change-Id: I18153d98625a42a32a1c64a9a4c8a4ac1734d4c5 --- M repo/includes/Database/FieldDefinition.php M repo/includes/Query/SQLStore/Setup.php 2 files changed, 132 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/FieldDefinition.php b/repo/includes/Database/FieldDefinition.php index d280e5c..2462155 100644 --- a/repo/includes/Database/FieldDefinition.php +++ b/repo/includes/Database/FieldDefinition.php @@ -86,8 +86,23 @@ const TYPE_INTEGER = 'int'; const TYPE_FLOAT = 'float'; + const NOT_NULL = false; + const NULL = true; + + const NO_DEFAULT = null; + + const NO_ATTRIB = null; const ATTRIB_BINARY = 'binary'; const ATTRIB_UNSIGNED = 'unsigned'; + + const NO_INDEX = null; + const INDEX = 'index'; + const INDEX_UNIQUE = 'unique'; + const INDEX_FULLTEXT = 'fulltext'; + const INDEX_PRIMARY = 'primary'; + + const AUTOINCREMENT = true; + const NO_AUTOINCREMENT = false; /** @@ -101,7 +116,7 @@ * * @throws InvalidArgumentException */ - public function __construct( $name, $type, $null = true, $default = null, $attributes = null, $index = null, $autoIncrement = false ) { + public function __construct( $name, $type, $null = self::NULL, $default = self::NO_DEFAULT, $attributes = null, $index = null, $autoIncrement = false ) { if ( !is_string( $name ) ) { throw new InvalidArgumentException( 'The field $name needs to be a string' ); } diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 3a2a670..0d82f63 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -5,6 +5,7 @@ use Wikibase\Repo\Database\TableBuilder; use Wikibase\Repo\Database\QueryInterface; use Wikibase\Repo\Database\TableDefinition; +use Wikibase\Repo\Database\FieldDefinition; use MessageReporter; /** @@ -131,6 +132,121 @@ } /** +* TODO +* +* @return TableDefinition[] +*/ + private function getNonDVTables() { + $tables = array(); + + // Id map with Wikibase EntityId to internal SQL store id + $tables[] = new TableDefinition( + 'entities', + array( + // Internal id + new FieldDefinition( + 'id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX_PRIMARY, + FieldDefinition::AUTOINCREMENT + ), + + // EntityId type part + new FieldDefinition( + 'type', + FieldDefinition::TYPE_TEXT, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::NO_ATTRIB, + FieldDefinition::INDEX + ), + + // EntityId numerical part + new FieldDefinition( + 'number', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + ) + ); + + // Claim id table + $tables[] = new TableDefinition( + 'claims', + array( + // Internal id + new FieldDefinition( + 'id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, +
[MediaWiki-commits] [Gerrit] Added docs to FieldDefinition - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added docs to FieldDefinition .. Added docs to FieldDefinition Change-Id: I994141647b3c6a84d0dbf8faafc9e8837f097a51 --- M repo/includes/Database/FieldDefinition.php 1 file changed, 58 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/Database/FieldDefinition.php b/repo/includes/Database/FieldDefinition.php index 2462155..c8d46e6 100644 --- a/repo/includes/Database/FieldDefinition.php +++ b/repo/includes/Database/FieldDefinition.php @@ -106,6 +106,10 @@ /** +* Constructor. +* +* @since wd.db +* * @param string $name * @param string $type * @param boolean $null @@ -146,32 +150,85 @@ $this->autoIncrement = $autoIncrement; } + /** +* Returns the name of the field. +* +* @since wd.db +* +* @return string +*/ public function getName() { return $this->name; } + /** +* Returns the type of the field. +* This is one of the TYPE_ constants. +* +* @since wd.db +* +* @return string +*/ public function getType() { return $this->type; } + /** +* Returns the default value of the field. +* Null for no default value. +* +* @since wd.db +* +* @return mixed +*/ public function getDefault() { return $this->default; } + /** +* Returns the attributes of the field. +* This is one of the ATTRIB_ constants or null. +* +* @since wd.db +* +* @return string|null +*/ public function getAttributes() { return $this->attributes; } + /** +* Returns if the field allows for the value to be null. +* +* @since wd.db +* +* @return boolean +*/ public function allowsNull() { return $this->null; } + /** +* Returns the index type of the field. +* This is one of the INDEX_ constants or null. +* +* @since wd.db +* +* @return string|null +*/ public function getIndex() { return $this->index; } + /** +* Returns if the field has auto increment. +* +* @since wd.db +* +* @return boolean +*/ public function hasAutoIncrement() { return $this->autoIncrement; } -} \ No newline at end of file +} -- To view, visit https://gerrit.wikimedia.org/r/52365 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I994141647b3c6a84d0dbf8faafc9e8837f097a51 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Aude Gerrit-Reviewer: Jens Ohlig Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added FieldDefinition::mutateFields - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added FieldDefinition::mutateFields .. Added FieldDefinition::mutateFields Change-Id: I81ab9fbea643403c173094985ba5fcf977af1181 --- M repo/includes/Database/TableDefinition.php M repo/includes/Query/SQLStore/Setup.php M repo/tests/phpunit/includes/Database/TableDefinitionTest.php 3 files changed, 45 insertions(+), 5 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/TableDefinition.php b/repo/includes/Database/TableDefinition.php index a280d27..00df142 100644 --- a/repo/includes/Database/TableDefinition.php +++ b/repo/includes/Database/TableDefinition.php @@ -70,6 +70,10 @@ $this->fields = array(); foreach ( $fields as $field ) { + if ( !( $field instanceof FieldDefinition ) ) { + throw new InvalidArgumentException( 'All table fields should be of type FieldDefinition' ); + } + if ( array_key_exists( $field->getName(), $this->fields ) ) { throw new InvalidArgumentException( 'A table cannot have two fields with the same name' ); } @@ -124,10 +128,23 @@ * * @return TableDefinition */ - public function getClone( $cloneName ) { + public function mutateName( $cloneName ) { return new self( $cloneName, $this->fields ); } + /** +* Returns a clone of the table, though with the provided fields rather then the original ones. +* +* @since wd.db +* +* @param FieldDefinition[] $fields +* +* @return TableDefinition +*/ + public function mutateFields( array $fields ) { + return new self( $this->name, $fields ); + } + // TODO: multiple field indices } diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 0d82f63..0224934 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -123,7 +123,7 @@ */ foreach ( $this->config->getDataValueHandlers() as $dataValueHandler ) { $table = $dataValueHandler->getTableDefinition(); - $table = $table->getClone( $this->config->getTablePrefix() . $table->getName() ); + $table = $table->mutateName( $this->config->getTablePrefix() . $table->getName() ); $dvTables[] = $table; } diff --git a/repo/tests/phpunit/includes/Database/TableDefinitionTest.php b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php index 28f2bf1..6c229da 100644 --- a/repo/tests/phpunit/includes/Database/TableDefinitionTest.php +++ b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php @@ -121,16 +121,39 @@ * * @param TableDefinition $table */ - public function testGetClone( TableDefinition $table ) { - $newTable = $table->getClone( $table->getName() ); + public function testMutateName( TableDefinition $table ) { + $newTable = $table->mutateName( $table->getName() ); $this->assertInstanceOf( get_class( $table ), $newTable ); $this->assertEquals( $table, $newTable ); - $newTable = $table->getClone( 'foobarbaz' ); + $newTable = $table->mutateName( 'foobarbaz' ); $this->assertEquals( 'foobarbaz', $newTable->getName() ); $this->assertEquals( $table->getFields(), $newTable->getFields() ); } + /** +* @dataProvider instanceProvider +* +* @param TableDefinition $table +*/ + public function testMutateFields( TableDefinition $table ) { + $newTable = $table->mutateFields( $table->getFields() ); + + $this->assertInstanceOf( get_class( $table ), $newTable ); + $this->assertEquals( $table, $newTable ); + + $fields = array( + new FieldDefinition( 'h', FieldDefinition::TYPE_TEXT ), + new FieldDefinition( 'a', FieldDefinition::TYPE_BOOLEAN ), + new FieldDefinition( 'x', FieldDefinition::TYPE_INTEGER ), + ); + + $newTable = $table->mutateFields( $fields ); + + $this->assertEquals( $fields, array_values( $newTable->getFields() ) ); + $this->assertEquals( $table->getName(), $newTable->getName() ); + } + } -- To view, visit https://gerrit.wikimedia.org/r/52366 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I81ab9fbea643403c173094985ba5fcf977af1181 Gerrit-Patch
[MediaWiki-commits] [Gerrit] Work on SQLStore setup - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Work on SQLStore setup .. Work on SQLStore setup Change-Id: I9d6b5e39a07f74450deacfb8522be3c0ed56c7b5 --- M repo/includes/Query/SQLStore/Setup.php M repo/includes/Query/SQLStore/StoreConfig.php M repo/tests/phpunit/includes/Query/SQLStore/SetupTest.php 3 files changed, 93 insertions(+), 45 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 0224934..58d1a44 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -115,6 +115,19 @@ * * @return TableDefinition[] */ + private function getTables() { + // TODO: setup dv tables for different levels of snaks + // TODO: setup id tracking tables + // TODO: setup stats tables + + return array_merge( $this->getNonDVTables(), $this->getDVTables() ); + } + + /** +* TODO +* +* @return TableDefinition[] +*/ private function getDVTables() { $dvTables = array(); @@ -122,10 +135,39 @@ * @var DataValueHandler $dataValueHandler */ foreach ( $this->config->getDataValueHandlers() as $dataValueHandler ) { - $table = $dataValueHandler->getTableDefinition(); - $table = $table->mutateName( $this->config->getTablePrefix() . $table->getName() ); + foreach ( array( 'msnak_', 'qualifier_' ) as $snakLevel ) { + $table = $dataValueHandler->getTableDefinition(); + $table = $table->mutateName( $snakLevel . $table->getName() ); - $dvTables[] = $table; + $table = $table->mutateFields( + array_merge( + array( + // Internal claim id + new FieldDefinition( + 'claim_id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Internal property id + new FieldDefinition( + 'property_id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + ), + $table->getFields() + ) + ); + + $dvTables[] = $table; + } } return $dvTables; @@ -138,6 +180,9 @@ */ private function getNonDVTables() { $tables = array(); + + // TODO: multi field indexes + // TODO: more optimal types // Id map with Wikibase EntityId to internal SQL store id $tables[] = new TableDefinition( @@ -247,6 +292,19 @@ } /** +* Returns the provided table with the configs table prefix prepended to the name of the table. +* +* @since wd.qe +* +* @param TableDefinition $tableDefinition +* +* @return TableDefinition +*/ + private function getPrefixedTable( TableDefinition $tableDefinition ) { + return $tableDefinition->mutateName( $this->config->getTablePrefix() . $tableDefinition->getName() ); + } + + /** * Sets up the tables of the store. * * @since wd.qe @@ -256,13 +314,10 @@ private function setupTables(
[MediaWiki-commits] [Gerrit] Added MonolingualTextHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added MonolingualTextHandler .. Added MonolingualTextHandler Change-Id: Iba9aeb9904d75786d01bbe61b76ed77443188e1b --- M repo/config/Wikibase.experimental.php A repo/includes/Query/SQLStore/DVHandler/MonolingualTextHandler.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/MonolingualTextHandlerTest.php 3 files changed, 231 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index ea3015b..1ea0f32 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -66,6 +66,7 @@ 'Wikibase\Repo\Query\SQLStore\DVHandler\BooleanHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', + 'Wikibase\Repo\Query\SQLStore\DVHandler\MonolingualTextHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\NumberHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\StringHandler', @@ -151,6 +152,7 @@ 'Query/SQLStore/DVHandler/BooleanHandler', 'Query/SQLStore/DVHandler/EntityIdHandler', 'Query/SQLStore/DVHandler/GeoCoordinateHandler', + 'Query/SQLStore/DVHandler/MonolingualTextHandler', 'Query/SQLStore/DVHandler/NumberHandler', 'Query/SQLStore/DVHandler/StringHandler', diff --git a/repo/includes/Query/SQLStore/DVHandler/MonolingualTextHandler.php b/repo/includes/Query/SQLStore/DVHandler/MonolingualTextHandler.php new file mode 100644 index 000..af658d8 --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/MonolingualTextHandler.php @@ -0,0 +1,153 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class MonolingualTextHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'text', FieldDefinition::TYPE_TEXT, false ), + new FieldDefinition( 'language', FieldDefinition::TYPE_TEXT, false ), + new FieldDefinition( 'json', FieldDefinition::TYPE_TEXT, false ), + ); + + return new TableDefinition( 'mono_text', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'json'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'text'; + } + + /** +* @see DataValueHandler::getLabelFieldName +* +* @since wd.qe +* +* @return string|null +*/ + public function getLabelFieldName() { + return 'text'; + } + + /** +* @see DataValueHandler::newDataValueFromValueField +* +* @since wd.qe +* +* @param $valueFieldValue // TODO: mixed or string? +* +* @return DataValue +*/ + public function newDataValueFromValueField( $valueFieldValue ) { + return MonolingualTextValue::newFromArray( json_decode( $valueFieldValue, true ) ); + } + + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof MonolingualTextValue ) ) { + throw new InvalidArgumentException( 'Value is not a MonolingualTextValue' ); + } + + return array( + // Note: the code in this package is not dependent on MW. + // So do not replace this with FormatJSON::encode. + 'json' => json_encode( $value->getArrayValue() ), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getInsertValues( DataValue $value ) { +
[MediaWiki-commits] [Gerrit] Added IriHandler - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added IriHandler .. Added IriHandler Change-Id: Ic0eaf9d2e6b8e1996209bae5ec91e7061f0bc3bb --- M repo/config/Wikibase.experimental.php A repo/includes/Query/SQLStore/DVHandler/IriHandler.php A repo/tests/phpunit/includes/Query/SQLStore/DVHandler/IriHandlerTest.php 3 files changed, 241 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 1ea0f32..dac9a88 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -66,6 +66,7 @@ 'Wikibase\Repo\Query\SQLStore\DVHandler\BooleanHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\EntityIdHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\GeoCoordinateHandler', + 'Wikibase\Repo\Query\SQLStore\DVHandler\IriHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\MonolingualTextHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\NumberHandler', 'Wikibase\Repo\Query\SQLStore\DVHandler\StringHandler', @@ -152,6 +153,7 @@ 'Query/SQLStore/DVHandler/BooleanHandler', 'Query/SQLStore/DVHandler/EntityIdHandler', 'Query/SQLStore/DVHandler/GeoCoordinateHandler', + 'Query/SQLStore/DVHandler/IriHandler', 'Query/SQLStore/DVHandler/MonolingualTextHandler', 'Query/SQLStore/DVHandler/NumberHandler', 'Query/SQLStore/DVHandler/StringHandler', diff --git a/repo/includes/Query/SQLStore/DVHandler/IriHandler.php b/repo/includes/Query/SQLStore/DVHandler/IriHandler.php new file mode 100644 index 000..4dc25a5 --- /dev/null +++ b/repo/includes/Query/SQLStore/DVHandler/IriHandler.php @@ -0,0 +1,162 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since wd.qe + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class IriHandler extends DataValueHandler { + + /** +* @see DataValueHandler::getTableDefinition +* +* @since wd.qe +* +* @return TableDefinition +*/ + public function getTableDefinition() { + $fields = array( + new FieldDefinition( 'scheme', FD::TYPE_TEXT, FD::NOT_NULL ), + new FieldDefinition( 'fragment', FD::TYPE_TEXT, FD::NOT_NULL ), + new FieldDefinition( 'query', FD::TYPE_TEXT, FD::NOT_NULL ), + new FieldDefinition( 'hierp', FD::TYPE_TEXT, FD::NOT_NULL ), + + new FieldDefinition( 'iri', FD::TYPE_TEXT, FD::NOT_NULL ), + new FieldDefinition( 'json', FD::TYPE_TEXT, FD::NOT_NULL ), + ); + + return new TableDefinition( 'iri', $fields ); + } + + /** +* @see DataValueHandler::getValueFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getValueFieldName() { + return 'json'; + } + + /** +* @see DataValueHandler::getSortFieldName +* +* @since wd.qe +* +* @return string +*/ + public function getSortFieldName() { + return 'iri'; + } + + /** +* @see DataValueHandler::getLabelFieldName +* +* @since wd.qe +* +* @return string|null +*/ + public function getLabelFieldName() { + return 'iri'; + } + + /** +* @see DataValueHandler::newDataValueFromValueField +* +* @since wd.qe +* +* @param $valueFieldValue // TODO: mixed or string? +* +* @return DataValue +*/ + public function newDataValueFromValueField( $valueFieldValue ) { + return IriValue::newFromArray( json_decode( $valueFieldValue, true ) ); + } + + /** +* @see DataValueHandler::getWhereConditions +* +* @since wd.qe +* +* @param DataValue $value +* +* @return array +* @throws InvalidArgumentException +*/ + public function getWhereConditions( DataValue $value ) { + if ( !( $value instanceof IriValue ) ) { + throw new InvalidArgumentException( 'Value is not a IriValue' ); + } + + return array( + // Note: the code in this package is not dependent on MW. + // So do not replace this with FormatJSON::encode. + 'json' => json_encode( $value->getArrayValue() ), + ); + } + + /** +* @see DataValueHandler::getInsertValues +* +* @since wd.qe
[MediaWiki-commits] [Gerrit] Added table for valueless snaks - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added table for valueless snaks .. Added table for valueless snaks Change-Id: Icac0904b18bfc868a8633d388481c33ea0df752d --- M repo/includes/Query/SQLStore/Setup.php 1 file changed, 59 insertions(+), 21 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Query/SQLStore/Setup.php b/repo/includes/Query/SQLStore/Setup.php index 58d1a44..9be3f8c 100644 --- a/repo/includes/Query/SQLStore/Setup.php +++ b/repo/includes/Query/SQLStore/Setup.php @@ -141,27 +141,7 @@ $table = $table->mutateFields( array_merge( - array( - // Internal claim id - new FieldDefinition( - 'claim_id', - FieldDefinition::TYPE_INTEGER, - FieldDefinition::NOT_NULL, - FieldDefinition::NO_DEFAULT, - FieldDefinition::ATTRIB_UNSIGNED, - FieldDefinition::INDEX - ), - - // Internal property id - new FieldDefinition( - 'property_id', - FieldDefinition::TYPE_INTEGER, - FieldDefinition::NOT_NULL, - FieldDefinition::NO_DEFAULT, - FieldDefinition::ATTRIB_UNSIGNED, - FieldDefinition::INDEX - ), - ), + $this->getPropertySnakFields(), $table->getFields() ) ); @@ -171,6 +151,35 @@ } return $dvTables; + } + + /** +* TODO +* +* @return FieldDefinition[] +*/ + private function getPropertySnakFields() { + return array( + // Internal claim id + new FieldDefinition( + 'claim_id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Internal property id + new FieldDefinition( + 'property_id', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + ); } /** @@ -288,6 +297,35 @@ ) ); + // Table for snaks without a value + $tables[] = new TableDefinition( + 'valueless_snaks', + array_merge( + $this->getPropertySnakFields(), + array( + // Type of the snak + new FieldDefinition( + 'type', + FieldDefinition::TYPE_INTEGER, + FieldDefinition::NOT_NULL, + FieldDefinition::NO_DEFAULT, + FieldDefinition::ATTRIB_UNSIGNED, + FieldDefinition::INDEX + ), + + // Level at which the snak is used (ie "main snak" or "qualifier") + new FieldDe
[MediaWiki-commits] [Gerrit] Added some stub code in the SQLStore QueryEngine - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added some stub code in the SQLStore QueryEngine .. Added some stub code in the SQLStore QueryEngine Change-Id: If3b155a1bb791a374560cb5e6c347caa52cb5cf8 --- M repo/includes/Query/SQLStore/Engine.php 1 file changed, 39 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/Query/SQLStore/Engine.php b/repo/includes/Query/SQLStore/Engine.php index 3cd5b31..28e76e9 100644 --- a/repo/includes/Query/SQLStore/Engine.php +++ b/repo/includes/Query/SQLStore/Engine.php @@ -2,10 +2,14 @@ namespace Wikibase\Repo\Query\SQLStore; -use Ask\Language\Query; use Wikibase\Repo\Query\QueryEngineResult; use Wikibase\Repo\Query\QueryEngine; use Wikibase\Repo\Database\QueryInterface; + +use Ask\Language\Query; +use Ask\Language\Description\Description; +use Ask\Language\Option\QueryOptions; +use Ask\Language\Selection\SelectionRequest; /** * Simple query engine that works on top of the SQLStore. @@ -72,6 +76,40 @@ * @return QueryEngineResult */ public function runQuery( Query $query ) { + $internalEntityIds = $this->findQueryMatches( $query->getDescription(), $query->getOptions() ); + + $result = $this->selectRequestedFields( $internalEntityIds, $query->getSelectionRequests() ); + + return $result; + } + + /** +* Finds all entities that match the selection criteria. +* The matching entities are returned as an array of internal entity ids. +* +* @since wd.qe +* +* @param Description $description +* @param QueryOptions $options +* +* @return int[] +*/ + private function findQueryMatches( Description $description, QueryOptions $options ) { + // TODO + } + + /** +* Selects all the quested data from the matching entities. +* This data is put in a QueryEngineResult object which is then returned. +* +* @since wd.qe +* +* @param array $internalEntityIds +* @param array $query +* +* @return QueryEngineResult +*/ + private function selectRequestedFields( array $internalEntityIds, array $query ) { // TODO } -- To view, visit https://gerrit.wikimedia.org/r/52388 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If3b155a1bb791a374560cb5e6c347caa52cb5cf8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Copyright notice on editing will use Wikidata license text i... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Copyright notice on editing will use Wikidata license text if available .. Copyright notice on editing will use Wikidata license text if available Change-Id: Ie7dba1130202c3c1d7dd12fc50d7ee65059d99b4 --- M repo/includes/EntityView.php 1 file changed, 11 insertions(+), 5 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php index 1efb24e..d57735b 100644 --- a/repo/includes/EntityView.php +++ b/repo/includes/EntityView.php @@ -713,11 +713,17 @@ // entity specific data $out->addJsConfigVars( 'wbEntityId', $entity->getPrefixedId() ); - $rightsWarning = $this->msg( 'wikibase-shortcopyrightwarning', - $this->msg( 'wikibase-save' )->inContentLanguage()->text(), - $this->msg( 'copyrightpage' )->inContentLanguage()->text(), - "[$wgRightsUrl $wgRightsText]" - )->parse(); + if ( $this->msg( 'wikidata-shortcopyrightwarning' )->exists() ) { + // if this is a wiki using the WikimediaMessages extension (i.e. Wikidata) it will use the + // shortcopyrightwarning message from that extension instead. + $rightsWarning = $this->msg( 'wikidata-shortcopyrightwarning' )->parse(); + } else { + $rightsWarning = $this->msg( 'wikibase-shortcopyrightwarning', + $this->msg( 'wikibase-save' )->inContentLanguage()->text(), + $this->msg( 'copyrightpage' )->inContentLanguage()->text(), + "[$wgRightsUrl $wgRightsText]" + )->parse(); + } // copyright warning message $out->addJsConfigVars( 'wbCopyrightWarning', $rightsWarning ); -- To view, visit https://gerrit.wikimedia.org/r/52406 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie7dba1130202c3c1d7dd12fc50d7ee65059d99b4 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Denny Vrandecic Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove query message - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/67004 Change subject: Remove query message .. Remove query message The messge wikibase-query-summary-special-create-query is unused. Change-Id: I72f63d789ea07e72c44d4c31904c8b85ba953692 --- M repo/Wikibase.i18n.php 1 file changed, 0 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/04/67004/1 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index e30cf50..e00d83e 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -335,9 +335,6 @@ 'wikibase-property-summary-wbsetaliases-remove' => 'Removed [$2] {{PLURAL:$1|alias|aliases}}', 'wikibase-property-summary-special-create-property' => 'Created a [$2] property with {{PLURAL:$1|value|values}}', - // query - summary and autocomment - 'wikibase-query-summary-special-create-query' => 'Created a [$2] query with {{PLURAL:$1|value|values}}', - // datatype descriptions 'wikibase-listdatatypes-wikibase-item-head' => 'Item', 'wikibase-listdatatypes-wikibase-item-body' => 'Link to other items at the project. During entry the "Item" namespace on Wikidata will be searched for matching entries. It consists of a single text entry field. @@ -988,9 +985,6 @@ * $1 is the number of aliases that were removed; * $2 is the language code for the item page.', 'wikibase-property-summary-special-create-property' => 'Automatic edit summary when creating a property, and supplying one or more values. Parameters: -* $1 is the number of values set (that is 0 - zero); -* $2 is the language code of the entity page during creation.', - 'wikibase-query-summary-special-create-query' => 'Automatic edit summary when creating a query, and supplying one or more values. Parameters: * $1 is the number of values set (that is 0 - zero); * $2 is the language code of the entity page during creation.', 'wikibase-listdatatypes-wikibase-item-head' => '{{Wikibase-datatype-head|Item|wikibase-item}} -- To view, visit https://gerrit.wikimedia.org/r/67004 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I72f63d789ea07e72c44d4c31904c8b85ba953692 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Corrected string and text description - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/67011 Change subject: Corrected string and text description .. Corrected string and text description The string type had language part, which is wrong. The text used a "text" part which should be "value" Change-Id: I5a5e6c164bd070d77c87e3a24fa7f243c36cf338 --- M repo/Wikibase.i18n.php 1 file changed, 4 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/11/67011/1 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index e30cf50..e6f3bc5 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -365,15 +365,14 @@ 'wikibase-listdatatypes-monolingual-text-head' => 'Monolingual text', 'wikibase-listdatatypes-monolingual-text-body' => 'Literal data field for a string that is not translated into other languages. This type of string is defined once and reused across all languages. Typical use is a geographical names written in the local language, an identifier of some kind, a chemical formula or a Latin scientific name. * language – explicit value for identifying the language for the text part -* text – explicit value for the language specific variant string', +* value – explicit value for the language specific variant string', 'wikibase-listdatatypes-multilingual-text-head' => 'Multilingual text', 'wikibase-listdatatypes-multilingual-text-body' => 'Literal data field for a string that must be translated into other languages. Typical use is an entity name of global interest that has non-local written forms. Those can differ both in languages and script systems. * language – explicit value for identifying the language for the text part -* text – explicit value for the language specific variant string', +* value – explicit value for the language specific variant string', 'wikibase-listdatatypes-string-head' => 'String', - 'wikibase-listdatatypes-string-body' => 'Literal data field for a string of characters. Typical use is identifiers that has written forms that does not depend on the language. Such strings can in some cases be transliterated into other script systems. -* language – explicit value for identifying the language for the text part -* text – explicit value for the language specific variant string', + 'wikibase-listdatatypes-string-body' => 'Literal data field for a string of glyphs. Typical use is identifiers that has written forms that does not depend on the language of the reader. +* value – explicit value for the language specific variant string', 'wikibase-listdatatypes-time-head' => 'Time', 'wikibase-listdatatypes-time-body' => 'Literal data field for a time value. Given as a time with some precision and boundaries. The time is always saved internally in the Proleptic Gregorian format, but can use other formats during parsing and formating.(?) * time – explicit value for point in time, represented per ISO8601, the year always having 11 digits and the date always being signed, in the format +0002013-01-01T00:00:00Z -- To view, visit https://gerrit.wikimedia.org/r/67011 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5a5e6c164bd070d77c87e3a24fa7f243c36cf338 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use correct plural form - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/67024 Change subject: Use correct plural form .. Use correct plural form This is somewhat superflawous as the message itself will not be used in a singular form. That is it is not part of that code part. Note that this isn't tested as of thie upload. :) Change-Id: Id38d3308cfc0bb7bfd63f316dab3ed4824519d21 --- M client/WikibaseClient.i18n.php M client/resources/jquery.wikibase/jquery.wikibase.linkitem.js 2 files changed, 5 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/24/67024/1 diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php index 038af4e..0855fee 100644 --- a/client/WikibaseClient.i18n.php +++ b/client/WikibaseClient.i18n.php @@ -45,7 +45,7 @@ 'wikibase-linkitem-input-site' => 'Language:', 'wikibase-linkitem-input-page' => 'Page:', 'wikibase-linkitem-invalidsite' => 'Unknown or invalid site selected', - 'wikibase-linkitem-confirmitem-text' => 'The page you chose is already linked to an [$1 item on our central data repository]. Please confirm that the pages shown below are the ones you want to link with this page.', + 'wikibase-linkitem-confirmitem-text' => 'The page you chose is already associated to an [$1 item on our central data repository]. Please confirm that the {{PLURAL:$2|page|pages}} shown below are the {{PLURAL:$2|one|ones}} you want to link with this page.', 'wikibase-linkitem-confirmitem-button' => 'Confirm', 'wikibase-linkitem-not-loggedin-title' => 'You need to be logged in', 'wikibase-linkitem-not-loggedin' => 'You need to be logged in on this wiki and in the [$1 central data repository] to use this feature.', @@ -132,9 +132,11 @@ {{Identical|Page}}', 'wikibase-linkitem-invalidsite' => 'Tooltip shown if the user entered an invalid site to link pages with', 'wikibase-linkitem-confirmitem-text' => 'Text shown above a table containing links to other pages. Asks the user to confirm that the links are correct and should be linked with the current page. + The message string will only be used when there are multiple pages, still it has a count argument so it can use a correct plural parser function. Parameters: -* $1 - the URL to the item which links to the shown pages', +* $1 - the URL to the item which links to the shown pages +* $2 - the number of links to associated pages', 'wikibase-linkitem-confirmitem-button' => 'Button label below a table containing links to other pages. Asks the user to confirm that he wants to link them with the current page. {{Identical|Confirm}}', 'wikibase-linkitem-not-loggedin-title' => 'Title of the dialog telling the user that he needs to login on both the repo and client to use this feature.', diff --git a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js b/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js index 345f470..0ec5a23 100644 --- a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js +++ b/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js @@ -445,7 +445,7 @@ .empty() .append( $( '' ) - .html( mw.message( 'wikibase-linkitem-confirmitem-text', itemLink ).parse() ) + .html( mw.message( 'wikibase-linkitem-confirmitem-text', itemLink, siteLinkCount ).parse() ) ).append( $( '' ) ) -- To view, visit https://gerrit.wikimedia.org/r/67024 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id38d3308cfc0bb7bfd63f316dab3ed4824519d21 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Correct message so it is using plural parser function - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/67025 Change subject: Correct message so it is using plural parser function .. Correct message so it is using plural parser function Change-Id: I02c6787ca7f5dcc6a3ddcb5865d8632b8cba7156 --- M client/WikibaseClient.i18n.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/25/67025/1 diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php index 038af4e..6771984 100644 --- a/client/WikibaseClient.i18n.php +++ b/client/WikibaseClient.i18n.php @@ -64,7 +64,7 @@ 'wikibase-unconnectedpages-invalid-language' => '"$1" is not a valid language code.', 'wikibase-unconnectedpages-page-warning' => 'The page title could not be used for the query and is ignored.', 'wikibase-unconnectedpages-iwdata-label' => 'Only pages with interlanguagelinks', - 'wikibase-unconnectedpages-format-row' => '($1 interlanguagelinks on the page)', + 'wikibase-unconnectedpages-format-row' => '($1 {{PLURAL:$1|interlanguagelink|interlanguagelinks}} on the page)', 'wikibase-pageinfo-entity-id' => 'Wikidata Item ID', 'wikibase-pageinfo-entity-id-none' => 'None', ); -- To view, visit https://gerrit.wikimedia.org/r/67025 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I02c6787ca7f5dcc6a3ddcb5865d8632b8cba7156 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix handling of iwdata=only in Special UnconnectedPages - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/67155 Change subject: Fix handling of iwdata=only in Special UnconnectedPages .. Fix handling of iwdata=only in Special UnconnectedPages Succession links did not include the name-value pair iwdata=only and due to this would change behavior when the user clicked on those links. This patchset changes that behavior and properly add those pairs. Change-Id: I1f466e3ebe7882441998e93fc7fdbceb2f22beb8 --- M client/includes/specials/SpecialUnconnectedPages.php M lib/includes/specials/SpecialWikibaseQueryPage.php 2 files changed, 10 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/55/67155/1 diff --git a/client/includes/specials/SpecialUnconnectedPages.php b/client/includes/specials/SpecialUnconnectedPages.php index d90852d..10a0461 100644 --- a/client/includes/specials/SpecialUnconnectedPages.php +++ b/client/includes/specials/SpecialUnconnectedPages.php @@ -151,7 +151,12 @@ . Html::closeElement( 'form' ); $output->addHTML( $out ); - $this->showQuery(); + $query = array(); + if ( $this->iwData === 'only' ) { + $query['iwdata'] = $this->iwData; + } + + $this->showQuery( $query ); } /** diff --git a/lib/includes/specials/SpecialWikibaseQueryPage.php b/lib/includes/specials/SpecialWikibaseQueryPage.php index b92268e..285458c 100644 --- a/lib/includes/specials/SpecialWikibaseQueryPage.php +++ b/lib/includes/specials/SpecialWikibaseQueryPage.php @@ -85,9 +85,11 @@ /** * Output the query result * +* @param array|String $query optional URL query parameter string +* * @since 0.3 */ - protected function showQuery() { + protected function showQuery( array $query = array() ) { $out = $this->getOutput(); if ( $this->limit == 0 && $this->offset == 0 ) { @@ -107,7 +109,7 @@ $this->offset + 1 )->parseAsBlock() ); // Disable the "next" link when we reach the end $paging = $this->getLanguage()->viewPrevNext( $this->getTitleForNavigation(), $this->offset, - $this->limit, array(), ( $this->numRows <= $this->limit ) ); + $this->limit, $query, ( $this->numRows <= $this->limit ) ); $out->addHTML( Html::rawElement( 'p', array(), $paging ) ); } else { // No results to show, so don't bother with "showing X of Y" etc. -- To view, visit https://gerrit.wikimedia.org/r/67155 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1f466e3ebe7882441998e93fc7fdbceb2f22beb8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change example namespace base - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Change example namespace base .. Change example namespace base This is to avoid collission with the SMW namespaces. Else we even end up with the same property NS, which is very awkward! Picked 120 as it seems to not cause problems and is already being used by WMF. Change-Id: Ib26f654f4f7ed1e58ef4748a1c1b579560899690 --- M repo/config/Wikibase.example.php 1 file changed, 3 insertions(+), 3 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/config/Wikibase.example.php b/repo/config/Wikibase.example.php index c08ebf2..7cb9513 100644 --- a/repo/config/Wikibase.example.php +++ b/repo/config/Wikibase.example.php @@ -36,9 +36,9 @@ $wgContentHandlerUseDB = true; -// Define custom namespaces. Use these exact constant names. -$baseNs = 100; +$baseNs = 120; +// Define custom namespaces. Use these exact constant names. define( 'WB_NS_ITEM', $baseNs ); define( 'WB_NS_ITEM_TALK', $baseNs + 1 ); define( 'WB_NS_PROPERTY', $baseNs + 2 ); @@ -82,7 +82,7 @@ // Alternative settings, using the main namespace for items. // Note: if you do that, several core tests may fail. Parser tests for instance // assume that the main namespace contains wikitext. -$baseNs = 100; +$baseNs = 120; // NOTE: do *not* define WB_NS_ITEM and WB_NS_ITEM_TALK when using a core namespace for items! define( 'WB_NS_PROPERTY', $baseNs +2 ); -- To view, visit https://gerrit.wikimedia.org/r/52584 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib26f654f4f7ed1e58ef4748a1c1b579560899690 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Jens Ohlig Gerrit-Reviewer: John Erling Blad Gerrit-Reviewer: Tobias Gritschacher Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added insert, update and delete methods to query interface - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added insert, update and delete methods to query interface .. Added insert, update and delete methods to query interface Change-Id: I539ad26b87e1db06a4546df21621d7ffefeec028 --- M repo/includes/Database/MediaWikiQueryInterface.php M repo/includes/Database/ObservableQueryInterface.php M repo/includes/Database/QueryInterface.php M repo/tests/phpunit/includes/Database/MediaWikiQueryInterfaceTest.php 4 files changed, 258 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/Database/MediaWikiQueryInterface.php b/repo/includes/Database/MediaWikiQueryInterface.php index 86313f0..29fa479 100644 --- a/repo/includes/Database/MediaWikiQueryInterface.php +++ b/repo/includes/Database/MediaWikiQueryInterface.php @@ -104,4 +104,60 @@ return $this->getDB()->dropTable( $tableName, __METHOD__ ) !== false; } + /** +* @see QueryInterface::insert +* +* @since wd.db +* +* @param string $tableName +* @param array $values +* +* @return boolean Success indicator +*/ + public function insert( $tableName, array $values ) { + return $this->getDB()->insert( + $tableName, + $values, + __METHOD__ + ) !== false; + } + + /** +* @see QueryInterface::update +* +* @since wd.db +* +* @param string $tableName +* @param array $values +* @param array $conditions +* +* @return boolean Success indicator +*/ + public function update( $tableName, array $values, array $conditions ) { + return $this->getDB()->update( + $tableName, + $values, + $conditions, + __METHOD__ + ) !== false; + } + + /** +* @see QueryInterface::delete +* +* @since wd.db +* +* @param string $tableName +* @param array $conditions +* +* @return boolean Success indicator +*/ + public function delete( $tableName, array $conditions ) { + return $this->getDB()->delete( + $tableName, + $conditions, + __METHOD__ + ) !== false; + } + } diff --git a/repo/includes/Database/ObservableQueryInterface.php b/repo/includes/Database/ObservableQueryInterface.php index 48af945..8b01461 100644 --- a/repo/includes/Database/ObservableQueryInterface.php +++ b/repo/includes/Database/ObservableQueryInterface.php @@ -102,4 +102,47 @@ $this->runCallbacks( __FUNCTION__, func_get_args() ); } + /** +* @see QueryInterface::insert +* +* @since wd.db +* +* @param string $tableName +* @param array $values +* +* @return boolean Success indicator +*/ + public function insert( $tableName, array $values ) { + $this->runCallbacks( __FUNCTION__, func_get_args() ); + } + + /** +* @see QueryInterface::update +* +* @since wd.db +* +* @param string $tableName +* @param array $values +* @param array $conditions +* +* @return boolean Success indicator +*/ + public function update( $tableName, array $values, array $conditions ) { + $this->runCallbacks( __FUNCTION__, func_get_args() ); + } + + /** +* @see QueryInterface::delete +* +* @since wd.db +* +* @param string $tableName +* @param array $conditions +* +* @return boolean Success indicator +*/ + public function delete( $tableName, array $conditions ) { + $this->runCallbacks( __FUNCTION__, func_get_args() ); + } + } diff --git a/repo/includes/Database/QueryInterface.php b/repo/includes/Database/QueryInterface.php index 419fca4..85fe2c1 100644 --- a/repo/includes/Database/QueryInterface.php +++ b/repo/includes/Database/QueryInterface.php @@ -63,4 +63,47 @@ */ public function dropTable( $tableName ); + /** +* Inserts the provided values into the specified table. +* The values are provided as an associative array in +* which the keys are the field names. +* +* @since wd.db +* +* @param string $tableName +* @param array $values +* +* @return boolean Success indicator +*/ + public function insert( $tableName, array $values ); + + /** +* Updates the rows that match the conditions with t
[MediaWiki-commits] [Gerrit] Added TermsToClaimsTranslator - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added TermsToClaimsTranslator .. Added TermsToClaimsTranslator Change-Id: I3769b528cc3b21a24525b1b8801ffd27543efc7a --- M lib/WikibaseLib.hooks.php M lib/WikibaseLib.php A lib/includes/TermsToClaimsTranslator.php A lib/tests/phpunit/TermsToClaimsTranslatorTest.php 4 files changed, 317 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/lib/WikibaseLib.hooks.php b/lib/WikibaseLib.hooks.php index 28c7436..e6198f4 100644 --- a/lib/WikibaseLib.hooks.php +++ b/lib/WikibaseLib.hooks.php @@ -93,8 +93,9 @@ 'MapValueHasher', 'SettingsArray', 'SiteLink', - 'Utils', + 'TermsToClaimsTranslator', 'Term', + 'Utils', ); foreach ( $testFiles as $file ) { diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php index 2955626..10e8cba 100644 --- a/lib/WikibaseLib.php +++ b/lib/WikibaseLib.php @@ -117,6 +117,7 @@ $wgAutoloadClasses['Wikibase\SettingsArray'] = $dir . 'includes/SettingsArray.php'; $wgAutoloadClasses['Wikibase\SiteLink']= $dir . 'includes/SiteLink.php'; $wgAutoloadClasses['Wikibase\Term']= $dir . 'includes/Term.php'; +$wgAutoloadClasses['Wikibase\Lib\TermsToClaimsTranslator'] = $dir . 'includes/TermsToClaimsTranslator.php'; $wgAutoloadClasses['Wikibase\Utils'] = $dir . 'includes/Utils.php'; $wgAutoloadClasses['Wikibase\WikibaseDiffOpFactory'] = $dir . 'includes/WikibaseDiffOpFactory.php'; diff --git a/lib/includes/TermsToClaimsTranslator.php b/lib/includes/TermsToClaimsTranslator.php new file mode 100644 index 000..8e0432b --- /dev/null +++ b/lib/includes/TermsToClaimsTranslator.php @@ -0,0 +1,154 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since 0.4 + * + * @file + * @ingroup WikibaseLib + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class TermsToClaimsTranslator { + + /** +* Term type => Property id +* +* @var int[] +*/ + private $propertyIds = array(); + + /** +* Constructor. +* +* @since 0.4 +* +* @param int[] $propertyIds +*/ + public function __construct( array $propertyIds ) { + $this->propertyIds = $propertyIds; + } + + /** +* Turns a set of terms representing the same property though in different languages into a Claim +* with a MultilingualTextValue in its main snak. +* +* @since 0.4 +* +* @param Term[] $terms +* +* @return Claim +* @throws InvalidArgumentException +*/ + public function termsToClaim( array $terms ) { + if ( empty( $terms ) ) { + throw new InvalidArgumentException( 'Need to have at least one term to construct a claim' ); + } + + $term = reset( $terms ); + $termType = $term->getType(); + + $propertyId = $this->getPropertyIdForTermType( $termType ); + + $monoTexts = array(); + + foreach ( $terms as $term ) { + if ( $term->getType() !== $termType ) { + throw new InvalidArgumentException( 'Term types must be the same to construct a claim' ); + } + + $monoTexts[] = $this->termToMonoText( $term ); + } + + $multiText = new MultilingualTextValue( $monoTexts ); + + $mainSnak = new PropertyValueSnak( $propertyId, $multiText ); + + return new Claim( $mainSnak ); + } + + /** +* Turns a term into a Claim with MonolingualTextValue in its main snak. +* +* @since 0.4 +* +* @param Term $term +* +* @return Claim +*/ + public function termToClaim( Term $term ) { + $propertyId = $this->getPropertyIdForTermType( $term->getType() ); + $value = $this->termToMonoText( $term ); + + $mainSnak = new PropertyValueSnak( $propertyId, $value ); + + return new Claim( $mainSnak ); + } + + /** +* Returns the property id for a term type. +* +* @since 0.4 +* +* @param string $termType +* +* @return int +* @throws InvalidArgumentException +*/ + private function getPropertyIdForTermType( $termType ) { + if ( $termType === null ) { + throw new InvalidArgumentException( 'Term type must be set to turn
[MediaWiki-commits] [Gerrit] Add description of "string" to the list in DataTypes - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52624 Change subject: Add description of "string" to the list in DataTypes .. Add description of "string" to the list in DataTypes Change-Id: If5b9b8af97778a334cca8c024f14e506b9294d1d --- M repo/Wikibase.i18n.php 1 file changed, 8 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/24/52624/1 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 87aa254..1ba1b88 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -320,6 +320,10 @@ 'wikibase-listdatatypes-multilingual-text-body' => 'Literal data field for a string that must be translated into other languages. Typical use is a entity name of global interest that has non-local written forms. Those can differ both in languages and script systems. * language – explicit value for identifying the language for the text part * text – explicit value for the language specific variant string', + 'wikibase-listdatatypes-string-head' => 'String', + 'wikibase-listdatatypes-string-body' => 'Literal data field for a string of characters. Typical use is identifiers that has written forms that does not depend on the language. Such strings can in some cases be transliterated into other script systems. +* language – explicit value for identifying the language for the text part +* text – explicit value for the language specific variant string', 'wikibase-listdatatypes-time-head' => 'Time', 'wikibase-listdatatypes-time-body' => 'Literal data field for a time value. Given as a time with some precision and boundaries. The time are always saved internally in proleptic Gregorian, but can use other formats during parsing and formating.(?) * time – explicit value for point in time, represented per ISO8601, they year always having 11 digits, the date always be signed, in the format +0002013-01-01T00:00:00Z @@ -828,6 +832,10 @@ 'wikibase-listdatatypes-monolingual-text-body' => '{{Wikibase-datatype-body|Monolingual text}}', 'wikibase-listdatatypes-multilingual-text-head' => '{{Wikibase-datatype-head|Multilingual text}}', 'wikibase-listdatatypes-multilingual-text-body' => '{{Wikibase-datatype-body|Multilingual text}}', + 'wikibase-listdatatypes-string-head' => '{{Wikibase-datatype-head|String}}', + 'wikibase-listdatatypes-string-body' => '{{Wikibase-datatype-body|String}}', + 'wikibase-listdatatypes-time-head' => '{{Wikibase-datatype-head|Time}}', + 'wikibase-listdatatypes-time-body' => '{{Wikibase-datatype-body|Time}}', ); /** Achinese (Acèh) -- To view, visit https://gerrit.wikimedia.org/r/52624 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If5b9b8af97778a334cca8c024f14e506b9294d1d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: John Erling Blad ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits