[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Adding .luachecrc with a minimum configuration
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/392369 ) Change subject: Adding .luachecrc with a minimum configuration .. Adding .luachecrc with a minimum configuration The linter "luacheck" need a special configuration file to make it stop complaining. In addition to the configuration file a few changes are made to remove specific lints. This does not add the linter to the toolchain, it is only added for in-editor use. Bug: T180925 Change-Id: I091b46fdf358c36f02b36a65223f643a2c9e41b2 --- A .luacheckrc M client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua 2 files changed, 11 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/69/392369/1 diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 000..c92e319 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,5 @@ +stds.scribunto = { + globals = {"mw", "mw_interface"}, -- these globals can be set and accessed. +} +std = "min+scribunto" +files["client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua"].ignore = {"431"} diff --git a/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua b/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua index 989a572..158d37e 100644 --- a/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua +++ b/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua @@ -46,7 +46,7 @@ entity.claims = {} local pseudoClaimsMetatable = {} - pseudoClaimsMetatable.__index = function( emptyTable, propertyId ) + pseudoClaimsMetatable.__index = function( emptyTable, propertyId ) -- luacheck: no unused args if isValidPropertyId( propertyId ) then -- Only attempt to track the usage if we have a valid property id. php.addStatementUsage( entity.id, propertyId ) @@ -55,18 +55,18 @@ return actualEntityClaims[propertyId] end - pseudoClaimsMetatable.__newindex = function( emptyTable, propertyId, data ) + pseudoClaimsMetatable.__newindex = function( emptyTable, propertyId, data ) -- luacheck: no unused args error( 'Entity cannot be modified' ) end - local logNext = function( emptyTable, propertyId ) + local logNext = function( emptyTable, propertyId ) -- luacheck: no unused args if isValidPropertyId( propertyId ) then php.addStatementUsage( entity.id, propertyId ) end return next( actualEntityClaims, propertyId ) end - pseudoClaimsMetatable.__pairs = function( emptyTable ) + pseudoClaimsMetatable.__pairs = function( emptyTable ) -- luacheck: no unused args return logNext, {}, nil end @@ -211,7 +211,7 @@ local statements = {} local bestRank = 'normal' - for k, statement in pairs( entity.claims[propertyId] ) do + for _, statement in pairs( entity.claims[propertyId] ) do if statement.rank == bestRank then statements[#statements + 1] = statement elseif statement.rank == 'preferred' then @@ -233,7 +233,7 @@ local properties = {} local n = 0 - for k, v in pairs( entity.claims ) do + for k, _ in pairs( entity.claims ) do n = n + 1 properties[n] = k end -- To view, visit https://gerrit.wikimedia.org/r/392369 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I091b46fdf358c36f02b36a65223f643a2c9e41b2 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] translatewiki[master]: Fixed ignored and optional messages
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/366894 ) Change subject: Fixed ignored and optional messages .. Fixed ignored and optional messages Removed keys for optional "-wrap-" and "-translated" messages, and ignored "-original" and "-original-num" messages, and added a new optional "-keyword" message. Bug: T168691 Change-Id: I934757012a8e2b9b2c8787fd90762f1966d81d56 --- M groups/MediaWiki/mwgithub.yaml 1 file changed, 1 insertion(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/94/366894/1 diff --git a/groups/MediaWiki/mwgithub.yaml b/groups/MediaWiki/mwgithub.yaml index 443c73d..65be6ea 100644 --- a/groups/MediaWiki/mwgithub.yaml +++ b/groups/MediaWiki/mwgithub.yaml @@ -341,12 +341,9 @@ - pickle-testcase-invoke - pickle-default-subpage - pickle-default-invoke -- pickle-report-*-wrap-* -- pickle-report-*-translated +- pickle-report-*-keyword - pickle-report-*-no-description ignored: - pickle-testspec-subpage - pickle-testspec-invoke -- pickle-report-*-original -- pickle-report-*-original-num -- To view, visit https://gerrit.wikimedia.org/r/366894 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I934757012a8e2b9b2c8787fd90762f1966d81d56 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki 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] translatewiki[master]: Updated the optional and ignored messages
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/362871 ) Change subject: Updated the optional and ignored messages .. Updated the optional and ignored messages This is a maintenance update. Change-Id: Ib459eed575c5e73b5c4045b8f155bcfbd382 Bugs: T169455 --- M groups/MediaWiki/mwgithub.yaml 1 file changed, 14 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/71/362871/1 diff --git a/groups/MediaWiki/mwgithub.yaml b/groups/MediaWiki/mwgithub.yaml index 90f1e58..3fb25d5 100644 --- a/groups/MediaWiki/mwgithub.yaml +++ b/groups/MediaWiki/mwgithub.yaml @@ -337,9 +337,10 @@ TAGS: optional: -- pickle-testspec-subpage - pickle-testcase-subpage +- pickle-testcase-invoke - pickle-default-subpage +- pickle-default-invoke - pickle-report-adapt-wrap-translated - pickle-report-adapt-wrap-untranslated - pickle-report-frame-wrap-translated @@ -348,18 +349,20 @@ - pickle-report-adapt-is-not-ok-translated - pickle-report-frame-is-ok-translated - pickle-report-frame-is-not-ok-translated +- pickle-report-adapt-is-skip-translated +- pickle-report-adapt-is-todo-translated +- pickle-report-frame-is-skip-translated +- pickle-report-frame-is-todo-translated - pickle-report-adapt-todo-no-description - pickle-report-adapt-skip-no-description - pickle-report-frame-todo-no-description - pickle-report-frame-skip-no-description - pickle-report-frame-wrap-description - pickle-report-frame-wrap-no-description -- pickle-report-frame-is-skip-translated ignored: +- pickle-testspec-subpage - pickle-testspec-invoke -- pickle-testcase-invoke -- pickle-default-invoke - pickle-frame-full-header - pickle-frame-vivid-header - pickle-report-frame-wrap-description @@ -368,7 +371,14 @@ - pickle-report-adapt-skip-no-description - pickle-report-adapt-wrap-description - pickle-report-adapt-is-ok-original +- pickle-report-adapt-is-ok-original-num - pickle-report-adapt-is-not-ok-original +- pickle-report-adapt-is-not-ok-original-num - pickle-report-frame-is-ok-original +- pickle-report-frame-is-ok-original-num - pickle-report-frame-is-not-ok-original +- pickle-report-frame-is-not-ok-original-num +- pickle-report-adapt-is-skip-original +- pickle-report-adapt-is-todo-original - pickle-report-frame-is-skip-original +- pickle-report-frame-is-todo-original -- To view, visit https://gerrit.wikimedia.org/r/362871 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib459eed575c5e73b5c4045b8f155bcfbd382 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki 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] translatewiki[master]: Fixed ignored and optional messages
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/360998 ) Change subject: Fixed ignored and optional messages .. Fixed ignored and optional messages This is the call for invoked messages holding the reports, and optional messages for building links to the test pages. Bug: T168691 Change-Id: Ied4876a4190b239001da1b7814abd192b5e41d18 --- M groups/MediaWiki/mwgithub.yaml 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/98/360998/1 diff --git a/groups/MediaWiki/mwgithub.yaml b/groups/MediaWiki/mwgithub.yaml index 90f1e58..993e53e 100644 --- a/groups/MediaWiki/mwgithub.yaml +++ b/groups/MediaWiki/mwgithub.yaml @@ -337,9 +337,10 @@ TAGS: optional: -- pickle-testspec-subpage - pickle-testcase-subpage +- pickle-testcase-invoke - pickle-default-subpage +- pickle-default-invoke - pickle-report-adapt-wrap-translated - pickle-report-adapt-wrap-untranslated - pickle-report-frame-wrap-translated @@ -357,9 +358,8 @@ - pickle-report-frame-is-skip-translated ignored: +- pickle-testspec-subpage - pickle-testspec-invoke -- pickle-testcase-invoke -- pickle-default-invoke - pickle-frame-full-header - pickle-frame-vivid-header - pickle-report-frame-wrap-description -- To view, visit https://gerrit.wikimedia.org/r/360998 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ied4876a4190b239001da1b7814abd192b5e41d18 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki 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] translatewiki[master]: Updated ignored and optional messages
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/360899 ) Change subject: Updated ignored and optional messages .. Updated ignored and optional messages These are additional entries for new and changed messages. Change-Id: I2862f4bab79e8dc88e0bf5bc0161d414606f4919 --- M groups/MediaWiki/mwgithub.yaml 1 file changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/99/360899/1 diff --git a/groups/MediaWiki/mwgithub.yaml b/groups/MediaWiki/mwgithub.yaml index 00e04c4..90f1e58 100644 --- a/groups/MediaWiki/mwgithub.yaml +++ b/groups/MediaWiki/mwgithub.yaml @@ -348,6 +348,14 @@ - pickle-report-adapt-is-not-ok-translated - pickle-report-frame-is-ok-translated - pickle-report-frame-is-not-ok-translated +- pickle-report-adapt-todo-no-description +- pickle-report-adapt-skip-no-description +- pickle-report-frame-todo-no-description +- pickle-report-frame-skip-no-description +- pickle-report-frame-wrap-description +- pickle-report-frame-wrap-no-description +- pickle-report-frame-is-skip-translated + ignored: - pickle-testspec-invoke - pickle-testcase-invoke @@ -363,3 +371,4 @@ - pickle-report-adapt-is-not-ok-original - pickle-report-frame-is-ok-original - pickle-report-frame-is-not-ok-original +- pickle-report-frame-is-skip-original -- To view, visit https://gerrit.wikimedia.org/r/360899 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2862f4bab79e8dc88e0bf5bc0161d414606f4919 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki 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] translatewiki[master]: Updated ignored and optionals
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/360334 ) Change subject: Updated ignored and optionals .. Updated ignored and optionals Change-Id: I09026e2be2005bb85569dac700f09c638ee1e1a1 --- M groups/MediaWiki/mediawiki-extensions.txt 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/34/360334/1 diff --git a/groups/MediaWiki/mediawiki-extensions.txt b/groups/MediaWiki/mediawiki-extensions.txt index f78ebe6..5318b16 100644 --- a/groups/MediaWiki/mediawiki-extensions.txt +++ b/groups/MediaWiki/mediawiki-extensions.txt @@ -2021,11 +2021,15 @@ Pickle optional = pickle-testspec-subpage, pickle-testcase-subpage, pickle-default-subpage +optional = pickle-report-adapt-is-ok-translated, pickle-report-adapt-is-not-ok-original +optional = pickle-report-frame-is-ok-original, pickle-report-frame-is-not-ok-original ignored = pickle-testspec-invoke, pickle-testcase-invoke, pickle-default-invoke ignored = pickle-frame-full-header, pickle-frame-vivid-header ignored = pickle-report-frame-wrap-description, pickle-report-adapt-wrap-line ignored = pickle-report-adapt-todo-no-description, pickle-report-adapt-skip-no-description ignored = pickle-report-adapt-wrap-description +ignored = pickle-report-adapt-is-ok-original, pickle-report-adapt-is-not-ok-original +ignored = pickle-report-frame-is-ok-original, pickle-report-frame-is-not-ok-original Pipe Escape -- To view, visit https://gerrit.wikimedia.org/r/360334 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I09026e2be2005bb85569dac700f09c638ee1e1a1 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki 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] mediawiki/core[master]: Moved stub thresholds to default settings
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/351316 ) Change subject: Moved stub thresholds to default settings .. Moved stub thresholds to default settings The stub thresholds used for link classes are moved to DefaultSettings, and the default sequence is completed. It was missing the number "200", and should now be a log-like sequence. Bug: T164235 Change-Id: Ice7ef0d23823d79f16f249003e574f4c3def30d0 --- M includes/DefaultSettings.php M includes/Preferences.php 2 files changed, 6 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/16/351316/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ac2261c..a6b2920 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3326,6 +3326,11 @@ $wgUseSiteCss = true; /** + * Use a set of stub threshold values + */ +$wgUseStubThresholdValues = [ 50, 100, 200, 500, 1000, 2000, 5000, 1 ]; + +/** * Break out of framesets. This can be used to prevent clickjacking attacks, * or to prevent external sites from framing your site with ads. */ diff --git a/includes/Preferences.php b/includes/Preferences.php index b428e87..3b77a17 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -778,7 +778,7 @@ ]; } - $stubThresholdValues = [ 50, 100, 500, 1000, 2000, 5000, 1 ]; + $stubThresholdValues = $context->getConfig()->get( 'UseStubThresholdValues' ); $stubThresholdOptions = [ $context->msg( 'stub-threshold-disabled' )->text() => 0 ]; foreach ( $stubThresholdValues as $value ) { $stubThresholdOptions[$context->msg( 'size-bytes', $value )->text()] = $value; -- To view, visit https://gerrit.wikimedia.org/r/351316 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ice7ef0d23823d79f16f249003e574f4c3def30d0 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] mediawiki/core[master]: Completed the log sequence for stub thresholds
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/351219 ) Change subject: Completed the log sequence for stub thresholds .. Completed the log sequence for stub thresholds The sequence does not contain the value "200". Bug: T164235 Change-Id: If129cbf76845a6758c39122aa086b8d68dc594dc --- M includes/Preferences.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/19/351219/1 diff --git a/includes/Preferences.php b/includes/Preferences.php index b428e87..02b1e41 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -778,7 +778,7 @@ ]; } - $stubThresholdValues = [ 50, 100, 500, 1000, 2000, 5000, 1 ]; + $stubThresholdValues = [ 50, 100, 200, 500, 1000, 2000, 5000, 1 ]; $stubThresholdOptions = [ $context->msg( 'stub-threshold-disabled' )->text() => 0 ]; foreach ( $stubThresholdValues as $value ) { $stubThresholdOptions[$context->msg( 'size-bytes', $value )->text()] = $value; -- To view, visit https://gerrit.wikimedia.org/r/351219 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If129cbf76845a6758c39122aa086b8d68dc594dc 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] translatewiki[master]: Translation config for the Pickle extension
John Erling Blad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/337856 ) Change subject: Translation config for the Pickle extension .. Translation config for the Pickle extension This config has not been tested, so it should be reviewed by someone familiar with translatewiki.net Bug: T158189 Change-Id: I4eda10b2a5200a098cae8a3b333f804bda2d3e91 --- M bin/EXTERNAL-PROJECTS M bin/REPONG-PROJECTS M repoconfig.commit.json M repoconfig.json 4 files changed, 20 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/translatewiki refs/changes/56/337856/1 diff --git a/bin/EXTERNAL-PROJECTS b/bin/EXTERNAL-PROJECTS index 4bdd657..63423d0 100644 --- a/bin/EXTERNAL-PROJECTS +++ b/bin/EXTERNAL-PROJECTS @@ -35,6 +35,7 @@ oppia osm pageviews +pickle pywikibot vicuna video2commons diff --git a/bin/REPONG-PROJECTS b/bin/REPONG-PROJECTS index 06a7adc..b19adee 100644 --- a/bin/REPONG-PROJECTS +++ b/bin/REPONG-PROJECTS @@ -33,6 +33,7 @@ oppia osm pageviews +pickle pywikibot vicuna video2commons diff --git a/repoconfig.commit.json b/repoconfig.commit.json index 5c32b98..d70ec84 100644 --- a/repoconfig.commit.json +++ b/repoconfig.commit.json @@ -345,6 +345,15 @@ } } }, + "pickle": { + "group": "pickle", + "repos": { + "pageviews": { + "type": "wmgerrit", + "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Pickle"; + } + } + }, "pywikibot": { "group": "out-pywikipedia-*", "export-threshold": 1, diff --git a/repoconfig.json b/repoconfig.json index 58c4add..6a34aaa 100644 --- a/repoconfig.json +++ b/repoconfig.json @@ -345,6 +345,15 @@ } } }, + "pickle": { + "group": "pickle", + "repos": { + "pageviews": { + "type": "wmgerrit", + "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Pickle"; + } + } + }, "pywikibot": { "group": "out-pywikipedia-*", "export-threshold": 1, -- To view, visit https://gerrit.wikimedia.org/r/337856 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4eda10b2a5200a098cae8a3b333f804bda2d3e91 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki 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] 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] 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] 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] 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] 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] 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] (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] 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] 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] 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] 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] 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] 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] 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] 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] 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] (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] 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] 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] (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] 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 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 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] 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] 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] 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] Prevent type errors on unexpected diff types in changes. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Prevent type errors on unexpected diff types in changes. .. Prevent type errors on unexpected diff types in changes. Change-Id: I08ebd11da8b737900afb3f5a37b770ea725b8f4e --- M client/includes/ChangeHandler.php M lib/includes/changes/ItemChange.php 2 files changed, 4 insertions(+), 5 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 4ad7741..30e980c 100644 --- a/client/includes/ChangeHandler.php +++ b/client/includes/ChangeHandler.php @@ -677,10 +677,9 @@ $actions = 0; if ( $change instanceof ItemChange ) { - /* @var ItemDiff $diff */ $diff = $change->getDiff(); - if ( !$diff->getSiteLinkDiff()->isEmpty() ) { + if ( $diff instanceof ItemDiff && !$diff->getSiteLinkDiff()->isEmpty() ) { //TODO: make it so we don't have to re-render // if only the site links changed (see bug 45534) $actions |= self::PARSER_PURGE_ACTION | self::WEB_PURGE_ACTION | self::LINKS_UPDATE_ACTION @@ -688,12 +687,12 @@ } if ( $this->dataTransclusionAllowed ) { - if ( !$diff->getClaimDiff()->isEmpty() ) { + if ( $diff instanceof EntityDiff && !$diff->getClaimDiff()->isEmpty() ) { $actions |= self::PARSER_PURGE_ACTION | self::WEB_PURGE_ACTION | self::LINKS_UPDATE_ACTION | self::RC_ENTRY_ACTION | self::HISTORY_ENTRY_ACTION; } - if ( !$diff->getLabelDiff()->isEmpty() ) { + if ( $diff instanceof EntityDiff && !$diff->getLabelDiff()->isEmpty() ) { $actions |= self::PARSER_PURGE_ACTION | self::WEB_PURGE_ACTION | self::LINKS_UPDATE_ACTION | self::RC_ENTRY_ACTION | self::HISTORY_ENTRY_ACTION; } diff --git a/lib/includes/changes/ItemChange.php b/lib/includes/changes/ItemChange.php index d3bf23a..eaefc93 100644 --- a/lib/includes/changes/ItemChange.php +++ b/lib/includes/changes/ItemChange.php @@ -46,7 +46,7 @@ return new \Diff\Diff(); } else { - return $this->getDiff()->getSiteLinkDiff(); + return $diff->getSiteLinkDiff(); } } } -- To view, visit https://gerrit.wikimedia.org/r/54479 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I08ebd11da8b737900afb3f5a37b770ea725b8f4e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler Gerrit-Reviewer: Aude Gerrit-Reviewer: Jeroen De Dauw 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] WikibaseClient uses __FILE__ instead of __DIR_ - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/54799 Change subject: WikibaseClient uses __FILE__ instead of __DIR_ .. WikibaseClient uses __FILE__ instead of __DIR_ By using __FILE__ the path will be wrong and the link is not generated on Special:Version. This is done already in WikibaseLib and Wikibase. Change-Id: I9c37ab4a5aeb1aaf7b8bced855ce0ca7c329a94a --- M client/WikibaseClient.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/99/54799/1 diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index af99a9c..82cc400 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -40,7 +40,7 @@ . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); $wgExtensionCredits['other'][] = array( - 'path' => __FILE__, + 'path' => __DIR__, 'name' => 'Wikibase Client', 'version' => WBC_VERSION, 'author' => array( -- To view, visit https://gerrit.wikimedia.org/r/54799 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9c37ab4a5aeb1aaf7b8bced855ce0ca7c329a94a 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] Add "experimental" to the version string when in exp mode. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Add "experimental" to the version string when in exp mode. .. Add "experimental" to the version string when in exp mode. Change-Id: Ib41189695c1406a1eea9eb91f76c422f4ece7d4e --- M DataModel/DataModel.php M client/WikibaseClient.php M lib/WikibaseLib.php M repo/Wikibase.php 4 files changed, 8 insertions(+), 4 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/DataModel/DataModel.php b/DataModel/DataModel.php index dcc715e..3120c9a 100644 --- a/DataModel/DataModel.php +++ b/DataModel/DataModel.php @@ -27,7 +27,8 @@ * @author Jeroen De Dauw < jeroended...@gmail.com > */ -define( 'WIKIBASE_DATAMODEL_VERSION', '0.4 alpha' ); +define( 'WIKIBASE_DATAMODEL_VERSION', '0.4 alpha' + . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); // @codeCoverageIgnoreStart call_user_func( function() { diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 5d34865..af99a9c 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -36,7 +36,8 @@ die( 'Error: WikibaseClient depends on the https://www.mediawiki.org/wiki/Extension:WikibaseLib";>WikibaseLib extension.' ); } -define( 'WBC_VERSION', '0.4 alpha' ); +define( 'WBC_VERSION', '0.4 alpha' + . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); $wgExtensionCredits['other'][] = array( 'path' => __FILE__, diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php index b5e7506..bd08d34 100644 --- a/lib/WikibaseLib.php +++ b/lib/WikibaseLib.php @@ -73,7 +73,8 @@ unset( $dependencies ); -define( 'WBL_VERSION', '0.4 alpha' ); +define( 'WBL_VERSION', '0.4 alpha' + . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); $wgExtensionCredits['other'][] = array( 'path' => __DIR__, diff --git a/repo/Wikibase.php b/repo/Wikibase.php index fd45ed4..c3f2b45 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -47,7 +47,8 @@ die( 'Error: Wikibase depends on the https://www.mediawiki.org/wiki/Extension:WikibaseLib";>WikibaseLib extension.' ); } -define( 'WB_VERSION', '0.4 alpha' ); +define( 'WB_VERSION', '0.4 alpha' + . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); $wgExtensionCredits['other'][] = array( 'path' => __DIR__, -- To view, visit https://gerrit.wikimedia.org/r/54711 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib41189695c1406a1eea9eb91f76c422f4ece7d4e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler Gerrit-Reviewer: Anja Jentzsch 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] Fix namespace filtering in ChangeHandler. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Fix namespace filtering in ChangeHandler. .. Fix namespace filtering in ChangeHandler. In addition to the actual fix (include/exclude params in the correct order), thich change includes a number of improvements to debug logging and error reporting during change handling on the client. Note: this needs to be backported to the wmf12 branch. Change-Id: Ib8ac99f762b9aed5f61d62c10bf7706ed70affa8 --- M client/includes/ChangeHandler.php M client/includes/NamespaceChecker.php M client/includes/WikiPageUpdater.php M lib/includes/ChangeNotificationJob.php M lib/includes/changes/ItemChange.php M lib/maintenance/dispatchChanges.php 6 files changed, 53 insertions(+), 23 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 4ad7741..3aa21ed 100644 --- a/client/includes/ChangeHandler.php +++ b/client/includes/ChangeHandler.php @@ -141,8 +141,8 @@ // TODO: allow these to be passed in as parameters! $this->setNamespaces( - Settings::get( 'excludeNamespaces' ), - Settings::get( 'namespaces' ) + Settings::get( 'namespaces' ), + Settings::get( 'excludeNamespaces' ) ); $this->injectRC = Settings::get( 'injectRecentChanges' ); @@ -237,7 +237,10 @@ $minor = true; $bot = true; + $ids = array(); + foreach ( $changes as $change ) { + $ids[] = $change->getId(); $meta = $change->getMetadata(); $minor &= isset( $meta['minor'] ) && (bool)$meta['minor']; @@ -289,6 +292,7 @@ ) ); $info = $change->hasField( 'info' ) ? $change->getField( 'info' ) : array(); + $info['change-ids'] = $ids; $info['changes'] = $changes; $change->setField( 'info', $info ); @@ -397,6 +401,10 @@ } usort( $coalesced, 'Wikibase\ChangeHandler::compareChangesByTimestamp' ); + + wfDebugLog( __CLASS__, __METHOD__ . ": coalesced " + . count( $changes ) . " into " . count( $coalesced ) . " changes" ); + return $coalesced; } @@ -466,7 +474,10 @@ */ public function handleChange( Change $change ) { wfProfileIn( __METHOD__ ); - wfDebugLog( __CLASS__, __FUNCTION__ . ": handling change #" . $change->getId() ); + + $chid = self::getChangeIdForLog( $change ); + wfDebugLog( __CLASS__, __FUNCTION__ . ": handling change #$chid" + . " (" . $change->getType() . ")" ); //TODO: Actions may be per-title, depending on how the change applies to that page. // We'll need on list of titles per action. @@ -474,6 +485,7 @@ if ( $actions === 0 ) { // nothing to do + wfDebugLog( __CLASS__, __FUNCTION__ . ": No actions to take for change #$chid." ); wfProfileOut( __METHOD__ ); return false; } @@ -487,11 +499,13 @@ if ( empty( $titlesToUpdate ) ) { // nothing to do + wfDebugLog( __CLASS__, __FUNCTION__ . ": No pages to update for change #$chid." ); wfProfileOut( __METHOD__ ); return false; } - wfDebugLog( __CLASS__, __FUNCTION__ . ": " . count( $titlesToUpdate ) . " pages to update." ); + wfDebugLog( __CLASS__, __FUNCTION__ . ": updating " . count( $titlesToUpdate ) + . " pages (actions: " . dechex( $actions ). ") for change #$chid." ); $this->updatePages( $change, $actions, $titlesToUpdate ); @@ -597,7 +611,7 @@ if ( $rcAttribs !== false ) { $this->updater->injectRCRecord( $title, $rcAttribs ); } else { - trigger_error( "change #" . $change->getId() . " did not provide RC info", E_USER_WARNING ); + trigger_error( "change #" . self::getChangeIdForLog( $change ) . " did not provide RC info", E_USER_WARNING ); } } @@ -606,6 +620,26 @@ } wfProfileOut( __METHOD__ ); + } + + /** +* Returns a human readable change ID, containing multiple IDs in case of a +* coalesced change. +* +
[MediaWiki-commits] [Gerrit] Finally make wbclient.linkItem non-experimental - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Finally make wbclient.linkItem non-experimental .. Finally make wbclient.linkItem non-experimental Patchset 2: Rebased Patchset 3: Sporious lines commented out Change-Id: Ibcab6cfd32bbff82900fcc05edeedc63635fbd71 --- M client/WikibaseClient.hooks.php M client/config/WikibaseClient.experimental.php 2 files changed, 8 insertions(+), 16 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index c466e25..1396a58 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -609,6 +609,8 @@ // Needed as we can't do that in the regular CSS nor in JavaScript // (as that only runs after the element initially appeared). $out->addModules( 'wikibase.client.nolanglinks' ); + // Add the JavaScript to link pages locally + $out->addModules( 'wbclient.linkItem' ); } } diff --git a/client/config/WikibaseClient.experimental.php b/client/config/WikibaseClient.experimental.php index e3844c3..4646a00 100644 --- a/client/config/WikibaseClient.experimental.php +++ b/client/config/WikibaseClient.experimental.php @@ -36,19 +36,9 @@ // includes/parserhooks $wgAutoloadClasses['Wikibase\PropertyParserFunction'] = $dir . 'includes/parserhooks/PropertyParserFunction.php'; -// Add the JavaScript to link items locally -$wgHooks['BeforePageDisplay'][] = function( OutputPage &$out, Skin &$skin ) { - $title = $out->getTitle(); - $namespaceChecker = new \Wikibase\NamespaceChecker( - \Wikibase\Settings::get( 'excludeNamespaces' ), - \Wikibase\Settings::get( 'namespaces' ) - ); - - if ( $namespaceChecker->isWikibaseEnabled( $title->getNamespace() ) ) { - if ( !$out->getLanguageLinks() && \Action::getActionName( $skin->getContext() ) === 'view' && $title->exists() ) { - $out->addModules( 'wbclient.linkItem' ); - } - } - - return true; -}; +// Sporious code from a merge conflict, but should probably be left in due to line above +//$wgHooks['ParserFirstCallInit'][] = function( \Parser &$parser ) { +// $parser->setFunctionHook( 'property', array( '\Wikibase\PropertyParserFunction', 'render' ) ); +// +// return true; +//}; -- To view, visit https://gerrit.wikimedia.org/r/53606 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibcab6cfd32bbff82900fcc05edeedc63635fbd71 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Hoo man Gerrit-Reviewer: Aude Gerrit-Reviewer: Hoo man 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 file to clarify DataModel component dependencies - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Added file to clarify DataModel component dependencies .. Added file to clarify DataModel component dependencies Change-Id: Ia980d7bb7aa8d91538b1eb171e23a8f1413cbf45 --- A DataModel/dependencies.txt 1 file changed, 8 insertions(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/DataModel/dependencies.txt b/DataModel/dependencies.txt new file mode 100644 index 000..bb0fc3e --- /dev/null +++ b/DataModel/dependencies.txt @@ -0,0 +1,8 @@ +The Wikibase DataModel component is dependent on: + +* WikibaseLib (this dependency is something we want to get rid of) +* MediaWiki (this dependency is something we want to get rid of) +* DataValues library +* Ask library (only the Query class has this dependency) + +And nothing else. \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/54017 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia980d7bb7aa8d91538b1eb171e23a8f1413cbf45 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] Update install requirements - change (mediawiki...Ask)
John Erling Blad has submitted this change and it was merged. Change subject: Update install requirements .. Update install requirements Change-Id: I91fdb69314d50ef56a569ad1ebef7188f39939ff --- M INSTALL 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/INSTALL b/INSTALL index cf06458..98d9468 100644 --- a/INSTALL +++ b/INSTALL @@ -9,6 +9,7 @@ Ask requires: * PHP 5.3 or above +* DataValues library 0.1 or above * If used as MediaWiki extension: MediaWiki 1.16 or later ** PHPUnit tests can require the latest MediaWiki -- To view, visit https://gerrit.wikimedia.org/r/54018 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I91fdb69314d50ef56a569ad1ebef7188f39939ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Ask Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Jens Ohlig 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 type hints - change (mediawiki...DataValues)
John Erling Blad has submitted this change and it was merged. Change subject: Improve type hints .. Improve type hints Change-Id: I05ba765ca721877292bf2e3125ec8e42a95876ac --- M DataValues/includes/values/BooleanValue.php M DataValues/includes/values/GeoCoordinateValue.php M DataValues/includes/values/IriValue.php M DataValues/includes/values/MediaWikiTitleValue.php M DataValues/includes/values/MonolingualTextValue.php M DataValues/includes/values/MultilingualTextValue.php M DataValues/includes/values/NumberValue.php M DataValues/includes/values/PropertyValue.php M DataValues/includes/values/QuantityValue.php M DataValues/includes/values/StringValue.php M DataValues/includes/values/TimeValue.php M DataValues/includes/values/UnknownValue.php 12 files changed, 28 insertions(+), 14 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/DataValues/includes/values/BooleanValue.php b/DataValues/includes/values/BooleanValue.php index f01b03b..2fe4dc5 100644 --- a/DataValues/includes/values/BooleanValue.php +++ b/DataValues/includes/values/BooleanValue.php @@ -1,6 +1,7 @@ https://gerrit.wikimedia.org/r/54021 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I05ba765ca721877292bf2e3125ec8e42a95876ac Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw Gerrit-Reviewer: Jens Ohlig 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] noexternallanglinks needs to be serialized - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: noexternallanglinks needs to be serialized .. noexternallanglinks needs to be serialized - there was a reason we serialized it... LinksUpdate does array_diff_assoc. If the property is set (as array), and compared with empty property (a string), then we have a problem. If the array values are strings, regardless if it's set or not then all is good. Change-Id: Ie8796ebcc774b3c9aa91bc7c0555917ec66b66dd --- M client/includes/LangLinkHandler.php 1 file changed, 3 insertions(+), 6 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/includes/LangLinkHandler.php b/client/includes/LangLinkHandler.php index 6226f75..0cf009d 100644 --- a/client/includes/LangLinkHandler.php +++ b/client/includes/LangLinkHandler.php @@ -203,11 +203,8 @@ */ public function getNoExternalLangLinks( ParserOutput $out ) { wfProfileIn( __METHOD__ ); - $nel = $out->getProperty( 'noexternallanglinks' ); - - if( empty( $nel ) ) { - $nel = array(); - } + $property = $out->getProperty( 'noexternallanglinks' ); + $nel = is_string( $property ) ? unserialize( $property ) : array(); wfProfileOut( __METHOD__ ); return $nel; @@ -224,7 +221,7 @@ */ public function setNoExternalLangLinks( ParserOutput $out, array $noexternallanglinks ) { wfProfileIn( __METHOD__ ); - $out->setProperty( 'noexternallanglinks', $noexternallanglinks ); + $out->setProperty( 'noexternallanglinks', serialize( $noexternallanglinks ) ); wfProfileOut( __METHOD__ ); } -- To view, visit https://gerrit.wikimedia.org/r/53768 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie8796ebcc774b3c9aa91bc7c0555917ec66b66dd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude Gerrit-Reviewer: Daniel Kinzler 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 45099) Return full error report from API. - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (bug 45099) Return full error report from API. .. (bug 45099) Return full error report from API. This generalizes entity saving and error handling in the API. By this, consistency is improved, redundant code is reduced, and error reporting is greatly improved. There are some design issues here pending discussion, especially in regards to moving from inheritance based code re-use towards a composition based model. This change does not solve these issues, but should make any future refactoring easier, and is thus a step into the right direction. patchset 9: rebased and solved conflict in ClaimSaver.php Change-Id: I4094feee1e6166171fd15ffdf7249b3c0d27ce1c --- M repo/includes/ClaimSaver.php M repo/includes/EditEntity.php M repo/includes/api/ApiWikibase.php M repo/includes/api/CreateClaim.php M repo/includes/api/LinkTitles.php M repo/includes/api/ModifyEntity.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 M repo/tests/phpunit/includes/api/SetAliasesTest.php M repo/tests/phpunit/includes/api/SetQualifierTest.php 16 files changed, 433 insertions(+), 334 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/includes/ClaimSaver.php b/repo/includes/ClaimSaver.php index d0752a4..a9b1968 100644 --- a/repo/includes/ClaimSaver.php +++ b/repo/includes/ClaimSaver.php @@ -4,6 +4,7 @@ use User; use MWException; +use Status; use Wikibase\ExceptionWithCode; /** @@ -46,18 +47,33 @@ * @param string $token * @param User $user * -* @return int +* @return Status The status. The status value is an array which may contain +* the following fields: +* +* -revision: the revision object created by the save +* -errorFlags: error flags using the EditEntity::XXX_ERROR constants +* -errorCode: error code to use in API output +* +* This status object can be used with ApiWikibase::handleSaveStatus(). */ public function saveClaim( Claim $claim, $baseRevId, $token, User $user ) { - $entityId = $this->getEntityIdForClaim( $claim ); + try { + $entityId = $this->getEntityIdForClaim( $claim ); - $content = $this->getEntityContent( $entityId, $baseRevId ); + $content = $this->getEntityContent( $entityId, $baseRevId ); - $this->updateClaim( $content->getEntity(), $claim ); + $this->updateClaim( $content->getEntity(), $claim ); - $newRevisionId = $this->saveChanges( $content, $baseRevId, $token, $user ); + $status = $this->saveChanges( $content, $baseRevId, $token, $user ); + } catch ( ExceptionWithCode $ex ) { + // put the error code into the status + $value = array( 'errorCode' => $ex->getErrorCode() ); + $status = Status::newGood(); + $status->setResult( false, $value ); + //TODO: add an error message localization key, perhaps derived from the error code. + } - return $newRevisionId; + return $status; } /** @@ -151,8 +167,7 @@ * @param string $token * @param User $user * -* @return int -* @throws ExceptionWithCode +* @return Status */ protected function saveChanges( EntityContent $content, $baseRevisionId, $token, User $user ) { $baseRevisionId = is_int( $baseRevisionId ) && $baseRevisionId > 0 ? $baseRevisionId : false; @@ -164,12 +179,7 @@ $token ); - if ( !$status->isOK() ) { - throw new ExceptionWithCode( $status->getMessage(), 'setclaim-save-failed' ); - } - - $statusValue = $status->getValue(); - return (int)$statusValue['revision']->getId(); + return $status; } } \ No newline at end of file diff --git a/repo/includes/EditEntity.php b/repo/includes/EditEntity.php index e8965ff..251059e 100644 --- a/repo/includes/EditEntity.php +++ b/repo/includes/EditEntity.php @@ -363,6 +363,7 @@ * * - new: bool whether the edit created a new page * - revision: Revision the new revision object +* - errorFlags: bit field indicating errors, see the XXX_ERROR constants. * * @since 0.1
[MediaWiki-commits] [Gerrit] Add fywiki sort order and allow custom order in settings - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Add fywiki sort order and allow custom order in settings .. Add fywiki sort order and allow custom order in settings Change-Id: I07c3448b253330a2f834e48e565dd0eb28aa45d9 --- M client/config/WikibaseClient.default.php M client/includes/InterwikiSorter.php M client/tests/phpunit/includes/InterwikiSorterTest.php M docs/options.wiki 4 files changed, 51 insertions(+), 15 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/client/config/WikibaseClient.default.php b/client/config/WikibaseClient.default.php index c2da880..1a564c1 100644 --- a/client/config/WikibaseClient.default.php +++ b/client/config/WikibaseClient.default.php @@ -62,7 +62,7 @@ /** * @todo this is a bit wikimedia-specific and need to find a better place for this stuff, - * such as mediawiki-config or somewhere. + * such as mediawiki-config, mediawiki messages for custom orders, or somewhere. * * alphabetic and alphabetic revised come from: * http://meta.wikimedia.org/w/index.php?title=MediaWiki:Interwiki_config-sorting_order-native-languagename @@ -151,5 +151,32 @@ 'tk', 'tw', 'udm', 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vo', 'fiu-vro', 'wa', 'vls', 'war', 'wo', 'wuu', 'ts', 'xmf', 'yi', 'yo', 'diq', 'zea', 'zh', 'zh-tw', 'zh-cn', 'zh-classical', 'zh-yue', 'bat-smg' -) +), + 'alphabetic_fy' => array( + 'aa', 'ab', 'ace', 'af', 'ay', 'ak', 'als', 'am', 'an', 'ang', 'ar', 'arc', + 'arz', 'as', 'ast', 'av', 'az', 'ba', 'bar', 'bat-smg', 'bcl', 'be', 'be-x-old', + 'bg', 'bh', 'bi', 'bjn', 'bm', 'bn', 'bo', 'bpy', 'br', 'bs', 'bug', 'bxr', + 'ca', 'cbk-zam', 'cdo', 'ce', 'ceb', 'ch', 'chy', 'cho', 'chr', 'cy', 'ckb', + 'co', 'cr', 'crh', 'cs', 'csb', 'cu', 'cv', 'da', 'de', 'diq', 'dk', 'dsb', 'dv', + 'dz', 'ee', 'el', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'fa', 'ff', 'fi', + 'fy', 'fiu-vro', 'fj', 'fo', 'fr', 'frp', 'frr', 'fur', 'ga', 'gag', 'gan', 'gd', + 'gl', 'glk', 'gn', 'got', 'gu', 'gv', 'ha', 'hak', 'haw', 'he', 'hi', 'hy', + 'hif', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'yi', + 'ik', 'ilo', 'io', 'yo', 'is', 'it', 'iu', 'ja', 'jbo', 'jv', 'ka', 'kaa', 'kab', + 'kbd', 'kg', 'ki', 'ky', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'koi', 'kr', 'krc', + 'ks', 'ksh', 'ku', 'kv', 'kw', 'la', 'lad', 'lb', 'lbe', 'lez', 'lg', 'li', + 'lij', 'lmo', 'ln', 'lo', 'lt', 'ltg', 'lv', 'map-bms', 'mdf', 'mg', 'mh', 'mhr', + 'mi', 'my', 'min', 'myv', 'mk', 'ml', 'mn', 'mo', 'mr', 'mrj', 'ms', 'mt', 'mus', + 'mwl', 'mzn', 'na', 'nah', 'nan', 'nap', 'nds', 'nds-nl', 'ne', 'new', 'ng', 'ny', + 'nl', 'nn', 'no', 'nov', 'nrm', 'nso', 'nv', 'oc', 'om', 'or', 'os', 'pa', 'pag', + 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pi', 'pih', 'pl', 'pms', 'pnb', 'pnt', 'ps', + 'pt', 'qu', 'rm', 'rmy', 'rn', 'ro', 'roa-rup', 'roa-tara', 'ru', 'rue', 'rw', + 'sa', 'sah', 'sc', 'scn', 'sco', 'sd', 'se', 'sg', 'sh', 'shi', 'si', 'simple', + 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'srn', 'ss', 'st', 'stq', 'su', 'sv', + 'sw', 'szl', 'ta', 'te', 'tet', 'tg', 'th', 'ti', 'ty', 'tk', 'tl', 'tn', 'to', + 'tokipona', 'tp', 'tpi', 'tr', 'ts', 'tt', 'tum', 'tw', 'udm', 'ug', 'uk', 'ur', + 'uz', 've', 'vec', 'vep', 'vi', 'vls', 'vo', 'wa', 'war', 'wo', 'wuu', 'xal', + 'xh', 'xmf', 'za', 'zea', 'zh', 'zh-classical', 'zh-cn', 'zh-yue', 'zh-min-nan', + 'zh-tw', 'zu' + ), ); diff --git a/client/includes/InterwikiSorter.php b/client/includes/InterwikiSorter.php index 7313bb8..f4955be 100644 --- a/client/includes/InterwikiSorter.php +++ b/client/includes/InterwikiSorter.php @@ -123,26 +123,29 @@ * * @return array */ - protected function buildSortOrder( $sort, array $sortOrders, $sortPrepend ) { + protected function buildSortOrder( $sort, array $sortOrders, array $sortPrepend ) { + if ( !array_key_exists( 'alphabetic', $sortOrders ) ) { + throw new \MWException( 'alphabetic interwiki sorting order is missing from Wikibase Client settings.' ); + } + $sortOrder = $sortOrders['alphabetic']; if ( $sort === 'alphabetic' ) { // do nothing - } else if ( $sort === 'alphabetic_revised' ) { - $sortOrder = $sortOrders['alphabetic_revised']; - } else if ( $sort === 'alphabetic_sr' ) { - $sortOrder = $sortOrders['alphabetic_sr'];
[MediaWiki-commits] [Gerrit] Revert "(bug 45037) show edit link only if we have repo links" - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Revert "(bug 45037) show edit link only if we have repo links" .. Revert "(bug 45037) show edit link only if we have repo links" This reverts commit 565a31e8fea276dd73f93854665fdb1632b3b8a1 Change-Id: Icdaef93dc05aff3b8eade06e542cc830b2e21eeb --- M client/WikibaseClient.hooks.php M client/WikibaseClient.php M client/includes/ClientUtils.php M client/includes/LangLinkHandler.php M client/includes/recentchanges/ExternalChangesLine.php 5 files changed, 66 insertions(+), 153 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index f5b4756..659dec8 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -602,43 +602,12 @@ } /** -* Add output page property if repo links are suppressed, and property for item id -* -* @since 0.4 -* -* @param \OutputPage &$out -* @param \ParserOutput $pout -* -* @return bool -*/ - public static function onOutputPageParserOutput( \OutputPage &$out, \ParserOutput $pout ) { - $langLinkHandler = new LangLinkHandler( - Settings::get( 'siteGlobalID' ), - Settings::get( 'namespaces' ), - Settings::get( 'excludeNamespaces' ), - ClientStoreFactory::getStore()->newSiteLinkTable(), - \Sites::singleton() ); - - $noExternalLangLinks = $langLinkHandler->getNoExternalLangLinks( $pout ); - if ( $noExternalLangLinks !== array() ) { - $out->setProperty( 'noexternallanglinks', $noExternalLangLinks ); - } - - $itemId = $pout->getProperty( 'wikibase_item' ); - if ( $itemId !== false ) { - $out->setProperty( 'wikibase_item', $itemId ); - } - - return true; - } - - /** * Displays a list of links to pages on the central wiki at the end of the language box. -* -* @since 0.1 * * @param \Skin $skin * @param \QuickTemplate $template +* +* @since 0.1 * * @return bool */ @@ -646,38 +615,34 @@ wfProfileIn( __METHOD__ ); $title = $skin->getContext()->getTitle(); - $namespaceChecker = new NamespaceChecker( - Settings::get( 'excludeNamespaces' ), - Settings::get( 'namespaces' ) - ); + if ( !in_array( $title->getNamespace(), Settings::get( 'excludeNamespaces' ) ) && $title->exists() ) { -if ( $title->exists() && $namespaceChecker->isWikibaseEnabled( $title->getNamespace() ) ) { if ( empty( $template->data['language_urls'] ) && \Action::getActionName( $skin->getContext() ) === 'view' ) { - $noExternalLangLinks = $skin->getOutput()->getProperty( 'noexternallanglinks' ); - - if ( $noExternalLangLinks !== null && !in_array( '*', $noExternalLangLinks ) ) { - // Placeholder in case the page doesn't have any langlinks yet - // self::onBeforePageDisplay adds the JavaScript module which will overwrite this with a link - $template->data['language_urls'][] = array( - 'text' => '', - 'id' => 'wbc-linkToItem', - 'class' => 'wbc-editpage wbc-nolanglinks', - ); - } + // Placeholder in case the page doesn't have any langlinks yet + // self::onBeforePageDisplay adds the JavaScript module which will overwrite this with a link + $template->data['language_urls'][] = array( + 'text' => '', + 'id' => 'wbc-linkToItem', + 'class' => 'wbc-editpage wbc-nolanglinks', + ); wfProfileOut( __METHOD__ ); return true; } - $itemId = $skin->getOutput()->getProperty( 'wikibase_item' ); + $title = $skin->getContext()->getTitle(); - if ( $itemId !== null ) { - $itemNamespace = ClientUtils::getNamespace( Item::ENTITY_TYPE, tr
[MediaWiki-commits] [Gerrit] Moved ClaimSaver and ExceptionWithCode to their own files - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Moved ClaimSaver and ExceptionWithCode to their own files .. Moved ClaimSaver and ExceptionWithCode to their own files Change-Id: I266f251a243651836d095cee12eaf3ef39ddff87 --- M repo/Wikibase.php A repo/includes/ClaimSaver.php A repo/includes/ExceptionWithCode.php M repo/includes/api/SetClaim.php 4 files changed, 242 insertions(+), 227 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 47b7488..822c046 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -97,6 +97,7 @@ // includes $wgAutoloadClasses['Wikibase\Autocomment'] = $dir . 'includes/Autocomment.php'; $wgAutoloadClasses['Wikibase\CachingEntityLoader'] = $dir . 'includes/CachingEntityLoader.php'; +$wgAutoloadClasses['Wikibase\ClaimSaver'] = $dir . 'includes/ClaimSaver.php'; $wgAutoloadClasses['Wikibase\DataTypeSelector']= $dir . 'includes/DataTypeSelector.php'; $wgAutoloadClasses['Wikibase\Repo\DBConnectionProvider'] = $dir . 'includes/DBConnectionProvider.php'; $wgAutoloadClasses['Wikibase\EditEntity'] = $dir . 'includes/EditEntity.php'; @@ -104,6 +105,7 @@ $wgAutoloadClasses['Wikibase\ItemContentDiffView'] = $dir . 'includes/ItemContentDiffView.php'; $wgAutoloadClasses['Wikibase\ItemDisambiguation'] = $dir . 'includes/ItemDisambiguation.php'; $wgAutoloadClasses['Wikibase\EntityView'] = $dir . 'includes/EntityView.php'; +$wgAutoloadClasses['Wikibase\ExceptionWithCode'] = $dir . 'includes/ExceptionWithCode.php'; $wgAutoloadClasses['Wikibase\ItemView']= $dir . 'includes/ItemView.php'; $wgAutoloadClasses['Wikibase\LabelDescriptionDuplicateDetector'] = $dir . 'includes/LabelDescriptionDuplicateDetector.php'; $wgAutoloadClasses['Wikibase\Repo\LazyDBConnectionProvider'] = $dir . 'includes/LazyDBConnectionProvider.php'; diff --git a/repo/includes/ClaimSaver.php b/repo/includes/ClaimSaver.php new file mode 100644 index 000..38a7e7d --- /dev/null +++ b/repo/includes/ClaimSaver.php @@ -0,0 +1,175 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @since 0.4 + * + * @ingroup WikibaseRepo + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class ClaimSaver { + + /** +* @see ApiBase::execute +* +* @since 0.4 +* +* @param Claim $claim +* @param int|null $baseRevId +* @param string $token +* @param User $user +* +* @return int +*/ + public function saveClaim( Claim $claim, $baseRevId, $token, User $user ) { + $entityId = $this->getEntityIdForClaim( $claim ); + + $content = $this->getEntityContent( $entityId, $baseRevId ); + + $this->updateClaim( $content->getEntity(), $claim ); + + $newRevisionId = $this->saveChanges( $content, $baseRevId, $token, $user ); + + return $newRevisionId; + } + + /** +* @param Claim $claim +* +* @return EntityId +* @throws ExceptionWithCode +*/ + protected function getEntityIdForClaim( Claim $claim ) { + $guid = $claim->getGuid(); + + if ( $guid === null ) { + throw new ExceptionWithCode( 'The ID of the claim needs to be set', 'setclaim-no-guid' ); + } + + try { + $entityId = Entity::getIdFromClaimGuid( $guid ); + } + catch ( MWException $exception ) { + throw new ExceptionWithCode( $exception->getMessage(), 'setclaim-invalid-guid' ); + } + + $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); + $idParser = $libRegistry->getEntityIdParser(); + + $parseResult = $idParser->parse( $entityId ); + + if ( $parseResult->isValid() ) { + $entityId = $parseResult->getValue(); + assert( $entityId instanceof EntityId ); + return $entityId; + } + + throw new ExceptionWithCode( $parseResult->getError()->getText(), 'setclaim-invalid-guid' ); + } + + /** +* @since 0.4 +* +* @param Entity $entity +* @param Claim $claim +*/ + protected function updateClaim( Entity $entity, Claim $claim ) { + $claims = new \Wikibase\Claims( $entity->getClaims() ); + + if ( $claims->hasClaimWithGuid( $claim->getGuid() ) ) { + $claims->removeClaimWith
[MediaWiki-commits] [Gerrit] (bug 45037) show edit link only if we have repo links - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (bug 45037) show edit link only if we have repo links .. (bug 45037) show edit link only if we have repo links This also fixes bug 44536 to have Q### links instead of link via Special:ItemByTitle This patch adds parser output and output page properties that indicate: 1) userepolinks: if a page uses repo links... e.g. they've been suppressed or not. if not, it considers if the page is associated with the repo and has links. 2) wikibase_item: the associated prefixed item id, added regardless if userepolinks is true or not. Then it's easier and more efficient for the code to determine whether or not to add "edit links" link and build the link to the associated item. Change-Id: I9bcf497f23b3d28f58fda964d74b7097b28aac2b --- M client/WikibaseClient.hooks.php M client/WikibaseClient.php M client/includes/ClientUtils.php M client/includes/LangLinkHandler.php M client/includes/recentchanges/ExternalChangesLine.php 5 files changed, 153 insertions(+), 66 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index 659dec8..f5b4756 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -602,12 +602,43 @@ } /** +* Add output page property if repo links are suppressed, and property for item id +* +* @since 0.4 +* +* @param \OutputPage &$out +* @param \ParserOutput $pout +* +* @return bool +*/ + public static function onOutputPageParserOutput( \OutputPage &$out, \ParserOutput $pout ) { + $langLinkHandler = new LangLinkHandler( + Settings::get( 'siteGlobalID' ), + Settings::get( 'namespaces' ), + Settings::get( 'excludeNamespaces' ), + ClientStoreFactory::getStore()->newSiteLinkTable(), + \Sites::singleton() ); + + $noExternalLangLinks = $langLinkHandler->getNoExternalLangLinks( $pout ); + if ( $noExternalLangLinks !== array() ) { + $out->setProperty( 'noexternallanglinks', $noExternalLangLinks ); + } + + $itemId = $pout->getProperty( 'wikibase_item' ); + if ( $itemId !== false ) { + $out->setProperty( 'wikibase_item', $itemId ); + } + + return true; + } + + /** * Displays a list of links to pages on the central wiki at the end of the language box. +* +* @since 0.1 * * @param \Skin $skin * @param \QuickTemplate $template -* -* @since 0.1 * * @return bool */ @@ -615,34 +646,38 @@ wfProfileIn( __METHOD__ ); $title = $skin->getContext()->getTitle(); - if ( !in_array( $title->getNamespace(), Settings::get( 'excludeNamespaces' ) ) && $title->exists() ) { + $namespaceChecker = new NamespaceChecker( + Settings::get( 'excludeNamespaces' ), + Settings::get( 'namespaces' ) + ); +if ( $title->exists() && $namespaceChecker->isWikibaseEnabled( $title->getNamespace() ) ) { 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 - $template->data['language_urls'][] = array( - 'text' => '', - 'id' => 'wbc-linkToItem', - 'class' => 'wbc-editpage wbc-nolanglinks', - ); + $noExternalLangLinks = $skin->getOutput()->getProperty( 'noexternallanglinks' ); + + if ( $noExternalLangLinks !== null && !in_array( '*', $noExternalLangLinks ) ) { + // Placeholder in case the page doesn't have any langlinks yet + // self::onBeforePageDisplay adds the JavaScript module which will overwrite this with a link + $template->data['language_urls'][] = array( + 'text' => '', + 'id' => 'wbc-linkToItem', + 'class' => 'wbc-editpage wbc-nolanglinks', +
[MediaWiki-commits] [Gerrit] (Bug 43994) New Special:UnconnectedPages - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/53381 Change subject: (Bug 43994) New Special:UnconnectedPages .. (Bug 43994) New Special:UnconnectedPages This special page "Special:UnconnectedPages" uses a page prop "wikibase_item" that holds the id for the item at the repository. Later it could be other tables that are better suited, and updated faster, than the page_props table. Change-Id: I5cfab43ee8c7feff79c8b4bda0183142dc3e2c98 --- A client/WikibaseClient.i18n.alias.php M client/WikibaseClient.i18n.php M client/WikibaseClient.php A client/includes/specials/SpecialUnconnectedPages.php 4 files changed, 312 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/81/53381/1 diff --git a/client/WikibaseClient.i18n.alias.php b/client/WikibaseClient.i18n.alias.php new file mode 100644 index 000..61ad70d --- /dev/null +++ b/client/WikibaseClient.i18n.alias.php @@ -0,0 +1,20 @@ + + */ + +$specialPageAliases = array(); + +/** English (English) */ +$specialPageAliases['en'] = array( + 'UnconnectedPages' => array( 'UnconnectedPages', 'WithoutConnection', 'WithoutSitelinks' ), +); \ No newline at end of file diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php index 606d3b4..669f3d0 100644 --- a/client/WikibaseClient.i18n.php +++ b/client/WikibaseClient.i18n.php @@ -18,9 +18,11 @@ * @author Jeroen De Dauw * @author Nikola Smolenski * @author Marius Hoch + * @author Jeblad */ $messages['en'] = array( 'wikibase-client-desc' => 'Client for the Wikibase extension', + 'specialpages-group-wikibaseclient' => 'Wikidata client', 'wikibase-after-page-move' => 'You may also [$1 update] the associated Wikidata item to maintain language links on moved page.', 'wikibase-comment-remove' => 'Associated Wikidata item deleted. Language links removed.', 'wikibase-comment-linked' => 'A Wikidata item has been linked to this page.', @@ -52,6 +54,14 @@ 'wikibase-rc-hide-wikidata' => '$1 Wikidata', 'wikibase-rc-show-wikidata-pref' => 'Show Wikidata edits in recent changes', 'wikibase-watchlist-show-changes-pref' => 'Show Wikidata edits in your watchlist', + 'special-unconnectedpages' => 'Pages not connected to items', + 'wikibase-unconnectedpages-legend' => 'Unconnected pages options', + 'wikibase-unconnectedpages-page' => 'Start page:', + 'wikibase-unconnectedpages-submit' => 'Go', + '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)', ); /** Message documentation (Message documentation) @@ -66,6 +76,7 @@ $messages['qqq'] = array( 'wikibase-client-desc' => '{{desc|name=Wikibase Client|url=http://www.mediawiki.org/wiki/Extension:Wikibase_Client}} See also [[d:Wikidata:Glossary#Wikidata|Wikidata]].', + 'specialpages-group-wikibaseclient' => 'Title of group of special pages related to Wikidata clients', 'wikibase-after-page-move' => 'Message on [[Special:MovePage]] on submit and successfully move, inviting user to update associated Wikibase repository item to maintain language links on the moved page on the client. Parameters: @@ -130,6 +141,14 @@ * $1 - a link with the text {{msg-mw|show}} or {{msg-mw|hide}}', 'wikibase-rc-show-wikidata-pref' => 'Option in the recent changes section of preferences to show wikibase changes by default in recent changes.', 'wikibase-watchlist-show-changes-pref' => 'Option in the watchlist section of preferences to always show wikibase edits by default in the watchlist.', + 'special-unconnectedpages' => 'Title of the special page for listing unconnected items.', + 'wikibase-unconnectedpages-page-warning' => 'The title that is typed in could not be used of some kind of reason. This can happen for example when the title has an interwiki prefix to another language, or a namespace that is not used for Wikibase entities.', + 'wikibase-unconnectedpages-iwdata-label' => 'Text for the checkbox. Should say that only pages without interlanguage-links should be listed.', + 'wikibase-unconnectedpages-legend' => 'Legend for the options box at the special page for pages not connected to sitelinks.', + 'wikibase-unconnectedpages-page' => 'Label for the start page field in the options box of the special page for pages not connected to sitelinks.', + 'wikibase-unconnectedpages-submit' => 'Text for the submit button in the options box of the special page for pages not connected to site
[MediaWiki-commits] [Gerrit] Make WikiPageEntityLookup work on installs with a table prefix - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Make WikiPageEntityLookup work on installs with a table prefix .. Make WikiPageEntityLookup work on installs with a table prefix bug 43229 Change-Id: Ia465208d2c4239e4ce72f23addb51d248da62cb2 --- M lib/includes/store/WikiPageEntityLookup.php 1 file changed, 5 insertions(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/lib/includes/store/WikiPageEntityLookup.php b/lib/includes/store/WikiPageEntityLookup.php index fbdddf2..d344806 100644 --- a/lib/includes/store/WikiPageEntityLookup.php +++ b/lib/includes/store/WikiPageEntityLookup.php @@ -151,7 +151,11 @@ 'text' ); - $vars = 'page.*, revision.*, text.*'; + $pageTable = $db->tableName( 'page' ); + $revisionTable = $db->tableName( 'revision' ); + $textTable = $db->tableName( 'text' ); + + $vars = "$pageTable.*, $revisionTable.*, $textTable.*"; $where = array(); $join = array(); -- To view, visit https://gerrit.wikimedia.org/r/53351 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia465208d2c4239e4ce72f23addb51d248da62cb2 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: 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 45821) Fix prev diff link to work in special:contributi... - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: (bug 45821) Fix prev diff link to work in special:contributions etc. .. (bug 45821) Fix prev diff link to work in special:contributions etc. Change-Id: I84648b1ef5d595d1f95883c5f1864878b549849e --- M repo/includes/actions/ViewEntityAction.php 1 file changed, 16 insertions(+), 5 deletions(-) Approvals: John Erling Blad: Verified; Looks good to me, approved diff --git a/repo/includes/actions/ViewEntityAction.php b/repo/includes/actions/ViewEntityAction.php index 165c26e..b8074ca 100644 --- a/repo/includes/actions/ViewEntityAction.php +++ b/repo/includes/actions/ViewEntityAction.php @@ -32,19 +32,30 @@ /** * Returns the content of the page in the revision being viewed. * +* @todo split out the get revision id stuff, add tests and see if +* any core code can be shared here +* * @return EntityContent|null */ protected function getContent() { $queryValues = $this->getRequest()->getQueryValues(); - $revisionId = 0; + $title = $this->getTitle(); + $revisionId = array_key_exists( 'oldid', $queryValues ) && is_int( $queryValues['oldid'] ) ? + $queryValues['oldid'] : $title->getLatestRevID(); if ( array_key_exists( 'diff', $queryValues ) ) { - $revisionId = $queryValues[ 'diff' ]; - } elseif ( array_key_exists( 'oldid', $queryValues ) ) { - $revisionId = $queryValues[ 'oldid' ]; + $diffValue = $queryValues['diff']; + + if ( $diffValue === 'prev' ) { + $revisionId = $title->getPreviousRevisionID( $revisionId ); + } else if ( $diffValue === 'next' ) { + $revisionId = $title->getNextRevisionID( $revisionId ); + } else { + $revisionId = intval( $diffValue ); + } } - $revision = \Revision::newFromTitle( $this->getTitle(), $revisionId ); + $revision = \Revision::newFromTitle( $title, $revisionId ); if ( $revision !== null ) { return $revision->getContent(); -- To view, visit https://gerrit.wikimedia.org/r/53147 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I84648b1ef5d595d1f95883c5f1864878b549849e Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude Gerrit-Reviewer: Aude Gerrit-Reviewer: Daniel Kinzler 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] Remove unused argument in method call - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/53156 Change subject: Remove unused argument in method call .. Remove unused argument in method call Change-Id: I9d9615360212f865f7d3aada26af8cea6ea3e9f4 --- M repo/maintenance/pruneChanges.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/56/53156/1 diff --git a/repo/maintenance/pruneChanges.php b/repo/maintenance/pruneChanges.php index 40cbe98..9ee56b6 100644 --- a/repo/maintenance/pruneChanges.php +++ b/repo/maintenance/pruneChanges.php @@ -58,7 +58,7 @@ exit( 5 ); } - $this->pruneChanges( $numDays, $force ); + $this->pruneChanges( $numDays ); $this->output( date( 'H:i:s' ) . " done, exiting\n" ); unlink( $pidfile ); // delete lockfile on normal exit -- To view, visit https://gerrit.wikimedia.org/r/53156 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9d9615360212f865f7d3aada26af8cea6ea3e9f4 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 45881) Stop use of entity ids with wrong prefix - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52876 Change subject: (Bug 45881) Stop use of entity ids with wrong prefix .. (Bug 45881) Stop use of entity ids with wrong prefix Change-Id: Iafaca93b79d5ee2d7b9cd72d2a24fae5ba0f8d51 --- M repo/includes/api/SearchEntities.php 1 file changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/76/52876/1 diff --git a/repo/includes/api/SearchEntities.php b/repo/includes/api/SearchEntities.php index 2da7df9..4a67303 100644 --- a/repo/includes/api/SearchEntities.php +++ b/repo/includes/api/SearchEntities.php @@ -69,7 +69,7 @@ 'LIMIT' => $limit, ) ); - +wfDebug(">" . print_r($ids,true)); wfProfileOut( __METHOD__ ); return $ids; } @@ -98,12 +98,12 @@ $page = EntityContentFactory::singleton()->getWikiPageForId( $entityId ); if ( $page->exists() ) { $entityContent = $page->getContent(); - if ( $entityContent instanceof \Wikibase\EntityContent ) { + if ( ( $entityContent instanceof \Wikibase\EntityContent ) && ( $entityContent->getEntity()->getType() === $params['type'] ) ) { $ids[] = $entityId; } } } - + // If still space, then merge in exact matches if ( count( $ids ) < $limit ) { $ids = array_merge( $ids, $this->searchEntities( $params['language'], $params['search'], $params['type'], $limit, false ) ); @@ -115,6 +115,7 @@ $ids = array_merge( $ids, $this->searchEntities( $params['language'], $params['search'], $params['type'], $limit, true ) ); $ids = array_unique( $ids ); } + // reduce any overflow $ids = array_slice ( $ids, 0, $limit ); -- To view, visit https://gerrit.wikimedia.org/r/52876 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iafaca93b79d5ee2d7b9cd72d2a24fae5ba0f8d51 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 44940) Add fragment to sitelink - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52799 Change subject: (Bug 44940) Add fragment to sitelink .. (Bug 44940) Add fragment to sitelink Change-Id: I62371b1952feb1edf67b2272fc2e109569b9bf23 --- M client/WikibaseClient.hooks.php 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/99/52799/1 diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index 659dec8..b8dcfab 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -642,7 +642,10 @@ if ( $itemId ) { // links to the special page $template->data['language_urls'][] = array( - 'href' => ClientUtils::repoArticleUrl( "Special:ItemByTitle/$siteId/" . wfUrlencode( $title->getPrefixedDBkey() ) ), + 'href' => ClientUtils::repoArticleUrl( + "Special:ItemByTitle/$siteId/" + . wfUrlencode( $title->getPrefixedDBkey() ) + . '#q' . $itemId . '/sitelinks' ), 'text' => wfMessage( 'wikibase-editlinks' )->text(), 'title' => wfMessage( 'wikibase-editlinkstitle' )->text(), 'class' => 'wbc-editpage', -- To view, visit https://gerrit.wikimedia.org/r/52799 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I62371b1952feb1edf67b2272fc2e109569b9bf23 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 44876) Add toc to EntityView - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52796 Change subject: (Bug 44876) Add toc to EntityView .. (Bug 44876) Add toc to EntityView Change-Id: I2fe93fb732a29e0659b00584aaf853067e2f9313 --- M lib/WikibaseLib.i18n.php M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/templates.php M repo/Wikibase.i18n.php M repo/includes/EntityView.php M repo/includes/ItemView.php M repo/includes/PropertyView.php M repo/resources/wikibase.ui.entityViewInit.js 8 files changed, 192 insertions(+), 37 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/96/52796/1 diff --git a/lib/WikibaseLib.i18n.php b/lib/WikibaseLib.i18n.php index 73b9374..c0ec89e 100644 --- a/lib/WikibaseLib.i18n.php +++ b/lib/WikibaseLib.i18n.php @@ -48,7 +48,14 @@ 'wikibase-tooltip-error-details' => 'Details', 'datatypes-type-wikibase-item' => 'Item', 'datatypes-type-commonsMedia' => 'Commons media file', -); + + // toc stuff + 'wikibase-toc-title' => 'Contents', + 'wikibase-toc-section-other' => 'Other languages', + 'wikibase-toc-section-statements' => 'Statements', + 'wikibase-toc-section-sitelinks' => 'Sitelinks', + 'wikibase-toc-section-datatype' => 'Datatype', + ); /** Message documentation (Message documentation) * @author Amire80 @@ -100,6 +107,14 @@ 'datatypes-type-wikibase-item' => 'The name of a data type for items in Wikibase. {{Identical|Item}}', 'datatypes-type-commonsMedia' => 'The name of a data type for media files on Wikimedia Commons (proper name, capitalised in English; first letter capitalised anyway in this message and relatives).', + + // toc stuff + 'wikibase-toc-title' => 'Overall header on the "Table of Contents".', + 'wikibase-toc-section-other' => 'Section header in the "Table of Contents" for the section "In other languages".', + 'wikibase-toc-section-statements' => 'Section header in the "Table of Contents" for the section "Statements".', + 'wikibase-toc-section-sitelinks' => 'Section header in the "Table of Contents" for the section "Sitelinks".', + 'wikibase-toc-section-datatype' => 'Section header in the "Table of Contents" for the section "Datatype". Note that this section does not have a proper header.', + ); /** Asturian (asturianu) diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index 0767b63..867c62c 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -42,7 +42,10 @@ var entity = this.option( 'value' ), $claimsHeading = - $( mw.template( 'wb-section-heading', mw.msg( 'wikibase-statements' ) ) ); + $( mw.template( 'wb-section-heading', + mw.msg( 'wikibase-statements' ), + entity.getId(), + 'statements' ) ); this.$claims = $( '' ).claimlistview( { value: entity.getClaims(), diff --git a/lib/resources/templates.php b/lib/resources/templates.php index 8e7bda6..ca5c49c 100644 --- a/lib/resources/templates.php +++ b/lib/resources/templates.php @@ -35,13 +35,34 @@ $2 $3 -$4 -$5 +$4 +$5 +$6 +HTML; + + $templates['wb-entity-toc'] = +<< + + + +$1 + + +$2 + + + +HTML; + + $templates['wb-entity-toc-entry'] = +<<$1 $4 HTML; $templates['wb-section-heading'] = <<$1 +$1 HTML; // TODO: rename this to 'wb-claimlist' or 'wb-claims' (in which case the widget should also be renamed) @@ -209,7 +230,7 @@ $templates['wb-terms-heading'] = <<$1 + $1 HTML; $templates['wb-terms-table'] = @@ -320,7 +341,7 @@ $templates['wb-property-datatype'] = << + $1 $2 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 9c3435f..679907b 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -40,6 +40,7 @@ 'wikibase-alias-edit-placeholder' => 'enter an alias', 'wikibase-label-input-help-message' => 'Enter the title of this data set in $1.', 'wikibase-description-input-help-message' => 'Enter a short description in $1.', + 'wikibase-datatype' => 'Datatype', 'wikibase-statements' => 'Statements', 'wikibase-terms' => 'In other languages', 'wikibase-sitelinks-add' => 'add a link to a site-link', @@ -351,6 +352,7 @@ 'right-label-update' => 'Update labels', 'right-description-remove' => 'Remove descriptions', 'right-description-update' => 'Update descriptions', + ); /** Messa
[MediaWiki-commits] [Gerrit] Back to weird title - change (mediawiki...Wikibase)
John Erling Blad has submitted this change and it was merged. Change subject: Back to weird title .. Back to weird title In some part of the extension we are using words that simply don't fit what we are doing, but some of the weird wording has stuck somehow. In ItemByTitle we are really talking about a sitelink to an external site, with a pair of site id and a title on the external site, not about a single title. The last would be a local page. Change-Id: I40f69948036cec605dc0aa342084d884a003dd50 --- M repo/Wikibase.i18n.php 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: John Erling Blad: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 9c3435f..4ba5532 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -113,7 +113,7 @@ 'wikibase-itemlink-title' => '$1 | $2', // Special pages - 'special-itembytitle' => 'Item by sitelink', + 'special-itembytitle' => 'Item by title', 'wikibase-itembytitle-lookup-fieldset' => 'Search for items by site and title', 'wikibase-itembytitle-lookup-site' => 'Site:', 'wikibase-itembytitle-lookup-page' => 'Page:', -- To view, visit https://gerrit.wikimedia.org/r/52629 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I40f69948036cec605dc0aa342084d884a003dd50 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] Back to weird title - change (mediawiki...Wikibase)
John Erling Blad has uploaded a new change for review. https://gerrit.wikimedia.org/r/52629 Change subject: Back to weird title .. Back to weird title In some part of the extension we are using words that simply don't fit what we are doing, but some of the weird wording has stuck somehow. In ItemByTitle we are really talking about a sitelink to an external site, with a pair of site id and a title on the external site, not about a single title. The last would be a local page. Change-Id: I40f69948036cec605dc0aa342084d884a003dd50 --- M repo/Wikibase.i18n.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/29/52629/1 diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php index 9c3435f..4ba5532 100644 --- a/repo/Wikibase.i18n.php +++ b/repo/Wikibase.i18n.php @@ -113,7 +113,7 @@ 'wikibase-itemlink-title' => '$1 | $2', // Special pages - 'special-itembytitle' => 'Item by sitelink', + 'special-itembytitle' => 'Item by title', 'wikibase-itembytitle-lookup-fieldset' => 'Search for items by site and title', 'wikibase-itembytitle-lookup-site' => 'Site:', 'wikibase-itembytitle-lookup-page' => 'Page:', -- To view, visit https://gerrit.wikimedia.org/r/52629 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I40f69948036cec605dc0aa342084d884a003dd50 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] 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
[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] 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] 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] 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] 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] 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 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 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] 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 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] 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 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] 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 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] 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] 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] (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] (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] 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] 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 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] 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 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 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 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 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] 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] 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] 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] 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] (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] (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 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 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 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 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] 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] 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] 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] 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