[MediaWiki-commits] [Gerrit] Changed UI text "source" to "reference" - change (mediawiki...Wikibase)

2014-04-17 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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

Change subject: Changed UI text "source" to "reference"
..

Changed UI text "source" to "reference"

Change-Id: I9f8da036aca97cfa16b3ef1cd80b5cc9611a1fd2
---
M docs/json.wiki
M lib/resources/wikibase.css
M repo/i18n/de.json
M repo/i18n/en.json
M repo/i18n/qqq.json
5 files changed, 12 insertions(+), 12 deletions(-)


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

diff --git a/docs/json.wiki b/docs/json.wiki
index 371e515..c08206f 100644
--- a/docs/json.wiki
+++ b/docs/json.wiki
@@ -206,7 +206,7 @@
 }
 
 
-A Claim consists of a main value (or main Snak) and a number of qualifier 
Snaks. A Statement is a Claim that also contains a (possibly empty) list of 
source references.
+A Claim consists of a main value (or main Snak) and a number of qualifier 
Snaks. A Statement is a Claim that also contains a (possibly empty) list of 
references.
 A claim is always associated with a Property (semantically, the Claim is 
''about'' the Property), and there can be multiple Claims about the same 
Property in a single Entity.
 This is represented by a map structure that uses Property IDs as keys, and 
maps them to lists of Claim records.
 
@@ -217,7 +217,7 @@
 * 'mainsnak': If the claim has the type ''value'', it has a 
''mainsnak'' field that contains the Snak representing the value to be 
associated with the property. See [[#Snaks|Snaks]] below. The Property 
specified in the main Snak must be the same as the property the Claim is 
associated with. That is, if a value claim is provided for property P17, its 
main Snak will specify P17 as the property the value is assigned to.
 * '''rank''': Ihe rank expresses whether this value will be used in queries, 
and shown be visible per default on a client system. The value is either 
''preferred'', ''normal'' or ''deprecated''.
 * '''qualifiers''': Qualifiers provide a context for the primary value, such 
as the point in time of measurement. Qualifiers are given as lists of snaks, 
each associated with one property. See [[#Qualifiers|Qualifiers]] below.
-* 'references': If the Claim's type is ''statement'', there may be a 
list of source references, given as a list of reference records. See 
[[#References|References]] below.
+* 'references': If the Claim's type is ''statement'', there may be a 
list of references, given as a list of reference records. See 
[[#References|References]] below.
 
 === Snaks ===
 
@@ -468,7 +468,7 @@
 }
 
 
-References provide provenance/authority information for individual claims. 
Each source reference
+References provide provenance/authority information for individual claims. 
Each reference
 is a set of Snaks structured in a similar way to how qualifiers are 
represented: Snaks about the same
 property are grouped together in a list and made accessible by putting all 
these lists into a map,
 using the property IDs as keys.
diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css
index 7b2d96f..c27e9ac 100644
--- a/lib/resources/wikibase.css
+++ b/lib/resources/wikibase.css
@@ -884,7 +884,7 @@
margin-bottom: 1em;
 }
 
-/* "add source" link */
+/* "add reference" link */
 .wb-statement-references > .wikibase-toolbar {
float: right;
 }
diff --git a/repo/i18n/de.json b/repo/i18n/de.json
index 5f801e5..9260f3c 100644
--- a/repo/i18n/de.json
+++ b/repo/i18n/de.json
@@ -28,7 +28,7 @@
"wikibase-cancel": "abbrechen",
"wikibase-add": "hinzufügen",
"wikibase-addqualifier": "Qualifikator hinzufügen",
-   "wikibase-addreference": "Quelle hinzufügen",
+   "wikibase-addreference": "Beleg hinzufügen",
"wikibase-save-inprogress": "Speichere …",
"wikibase-remove-inprogress": "Entferne …",
"wikibase-label-empty": "Noch keine Bezeichnung angegeben",
@@ -78,8 +78,8 @@
"wikibase-statementview-rank-preferred": "Vorrangig",
"wikibase-statementview-rank-normal": "Normaler Rang",
"wikibase-statementview-rank-deprecated": "Herabgestufter Rang",
-   "wikibase-statementview-referencesheading-pendingcountersubject": 
"{{PLURAL:$1|Quelle|Quellen}}",
-   "wikibase-statementview-referencesheading-pendingcountertooltip": 
"{{PLURAL:$1|Eine Quelle|$1 Quellen}} wurden noch nicht gespeichert",
+   "wikibase-statementview-referencesheading-pendingcountersubject": 
"{{PLURAL:$1|Beleg|Belege}}",
+   "wikibase-statementview-referencesheading-pendingcountertooltip": 
"{{PLURAL:$1|Eine Beleg|$1 Belege}} wurden noch nicht gespeichert",
"wikibase-snakview-property-input-placeholder": "Eigenschaft",
"wikibase-snakview-unsupportedsnaktype": "Snak des Typs „$1“. Das 
Bearbeiten für diese Snakart wird noch nicht unterstützt.",
"wikibase-snakview-choosesnaktype": "Wähle einen Wertetyp aus.",
diff --git a/repo/i18n

[MediaWiki-commits] [Gerrit] Set up configuration for App indexing - change (operations/mediawiki-config)

2014-03-11 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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

Change subject: Set up configuration for App indexing
..

Set up configuration for App indexing

(BUG 60537) Set up app indexing

Change-Id: Ia55be2c4c6f62168440610ffbcb7607e8164c547
---
M wmf-config/InitialiseSettings.php
M wmf-config/mobile.php
2 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/20/118220/1

diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index 542eaf0..3a24cc8 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -11168,6 +11168,10 @@
 'wmgMFEnableSiteNotice' => array(
'default' => true,
 ),
+'wmgMFAppPackageId' => array(
+   'default' => false,
+   'wiki' => 'android-app://org.wikipedia/',
+),
 
 # trademark status
 'wmgMFTrademarkSitename' => array(
diff --git a/wmf-config/mobile.php b/wmf-config/mobile.php
index 8f4ac37..4f124ca 100644
--- a/wmf-config/mobile.php
+++ b/wmf-config/mobile.php
@@ -90,4 +90,11 @@
$wgMFEnablePhotoUploadCTA = $wmgMFEnablePhotoUploadCTA;
$wgMFEnableBetaDiff = $wmgMFEnableBetaDiff;
$wgMFTidyMobileViewSections = false; // experimental
+   
+   if ( $wmgMFAppPackageId ) {
+   $wgMFAppPackageId = $wmgMFAppPackageId;
+   }
+   if ( $wmgMFAppScheme ) {
+   $wgMFAppScheme = $wmgMFAppScheme;
+   }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia55be2c4c6f62168440610ffbcb7607e8164c547
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] (bug 60537) Adds a deep link to a mobile app if so configured - change (mediawiki...MobileFrontend)

2014-02-12 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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

Change subject: (bug 60537) Adds a deep link to a mobile app if so configured
..

(bug 60537) Adds a deep link to a mobile app if so configured

Adds, if an App-ID is configured, a link to the respective
page in order to allow deep linking from the Web to a
mobile app, like the Wikipedia app, as per
https://developers.google.com/app-indexing/webmasters/details
If no App-ID is configured, no link will be created.

Change-Id: Icadc7ab1e050e1e3d28cbd9d41c1b35b42e3fcca
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
2 files changed, 24 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/21/112921/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index a6b6c71..7189123 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -464,3 +464,14 @@
  * Controls whether the "Minerva as a desktop skin" beta feature is enabled
  */
 $wgMFEnableMinervaBetaFeature = false;
+
+/**
+ * ID of the App to deep link to replacing the browser. Set 'false' to have no 
such link.
+ * See https://developers.google.com/app-indexing/webmasters/details
+ */
+$wgMFAppPackageId = false;
+
+/**
+ * Scheme to use for the deep link. Per default, 'http' is used.
+ */
+$wgMFAppScheme = 'http';
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index f4b2afe..d549d6b 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -510,10 +510,22 @@
 * @return bool
 */
public static function onBeforePageDisplay( &$out, &$sk ) {
-   global $wgMFEnableXAnalyticsLogging;
+   global $wgMFEnableXAnalyticsLogging,
+ $wgMFAppPackageId, $wgMFAppScheme;;
wfProfileIn( __METHOD__ );
 
$context = MobileContext::singleton();
+
+   # Add deep link to a mobile app specified by $wgMFAppScheme
+   if ( $wgMFAppPackageId !== false ) {
+   $scheme = isset($wgMFAppScheme) ? $wgMFAppScheme : 
'http';
+   $title = $sk->getTitle();
+   $path = $title->getFullURL( $args );
+   $path = $context->getMobileUrl( $path );
+   $hreflink = 'android-app://' . $wgMFAppPackageId . '/' 
. $scheme . '/' . $path;
+   $out->addLink( array( 'rel' => 'alternate', 'href' => 
$hreflink ) );
+   }
+
if ( !$context->shouldDisplayMobileView() ) {
if ( class_exists( 'BetaFeatures' ) &&
BetaFeatures::isFeatureEnabled( 
$out->getSkin()->getUser(), 'betafeatures-geonotahack' ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icadc7ab1e050e1e3d28cbd9d41c1b35b42e3fcca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 
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 script to upload Freebase identifiers - change (pywikibot/core)

2013-12-04 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: Added script to upload Freebase identifiers
..

Added script to upload Freebase identifiers

Change-Id: I9d1f459d58da0eecd1631e8b863129d9d1aa3a85
---
A scripts/freebasemappingupload.py
1 file changed, 92 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/80/99180/1

diff --git a/scripts/freebasemappingupload.py b/scripts/freebasemappingupload.py
new file mode 100644
index 000..888988f
--- /dev/null
+++ b/scripts/freebasemappingupload.py
@@ -0,0 +1,92 @@
+# -*- coding: utf-8  -*-
+# script to upload the mappings of Freebase to Wikidata
+# can be easily adapted to upload other String identifiers as well
+# author: Denny Vrandecic, 2013
+# distributed under MIT license
+import pywikibot, gzip, re
+
+site = pywikibot.Site('wikidata', 'wikidata')
+repo = site.data_repository()
+
+output = open('output.txt', 'w')
+
+# for logging
+def out(text) :
+  output.write(text + "\n")
+  print(text)
+
+count = 0
+for line in gzip.open('fb2w.nt.gz') : # XXX has to point to the mapping file
+# can be downloaded here: 
https://developers.google.com/freebase/data#freebase-wikidata-mappings
+
+  # check if there is a stop in emergency
+  # XXX can be used to stop the bot by anyone. Should be advertised.
+  #emergencypage = pywikibot.Page(site, 'User:BotAccount/Emergency')
+  #emergencytext = emergencypage.get()
+  #if re.search('stop', emergencytext, re.IGNORECASE) :
+#out('ec0 - stop! the emergency page was used')
+#break
+
+  count += 1
+  if line.startswith('#') or line.strip() == '' :
+continue
+  mid,sameas,qid,dot = line.strip().split()
+  if sameas != '' :
+continue
+  if dot != '.' :
+continue
+  if not mid.startswith('

[MediaWiki-commits] [Gerrit] allow URLs for sources\n\nChange-Id: I5f65e8ce51fe7f34b66bc8... - change (pywikibot/core)

2013-11-27 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: allow URLs for sources\n\nChange-Id: 
I5f65e8ce51fe7f34b66bc8dfaa920209c087055a
..

allow URLs for sources\n\nChange-Id: I5f65e8ce51fe7f34b66bc8dfaa920209c087055a

Change-Id: I0bbbd18710be86263e923d592d48ced010063530
---
M pywikibot/site.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/18/98018/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index cf4c0fa..33fdd11 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3759,7 +3759,7 @@
 datavalue = {'type': 'wikibase-entityid',
  'value': sourceclaim._formatDataValue(),
  }
-elif sourceclaim.getType() == 'string':
+elif sourceclaim.getType() in ['string', 'url']:
 datavalue = {'type': 'string',
  'value': sourceclaim._formatDataValue(),
  }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0bbbd18710be86263e923d592d48ced010063530
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] Catching errors on rebuilding - change (mediawiki...Wikibase)

2013-07-26 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: Catching errors on rebuilding
..

Catching errors on rebuilding

Change-Id: Ic90c7cacfe51148547be4f9fddedae3b82c279b1
---
M repo/includes/store/sql/SqlStore.php
1 file changed, 6 insertions(+), 1 deletion(-)


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

diff --git a/repo/includes/store/sql/SqlStore.php 
b/repo/includes/store/sql/SqlStore.php
index ee8d3fa..0d6905a 100644
--- a/repo/includes/store/sql/SqlStore.php
+++ b/repo/includes/store/sql/SqlStore.php
@@ -1,6 +1,7 @@
 page_id );
$revision = \Revision::newFromId( $pageRow->page_latest 
);
-   $page->doEditUpdates( $revision, $GLOBALS['wgUser'] );
+   try {
+   $page->doEditUpdates( $revision, 
$GLOBALS['wgUser'] );
+   } catch (DBQueryError $e) {
+   wfLogWarning( 'editUpdateFailed for ' . 
$page->getId() . ' on revision ' . $revision->getId() );
+   }
}
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic90c7cacfe51148547be4f9fddedae3b82c279b1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] Removed failing test for illegal time value - change (mediawiki...Wikibase)

2013-07-25 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: Removed failing test for illegal time value
..

Removed failing test for illegal time value

Change-Id: Ie69992976344874e79f6c6163cd9e69c835ac3f7
---
M lib/tests/phpunit/WikibaseDataTypeBuildersTest.php
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/lib/tests/phpunit/WikibaseDataTypeBuildersTest.php 
b/lib/tests/phpunit/WikibaseDataTypeBuildersTest.php
index 5944eb9..751b093 100644
--- a/lib/tests/phpunit/WikibaseDataTypeBuildersTest.php
+++ b/lib/tests/phpunit/WikibaseDataTypeBuildersTest.php
@@ -122,7 +122,7 @@
//time['time']
//NOTE: The below will fail with a 
IllevalValueExcpetion once the TimeValue constructor enforces the time format.
//  Once that is done, this test and the respective 
validator can and should both be removed.
-   array( 'string', new TimeValue( '2013-06-06 11:22:33', 
0, 0, 0, 0, 'http://acme.com/calendar' ), false, 'time: not ISO 8601' ),
+   //array( 'string', new TimeValue( '2013-06-06 
11:22:33', 0, 0, 0, 0, 'http://acme.com/calendar' ), false, 'time: not ISO 
8601' ),
 
//TODO: must be an item reference
//TODO: must be from a list of configured values

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie69992976344874e79f6c6163cd9e69c835ac3f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Change DOUBLE to FLOAT for wb_term.term_weight - change (mediawiki...Wikibase)

2013-07-18 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: Change DOUBLE to FLOAT for wb_term.term_weight
..

Change DOUBLE to FLOAT for wb_term.term_weight

Needs less space, and the higher precision is not needed.

Change-Id: I6f9b58fc719edd5f7d9bd474808030616b10e1c4
---
M repo/includes/store/sql/AddTermsWeight.sql
M repo/includes/store/sql/AddTermsWeight.sqlite.sql
2 files changed, 2 insertions(+), 2 deletions(-)


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

diff --git a/repo/includes/store/sql/AddTermsWeight.sql 
b/repo/includes/store/sql/AddTermsWeight.sql
index 5c1de39..4d8392d 100644
--- a/repo/includes/store/sql/AddTermsWeight.sql
+++ b/repo/includes/store/sql/AddTermsWeight.sql
@@ -2,4 +2,4 @@
 -- Licence: GNU GPL v2+
 
 
-alter table /*_*/wb_terms add column term_weight DOUBLE UNSIGNED NOT NULL 
DEFAULT 0.0;
+alter table /*_*/wb_terms add column term_weight FLOAT UNSIGNED NOT NULL 
DEFAULT 0.0;
diff --git a/repo/includes/store/sql/AddTermsWeight.sqlite.sql 
b/repo/includes/store/sql/AddTermsWeight.sqlite.sql
index cf9845f..711ee52 100644
--- a/repo/includes/store/sql/AddTermsWeight.sqlite.sql
+++ b/repo/includes/store/sql/AddTermsWeight.sqlite.sql
@@ -8,7 +8,7 @@
   term_type  VARBINARY(32)   NOT NULL, -- Term type
   term_text  VARCHAR(255) binary NOT NULL, -- The term text
   term_search_keyVARCHAR(255) binary NOT NULL, -- The term text, 
lowercase for case-insensitive lookups
-  term_weightDOUBLE UNSIGNED NOT NULL DEFAULT 0.0 -- 
weight for ranking
+  term_weightFLOAT UNSIGNED NOT NULL DEFAULT 0.0 -- weight 
for ranking
 ) /*$wgDBTableOptions*/;
 
 INSERT INTO /*_*/wb_terms_tmp( term_entity_id, term_entity_type, 
term_language, term_type, term_text, term_search_key, term_weight )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f9b58fc719edd5f7d9bd474808030616b10e1c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] move term setting to lib - change (mediawiki...Wikibase)

2013-07-18 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: move term setting to lib
..

move term setting to lib

Change-Id: I31f605ac242d02fb692b89e0c29d6d0a1358fcf4
---
M lib/config/WikibaseLib.default.php
M repo/config/Wikibase.default.php
2 files changed, 6 insertions(+), 6 deletions(-)


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

diff --git a/lib/config/WikibaseLib.default.php 
b/lib/config/WikibaseLib.default.php
index 289c81b..aea5e48 100644
--- a/lib/config/WikibaseLib.default.php
+++ b/lib/config/WikibaseLib.default.php
@@ -80,6 +80,12 @@
'dispatchBatchChunkFactor' => 3,
'dispatchBatchCacheFactor' => 3,
 
+   // Allow the TermIndex table to work without weights,
+   // for sites that can not easily roll out schema changes on 
large tables.
+   // This means that all searches will return an undefined order
+   // (depending on the database's inner working).
+   'withoutTermWeight' => false,
+
'changeHandlers' => array(
'wikibase-item~add' => 'Wikibase\ItemChange',
'wikibase-property~add' => 'Wikibase\EntityChange',
diff --git a/repo/config/Wikibase.default.php b/repo/config/Wikibase.default.php
index 8a0e331..f905118 100644
--- a/repo/config/Wikibase.default.php
+++ b/repo/config/Wikibase.default.php
@@ -62,12 +62,6 @@
// (depending on the database's collation).
'withoutTermSearchKey' => false,
 
-   // Allow the TermIndex table to work without weights,
-   // for sites that can not easily roll out schema changes on 
large tables.
-   // This means that all searches will return an undefined order
-   // (depending on the database's inner working).
-   'withoutTermWeight' => false,
-
'entityNamespaces' => array(),
 
// These are used for multilanguage strings that should have a 
soft length constraint

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I31f605ac242d02fb692b89e0c29d6d0a1358fcf4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] Update QueryRountrip integration test to use new factories - change (mediawiki...Ask)

2013-07-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Update QueryRountrip integration test to use new factories
..


Update QueryRountrip integration test to use new factories

Change-Id: Icdd3d9e1c34b782489551d1f9f2ad33251693bfb
---
M Tests/Integration/Serialization/QueryRoundtripTest.php
1 file changed, 6 insertions(+), 28 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Integration/Serialization/QueryRoundtripTest.php 
b/Tests/Integration/Serialization/QueryRoundtripTest.php
index 5e1d1df..bd0a838 100644
--- a/Tests/Integration/Serialization/QueryRoundtripTest.php
+++ b/Tests/Integration/Serialization/QueryRoundtripTest.php
@@ -2,11 +2,7 @@
 
 namespace Ask\Tests\Integration\Serialization;
 
-use Ask\Deserializers\DescriptionDeserializer;
-use Ask\Deserializers\QueryDeserializer;
-use Ask\Deserializers\QueryOptionsDeserializer;
-use Ask\Deserializers\SelectionRequestDeserializer;
-use Ask\Deserializers\SortExpressionDeserializer;
+use Ask\DeserializerFactory;
 use Ask\Language\Description\AnyValue;
 use Ask\Language\Description\Conjunction;
 use Ask\Language\Description\SomeProperty;
@@ -18,15 +14,9 @@
 use Ask\Language\Query;
 use Ask\Language\Selection\PropertySelection;
 use Ask\Language\Selection\SubjectSelection;
-use Ask\Serializers\DescriptionSerializer;
-use Ask\Serializers\QueryOptionsSerializer;
-use Ask\Serializers\QuerySerializer;
-use Ask\Serializers\SelectionRequestSerializer;
-use Ask\Serializers\SortExpressionSerializer;
+use Ask\SerializerFactory;
 use DataValues\DataValueFactory;
 use DataValues\StringValue;
-use Deserializers\DispatchingDeserializer;
-use Serializers\DispatchingSerializer;
 
 /**
  * @file
@@ -41,29 +31,17 @@
 class QueryRoundtripTest extends \PHPUnit_Framework_TestCase {
 
protected function newQueryDeserializer() {
-   $componentDeserializer = new DispatchingDeserializer();
-
-   $componentDeserializer->addDeserializer( new 
QueryOptionsDeserializer( $componentDeserializer ) );
-
$dvFactory = new DataValueFactory();
$dvFactory->registerDataValue( 'string', 
'DataValues\StringValue' );
 
-   $componentDeserializer->addDeserializer( new 
DescriptionDeserializer( $dvFactory ) );
-   $componentDeserializer->addDeserializer( new 
SortExpressionDeserializer( $dvFactory ) );
-   $componentDeserializer->addDeserializer( new 
SelectionRequestDeserializer( $dvFactory ) );
+   $deserializerFactory = new DeserializerFactory( $dvFactory );
 
-   return new QueryDeserializer( $componentDeserializer );
+   return $deserializerFactory->newQueryDeserializer();
}
 
protected function newQuerySerializer() {
-   $dispatchingSerializer = new DispatchingSerializer();
-
-   $dispatchingSerializer->addSerializer( new 
DescriptionSerializer() );
-   $dispatchingSerializer->addSerializer( new 
SelectionRequestSerializer() );
-   $dispatchingSerializer->addSerializer( new 
QueryOptionsSerializer( $dispatchingSerializer ) );
-   $dispatchingSerializer->addSerializer( new 
SortExpressionSerializer() );
-
-   return new QuerySerializer( $dispatchingSerializer );
+   $serializerFactory = new SerializerFactory();
+   return $serializerFactory->newQuerySerializer();
}
 
/**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icdd3d9e1c34b782489551d1f9f2ad33251693bfb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Optimize imports - change (mediawiki...Ask)

2013-07-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Optimize imports
..


Optimize imports

Change-Id: I80016bf4bbf964641bbb1d89fad33a4e748445d0
---
M Tests/Integration/Serialization/QuerySerialializationTest.php
M Tests/Phpunit/DeserilaizerFactoryTest.php
2 files changed, 1 insertion(+), 8 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/Tests/Integration/Serialization/QuerySerialializationTest.php 
b/Tests/Integration/Serialization/QuerySerialializationTest.php
index 3bc1600..5705b59 100644
--- a/Tests/Integration/Serialization/QuerySerialializationTest.php
+++ b/Tests/Integration/Serialization/QuerySerialializationTest.php
@@ -2,7 +2,6 @@
 
 namespace Ask\Tests\Integration\Serialization;
 
-use Ask\SerializerFactory;
 use Ask\Language\Description\AnyValue;
 use Ask\Language\Description\Conjunction;
 use Ask\Language\Description\SomeProperty;
@@ -14,13 +13,8 @@
 use Ask\Language\Query;
 use Ask\Language\Selection\PropertySelection;
 use Ask\Language\Selection\SubjectSelection;
-use Ask\Serializers\DescriptionSerializer;
-use Ask\Serializers\QueryOptionsSerializer;
-use Ask\Serializers\QuerySerializer;
-use Ask\Serializers\SelectionRequestSerializer;
-use Ask\Serializers\SortExpressionSerializer;
+use Ask\SerializerFactory;
 use DataValues\StringValue;
-use Serializers\DispatchingSerializer;
 
 /**
  * @file
diff --git a/Tests/Phpunit/DeserilaizerFactoryTest.php 
b/Tests/Phpunit/DeserilaizerFactoryTest.php
index d03b9ca..3fdf333 100644
--- a/Tests/Phpunit/DeserilaizerFactoryTest.php
+++ b/Tests/Phpunit/DeserilaizerFactoryTest.php
@@ -4,7 +4,6 @@
 
 use Ask\DeserializerFactory;
 use Ask\Language\Option\SortExpression;
-use DataValues\DataValueFactory;
 use Deserializers\Deserializer;
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I80016bf4bbf964641bbb1d89fad33a4e748445d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Work on store interface - change (mediawiki...WikibaseQueryEngine)

2013-07-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Work on store interface
..


Work on store interface

* Removed stubs that will not be implemented any time soon
* Simplified test cases
* Provide access to DescriptionMatchFinder functionality via the public 
interface

Change-Id: Iffea17e8728d1719d7d61597d86ba3d40bbd5820
---
M src/QueryEngine.php
M src/SQLStore/Engine/Engine.php
M src/SQLStore/Factory.php
M src/SQLStore/Store.php
M tests/integration/SQLStore/Engine/DescriptionMatchFinderIntegrationTest.php
M tests/integration/SQLStore/WritingIntegrationTest.php
D tests/phpunit/QueryEngineResultTest.php
D tests/phpunit/QueryEngineTest.php
D tests/phpunit/QueryStoreTest.php
M tests/phpunit/SQLStore/Engine/EngineTest.php
M tests/phpunit/SQLStore/StoreTest.php
11 files changed, 84 insertions(+), 365 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/QueryEngine.php b/src/QueryEngine.php
index f0204d5..ad33281 100644
--- a/src/QueryEngine.php
+++ b/src/QueryEngine.php
@@ -2,27 +2,12 @@
 
 namespace Wikibase\QueryEngine;
 
-use Ask\Language\Query;
+use Ask\Language\Description\Description;
+use Ask\Language\Option\QueryOptions;
+use Wikibase\EntityId;
 
 /**
  * Interface for objects that can act as a query engine.
- *
- * A query engine can run a given Query and return the QueryResult for it.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
  *
  * @since 0.1
  *
@@ -37,10 +22,11 @@
/**
 * @since 0.1
 *
-* @param Query $query
+* @param Description $description
+* @param QueryOptions $options
 *
-* @return QueryResult
+* @return EntityId[]
 */
-   public function runQuery( Query $query );
+   public function getMatchingEntities( Description $description, 
QueryOptions $options );
 
 }
\ No newline at end of file
diff --git a/src/SQLStore/Engine/Engine.php b/src/SQLStore/Engine/Engine.php
index afb6ef9..0774e0d 100644
--- a/src/SQLStore/Engine/Engine.php
+++ b/src/SQLStore/Engine/Engine.php
@@ -9,24 +9,10 @@
 use Wikibase\QueryEngine\QueryEngine;
 use Wikibase\QueryEngine\QueryEngineResult;
 use Wikibase\QueryEngine\SQLStore\StoreConfig;
+use Wikibase\EntityId;
 
 /**
  * Simple query engine that works on top of the SQLStore.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
  *
  * @since 0.1
  *
@@ -38,42 +24,24 @@
  */
 class Engine implements QueryEngine {
 
-   /**
-* @since 0.1
-*
-* @var StoreConfig
-*/
-   private $config;
+   private $matchFinder;
 
-   /**
-* @since 0.1
-*
-* @var QueryInterface
-*/
-   private $queryInterface;
-
-   /**
-* @since 0.1
-*
-* @param StoreConfig $storeConfig
-* @param QueryInterface $queryInterface
-*/
-   public function __construct( StoreConfig $storeConfig, QueryInterface 
$queryInterface ) {
-   $this->config = $storeConfig;
-   $this->queryInterface = $queryInterface;
+   public function __construct( DescriptionMatchFinder $matchFinder ) {
+   $this->matchFinder = $matchFinder;
}
 
/**
-* @see QueryEngine::runQuery
+* @see QueryEngine::getMatchingEntities
 *
 * @since 0.1
 *
-* @param Query $query
+* @param Description $description
+* @param QueryOptions

[MediaWiki-commits] [Gerrit] Improve errors in wblinktitles - change (mediawiki...Wikibase)

2013-07-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Improve errors in wblinktitles
..


Improve errors in wblinktitles

Change-Id: Ib9ea338f5c24e0055d595c690760f0580ce13dc8
---
M repo/includes/api/LinkTitles.php
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/api/LinkTitles.php b/repo/includes/api/LinkTitles.php
index ca00ed5..a73c5c4 100644
--- a/repo/includes/api/LinkTitles.php
+++ b/repo/includes/api/LinkTitles.php
@@ -70,7 +70,7 @@
 
if ( $fromPage === false ) {
wfProfileOut( __METHOD__ );
-   $this->dieUsage( 'The external client site did not 
provide page information' , 'no-external-page' );
+   $this->dieUsage( 'The external client site did not 
provide page information for the from page' , 'no-external-page' );
}
 
// This is used for testing purposes later
@@ -84,7 +84,7 @@
 
if ( $toPage === false ) {
wfProfileOut( __METHOD__ );
-   $this->dieUsage( 'The external client site did not 
provide page information' , 'no-external-page' );
+   $this->dieUsage( 'The external client site did not 
provide page information for the to page' , 'no-external-page' );
}
// This is used for testing purposes later
$toId = 
StoreFactory::getStore()->newSiteLinkCache()->getItemIdForLink( 
$params['tosite'], $toPage );
@@ -133,12 +133,12 @@
elseif ( $fromId === $toId ) {
// no-op
wfProfileOut( __METHOD__ );
-   $this->dieUsage( 'Common item detected', 'common-item' 
);
+   $this->dieUsage( 'Common item detected, sitelinks are 
both on the same item', 'common-item' );
}
else {
// dissimilar items
wfProfileOut( __METHOD__ );
-   $this->dieUsage( 'No common item detected' , 
'no-common-item' );
+   $this->dieUsage( 'No common item detected, unable to 
link titles' , 'no-common-item' );
}
 
$this->addSiteLinksToResult( $return, 'entity' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib9ea338f5c24e0055d595c690760f0580ce13dc8
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Revert "Log a warning if ItemChange::getSiteLinkDiff returns... - change (mediawiki...Wikibase)

2013-07-13 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Revert "Log a warning if ItemChange::getSiteLinkDiff returns a 
non-array"
..


Revert "Log a warning if ItemChange::getSiteLinkDiff returns a non-array"

This reverts commit 833cf2e85143717b92c7aa2f3b9c8b687230daaa.

Change-Id: I0d7b66dc4a8c738c76d2a413d0d451b0248ab631
---
M lib/maintenance/dispatchChanges.php
1 file changed, 1 insertion(+), 7 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/maintenance/dispatchChanges.php 
b/lib/maintenance/dispatchChanges.php
index 5ce791a..2573d63 100644
--- a/lib/maintenance/dispatchChanges.php
+++ b/lib/maintenance/dispatchChanges.php
@@ -855,13 +855,7 @@
if ( $change instanceof ItemChange && !$change->isEmpty() ) {
$siteLinkDiff = $change->getSiteLinkDiff();
 
-   if ( !is_array( $siteLinkDiff ) ) {
-   wfLogWarning( '$siteLinkDiff must be an array, 
' . gettype( $siteLinkDiff ) . ' given' );
-   wfProfileOut( __METHOD__ );
-   return false;
-   }
-
-   if ( isset( $siteLinkDiff[ $siteID ] ) ) {
+   if ( is_array( $siteLinkDiff ) && isset( $siteLinkDiff[ 
$siteID ] ) ) {
wfProfileOut( __METHOD__ );
return true;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0d7b66dc4a8c738c76d2a413d0d451b0248ab631
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Log a warning if ItemChange::getSiteLinkDiff returns a non-a... - change (mediawiki...Wikibase)

2013-07-13 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Log a warning if ItemChange::getSiteLinkDiff returns a non-array
..


Log a warning if ItemChange::getSiteLinkDiff returns a non-array

Untested quick and dirty fix

Change-Id: Idfab159d2077bd3c85dd4eee99e1b7bb11e1a4e2
---
M lib/maintenance/dispatchChanges.php
1 file changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/maintenance/dispatchChanges.php 
b/lib/maintenance/dispatchChanges.php
index 2573d63..5ce791a 100644
--- a/lib/maintenance/dispatchChanges.php
+++ b/lib/maintenance/dispatchChanges.php
@@ -855,7 +855,13 @@
if ( $change instanceof ItemChange && !$change->isEmpty() ) {
$siteLinkDiff = $change->getSiteLinkDiff();
 
-   if ( is_array( $siteLinkDiff ) && isset( $siteLinkDiff[ 
$siteID ] ) ) {
+   if ( !is_array( $siteLinkDiff ) ) {
+   wfLogWarning( '$siteLinkDiff must be an array, 
' . gettype( $siteLinkDiff ) . ' given' );
+   wfProfileOut( __METHOD__ );
+   return false;
+   }
+
+   if ( isset( $siteLinkDiff[ $siteID ] ) ) {
wfProfileOut( __METHOD__ );
return true;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idfab159d2077bd3c85dd4eee99e1b7bb11e1a4e2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Check if Diff is a value before accessing value field - change (mediawiki...Wikibase)

2013-07-13 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: Check if Diff is a value before accessing value field
..

Check if Diff is a value before accessing value field

This is to increase the robustness with regards to
possible values given by the Change object. Although this
should never happened, it caused the Disptacher choking on
July 12/13, 2013, it seems, so we just check here one more
time whether the variable is an Array before accessing its
field.

Change-Id: Ibf1b1f01d82cc2e2febabbe2cebbace3508ee5d6
---
M lib/maintenance/dispatchChanges.php
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/lib/maintenance/dispatchChanges.php 
b/lib/maintenance/dispatchChanges.php
index cd01330..2573d63 100644
--- a/lib/maintenance/dispatchChanges.php
+++ b/lib/maintenance/dispatchChanges.php
@@ -855,7 +855,7 @@
if ( $change instanceof ItemChange && !$change->isEmpty() ) {
$siteLinkDiff = $change->getSiteLinkDiff();
 
-   if ( isset( $siteLinkDiff[ $siteID ] ) ) {
+   if ( is_array( $siteLinkDiff ) && isset( $siteLinkDiff[ 
$siteID ] ) ) {
wfProfileOut( __METHOD__ );
return true;
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf1b1f01d82cc2e2febabbe2cebbace3508ee5d6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] Add missing wfProfileOut() call - change (mediawiki...Wikibase)

2013-07-13 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add missing wfProfileOut() call
..


Add missing wfProfileOut() call

Change-Id: I2e3aaef7015e109a094cbfb512e09eec2b641d83
---
M lib/maintenance/dispatchChanges.php
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Verified; Looks good to me, approved



diff --git a/lib/maintenance/dispatchChanges.php 
b/lib/maintenance/dispatchChanges.php
index 10e0c0e..cd01330 100644
--- a/lib/maintenance/dispatchChanges.php
+++ b/lib/maintenance/dispatchChanges.php
@@ -856,6 +856,7 @@
$siteLinkDiff = $change->getSiteLinkDiff();
 
if ( isset( $siteLinkDiff[ $siteID ] ) ) {
+   wfProfileOut( __METHOD__ );
return true;
}
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2e3aaef7015e109a094cbfb512e09eec2b641d83
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Reedy 
Gerrit-Reviewer: Denny Vrandecic 
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 51227) add term_weight column to wb_terms table - change (mediawiki...Wikibase)

2013-07-12 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: (bug 51227) add term_weight column to wb_terms table
..

(bug 51227) add term_weight column to wb_terms table

Change-Id: I296008bde10945a0fb0e708e9bcccb68cb806fde
---
A repo/includes/store/sql/AddTermsWeight.sql
A repo/includes/store/sql/AddTermsWeight.sqlite.sql
M repo/includes/store/sql/SqlStore.php
M repo/includes/store/sql/Wikibase.sql
4 files changed, 54 insertions(+), 2 deletions(-)


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

diff --git a/repo/includes/store/sql/AddTermsWeight.sql 
b/repo/includes/store/sql/AddTermsWeight.sql
new file mode 100644
index 000..5c1de39
--- /dev/null
+++ b/repo/includes/store/sql/AddTermsWeight.sql
@@ -0,0 +1,5 @@
+-- Patch to add the term_search_key to wb_terms.
+-- Licence: GNU GPL v2+
+
+
+alter table /*_*/wb_terms add column term_weight DOUBLE UNSIGNED NOT NULL 
DEFAULT 0.0;
diff --git a/repo/includes/store/sql/AddTermsWeight.sqlite.sql 
b/repo/includes/store/sql/AddTermsWeight.sqlite.sql
new file mode 100644
index 000..e5856cc
--- /dev/null
+++ b/repo/includes/store/sql/AddTermsWeight.sqlite.sql
@@ -0,0 +1,26 @@
+-- Patch to add the term_weight to wb_terms.
+-- Licence: GNU GPL v2+
+
+CREATE TABLE /*_*/wb_terms_tmp (
+  term_entity_id INT unsignedNOT NULL, -- Id of the entity
+  term_entity_type   VARBINARY(32)   NOT NULL, -- Type of the 
entity
+  term_language  VARBINARY(32)   NOT NULL, -- Language code
+  term_type  VARBINARY(32)   NOT NULL, -- Term type
+  term_text  VARCHAR(255) binary NOT NULL, -- The term text
+  term_search_keyVARCHAR(255) binary NOT NULL -- The term text, 
lowercase for case-insensitive lookups
+  term_weightDOUBLE UNSIGNED NOT NULL DEFAULT 0.0 -- 
weight for ranking
+) ) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/wb_terms_tmp( term_entity_id, term_entity_type, 
term_language, term_type, term_text, term_search_key, term_weight )
+  SELECT term_entity_id, term_entity_type, term_language, term_type, 
term_text, term_text, term_search_key FROM wb_terms;
+
+DROP TABLE /*_*/wb_terms;
+
+ALTER TABLE /*_*/wb_terms_tmp RENAME TO /*_*/wb_terms;
+
+CREATE INDEX IF NOT EXISTS /*i*/wb_terms_entity_id ON /*_*/wb_terms 
(term_entity_id);
+CREATE INDEX IF NOT EXISTS /*i*/wb_terms_entity_type ON /*_*/wb_terms 
(term_entity_type);
+CREATE INDEX IF NOT EXISTS /*i*/wb_terms_language ON /*_*/wb_terms 
(term_language);
+CREATE INDEX IF NOT EXISTS /*i*/wb_terms_type ON /*_*/wb_terms (term_type);
+CREATE INDEX IF NOT EXISTS /*i*/wb_terms_text ON /*_*/wb_terms (term_text);
+CREATE INDEX IF NOT EXISTS /*i*/wb_terms_search_key ON /*_*/wb_terms 
(term_search_key);
diff --git a/repo/includes/store/sql/SqlStore.php 
b/repo/includes/store/sql/SqlStore.php
index 5595d9e..7332f2d 100644
--- a/repo/includes/store/sql/SqlStore.php
+++ b/repo/includes/store/sql/SqlStore.php
@@ -120,6 +120,9 @@
$db = $updater->getDB();
$type = $db->getType();
 
+   // TODO the following ifs are utterly confusing and need some 
clean up
+   // i.e. there are code branches that are unreachable, extension 
adding happens a little
+   // on the start, a little later, etc.
if ( $type === 'mysql' || $type === 'sqlite' /* || $type === 
'postgres' */ ) {
$extension = $type === 'postgres' ? '.pg.sql' : '.sql';
 
@@ -184,6 +187,23 @@
__DIR__ . '/AddRowIDs' . 
$alteredExtension
);
}
+
+   // Update to add weight to wb_terms
+   if ( !$db->fieldExists( 'wb_terms' , 'wb_weight' ) ) {
+   // creates wb_terms.wb_weight
+
+   $alteredExtension = $extension;
+   if ( $type === 'sqlite' ) {
+   $alteredExtension = '.sqlite' . 
$alteredExtension;
+   }
+
+   $updater->addExtensionField(
+   'wb_terms',
+   'term_search_key',
+   __DIR__ . '/AddTermsWeight' . 
$alteredExtension
+   );
+
+   }
}
else {
wfWarn( "Database type '$type' is not supported by 
Wikibase." );
diff --git a/repo/includes/store/sql/Wikibase.sql 
b/repo/includes/store/sql/Wikibase.sql
index 16f3b5d..00a3aa4 100644
--- a/repo/includes/store/sql/Wikibase.sql
+++ b/repo/includes/store/sql/Wikibase.sql
@@ -2,7 +2,7 @@
 -- Licence: GNU GPL v2+
 
 
--- TODO: figure out whic

[MediaWiki-commits] [Gerrit] (bug 43238) Add very simple weighting for entity search (DO ... - change (mediawiki...Wikibase)

2013-07-12 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: (bug 43238) Add very simple weighting for entity search (DO NOT 
MERGE)
..

(bug 43238) Add very simple weighting for entity search (DO NOT MERGE)

A very simple weighting algorithm (number of sitelinks) has
been added to do a post-DB-query ranking of search results.
Also, this limits the search to 5000 items.
It requires Bug 51227 to be resolved first.

Change-Id: Ie09e4932de42676dd5d638d32f76abe0a2200617
---
M lib/includes/store/sql/TermSqlIndex.php
1 file changed, 33 insertions(+), 7 deletions(-)


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

diff --git a/lib/includes/store/sql/TermSqlIndex.php 
b/lib/includes/store/sql/TermSqlIndex.php
index f9c10d8..e324a14 100644
--- a/lib/includes/store/sql/TermSqlIndex.php
+++ b/lib/includes/store/sql/TermSqlIndex.php
@@ -150,6 +150,14 @@
'term_entity_type' => $entity->getType()
);
 
+   // very simple weighting calculation.
+   // TODO delegate this to an object of its own
+   $entityWeight = array();
+   if ( $entity instanceof Item ) {
+   $weight = count( $entity->getSimpleSiteLinks() ) / 
1000.0;
+   $entityWeight['term_weight'] = $weight;
+   }
+
wfDebugLog( __CLASS__, __FUNCTION__ . ": updating terms for " . 
$entity->getId()->getPrefixedId() );
 
$success = $dbw->delete(
@@ -166,7 +174,8 @@
$this->tableName,
array_merge(
$this->getTermFields( $term ),
-   $entityIdentifiers
+   $entityIdentifiers,
+   $entityWeight
),
__METHOD__
);
@@ -539,7 +548,7 @@
 *
 * @param array $terms
 * @param string $entityType
-* @param array $options
+* @param array $options There is an implicit LIMIT of 5000 items in 
this implementation
 *
 * @return EntityId[]
 */
@@ -548,16 +557,19 @@
return array();
}
 
+   // this is the maximum limit of search results TODO this should 
not be hardcoded
+   $internalLimit = 5000;
+
$conditions = $this->termsToConditions( $terms, null, 
$entityType, false, $options );
 
-   $selectionFields = array( 'term_entity_id' );
+   $selectionFields = array( 'term_entity_id', 'term_weight' );
 
$dbr = $this->getReadDb();
 
$queryOptions = array( 'DISTINCT' );
 
if ( array_key_exists( 'LIMIT', $options ) && $options['LIMIT'] 
) {
-   $queryOptions['LIMIT'] = $options['LIMIT'];
+   $queryOptions['LIMIT'] = max( $options['LIMIT'], 
$internalLimit );
}
 
$obtainedIDs = $dbr->select(
@@ -568,12 +580,26 @@
$queryOptions
);
 
-   $result = array();
+   $entityIds = array();
+   $weights = array();
foreach ( $obtainedIDs as $obtainedID ) {
-   $result[] = new EntityId( $entityType, 
(int)$obtainedID->term_entity_id );
+   $entityIds[] = new EntityId( $entityType, 
(int)$obtainedID->term_entity_id );
+   $weights[] = floatval( $obtainedID->term_weight );
+   }
+   $this->releaseConnection( $dbr );
+
+   // this is a post-search sorting by weight. This allows us to 
not require an additional
+   // index on the wb_terms table that is very big already. This 
is also why we have
+   // the internal limit of 5000, since SQL's index would explode 
in size if we added the
+   // weight to it here (which would allow us to delegate the 
sorting to SQL itself)
+   array_multisort( $weights, SORT_DESC, SORT_NUMERIC, $entityIds 
);
+
+   if ( array_key_exists( 'LIMIT', $options ) && $options['LIMIT'] 
) {
+   $result = array_slice( $entityIds, 0, $options['LIMIT'] 
);
+   } else {
+   $result = $entityIds;
}
 
-   $this->releaseConnection( $dbr );
return $result;
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie09e4932de42676dd5d638d32f76abe0a2200617
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Bran

[MediaWiki-commits] [Gerrit] editentity aliases only 1 changeop per change type - change (mediawiki...Wikibase)

2013-07-11 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: editentity aliases only 1 changeop per change type
..


editentity aliases only 1 changeop per change type

Previously a changeop was created for each alias
given to wbeditentity. As each changeop is a set
each changeop was overwriting the previous changes
Bug: 50983

Change-Id: Iae7d15467c31bbf09f03acd4b069b3a2199a1509
---
M repo/includes/api/EditEntity.php
1 file changed, 12 insertions(+), 5 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 72a228f..a35e7a7 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -171,7 +171,6 @@
$this->addLabelsToResult( $entity->getLabels(), 'entity' );
$this->addDescriptionsToResult( $entity->getDescriptions(), 
'entity' );
$this->addAliasesToResult( $entity->getAllAliases(), 'entity' );
-
// TODO: This is a temporary fix that should be handled 
properly with a
// serializer class that is specific for the given entity
if ( $entity->getType() === Item::ENTITY_TYPE ) {
@@ -274,25 +273,33 @@
}
}
 
+   $aliasesChanges = array();
+
foreach ( $indexedAliases as $langCode => $args ) {
foreach ( $args as $arg ) {
$status->merge( $this->checkMultilangArgs( 
$arg, $langCode ) );
 
-   $alias = array( 
$this->stringNormalizer->trimToNFC( $arg['value'] ) );
+   $alias = $this->stringNormalizer->trimToNFC( 
$arg['value'] );
$language = $arg['language'];
 
if ( array_key_exists( 'remove', $arg ) ) {
-   $aliasesChangeOps[] = new 
ChangeOpAliases( $language, $alias, 'remove' );
+   $aliasesChanges['remove'][$language][] 
= $alias;
}
elseif ( array_key_exists( 'add', $arg ) ) {
-   $aliasesChangeOps[] = new 
ChangeOpAliases( $language, $alias, 'add' );
+   $aliasesChanges['add'][$language][] = 
$alias;
}
else {
-   $aliasesChangeOps[] = new 
ChangeOpAliases( $language, $alias, 'set' );
+   $aliasesChanges['set'][$language][] = 
$alias;
}
}
}
 
+   foreach ( $aliasesChanges as $opType => $aliasChange ) {
+   foreach ( $aliasChange as $language => $aliasArray ) {
+   $aliasesChangeOps[] = new ChangeOpAliases( 
$language, $aliasArray, $opType );
+   }
+   }
+
if ( !$status->isOk() ) {
wfProfileOut( __METHOD__ );
$this->dieUsage( "Contained status: $1", 
$status->getWikiText() );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iae7d15467c31bbf09f03acd4b069b3a2199a1509
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore 
Gerrit-Reviewer: Addshore 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Ebrahim 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Hoo man 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Liangent 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Nilesh 
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] Auto-populate wb_property_info in updater. - change (mediawiki...Wikibase)

2013-07-10 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Auto-populate wb_property_info in updater.
..


Auto-populate wb_property_info in updater.

Change-Id: I7ba72849258d26a106eb39b9ac91de9b800042fc
---
M lib/includes/store/sql/PropertyInfoTable.php
M repo/includes/store/sql/PropertyInfoTableBuilder.php
2 files changed, 54 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/store/sql/PropertyInfoTable.php 
b/lib/includes/store/sql/PropertyInfoTable.php
index 8c1c3e0..cd8b99d 100644
--- a/lib/includes/store/sql/PropertyInfoTable.php
+++ b/lib/includes/store/sql/PropertyInfoTable.php
@@ -83,10 +83,40 @@
}
 
$updater->addExtensionTable( $table, $file );
+
+   // populate the table after creating it
+   $updater->addExtensionUpdate( array(
+   array( 'Wikibase\PropertyInfoTable', 
'rebuildPropertyInfo' )
+   ) );
}
}
 
/**
+* Wrapper for invoking PropertyInfoTableBuilder from DatabaseUpdater
+* during a database update.
+*
+* @param \DatabaseUpdater $updater
+*/
+   public static function rebuildPropertyInfo( \DatabaseUpdater $updater ) 
{
+   $reporter = new \ObservableMessageReporter();
+   $reporter->registerReporterCallback(
+   function ( $msg ) use ( $updater ) {
+   $updater->output( "..." . $msg . "\n" );
+   }
+   );
+
+   $table = new PropertyInfoTable( false );
+   $entityLookup = new WikiPageEntityLookup( false );
+
+   $builder = new PropertyInfoTableBuilder( $table, $entityLookup 
);
+   $builder->setReporter( $reporter );
+   $builder->setUseTransactions( false );
+
+   $updater->output( 'Populating ' . $table->getTableName() . "\n" 
);
+   $builder->rebuildPropertyInfo();
+   }
+
+   /**
 * @see   PropertyInfoStore::getPropertyInfo
 *
 * @param EntityId $propertyId
diff --git a/repo/includes/store/sql/PropertyInfoTableBuilder.php 
b/repo/includes/store/sql/PropertyInfoTableBuilder.php
index 0bd53ac..f183adc 100644
--- a/repo/includes/store/sql/PropertyInfoTableBuilder.php
+++ b/repo/includes/store/sql/PropertyInfoTableBuilder.php
@@ -52,6 +52,13 @@
protected $reporter;
 
/**
+* @since 0.4
+*
+* @var bool
+*/
+   protected $useTransactions = true;
+
+   /**
 * Whether all entries should be updated, or only missing entries
 *
 * @var bool
@@ -136,6 +143,17 @@
}
 
/**
+* Enables or disables transactions.
+* The only good reason to disable transactions is to be able to
+* run the rebuild inside an already existing transaction.
+*
+* @param bool $useTransactions
+*/
+   public function setUseTransactions( $useTransactions ) {
+   $this->useTransactions = $useTransactions;
+   }
+
+   /**
 * Rebuild the property info entries.
 * Use the rebuildPropertyInfo.php maintenance script to invoke this 
from the command line.
 *
@@ -173,7 +191,9 @@
// as that would cause the site to be rendered read 
only.
$this->waitForSlaves( $dbw );
 
-   $dbw->begin();
+   if ( $this->useTransactions ) {
+   $dbw->begin();
+   }
 
$props = $dbw->select(
$tables,
@@ -208,7 +228,9 @@
$c+= 1;
}
 
-   $dbw->commit();
+   if ( $this->useTransactions ) {
+   $dbw->commit();
+   }
 
$this->report( "Updated $c properties, up to ID 
$rowId." );
$total += $c;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7ba72849258d26a106eb39b9ac91de9b800042fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Jeroen De Dauw 
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 46867) skip bad search keys and report them. - change (mediawiki...Wikibase)

2013-07-10 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: (bug 46867) skip bad search keys and report them.
..


(bug 46867) skip bad search keys and report them.

rebuildTermsSearchKey.php now reports terms for which no search key
could be calculated, and skips them.

Change-Id: Iedd9cc3b56c0db2e5ed6c02a398d7c35b1c96a1b
---
M repo/includes/store/sql/TermSearchKeyBuilder.php
1 file changed, 19 insertions(+), 4 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/store/sql/TermSearchKeyBuilder.php 
b/repo/includes/store/sql/TermSearchKeyBuilder.php
index f8fa085..d2fc77e 100644
--- a/repo/includes/store/sql/TermSearchKeyBuilder.php
+++ b/repo/includes/store/sql/TermSearchKeyBuilder.php
@@ -173,16 +173,24 @@
);
 
$c = 0;
+   $cError = 0;
 
foreach ( $terms as $row ) {
-   $this->updateSearchKey( $dbw, 
$row->term_row_id, $row->term_text, $row->term_language );
+   $key = $this->updateSearchKey( $dbw, 
$row->term_row_id, $row->term_text, $row->term_language );
+
+   if ( $key === false ) {
+   $this->report( "Unable to calculate 
search key for " . $row->term_text );
+   $cError += 1;
+   } else {
+   $c+= 1;
+   }
+
$rowId = $row->term_row_id;
-   $c+= 1;
}
 
$dbw->commit();
 
-   $this->report( "Updated $c search keys, up to row 
$rowId." );
+   $this->report( "Updated $c search keys (skipped 
$cError), up to row $rowId." );
$total += $c;
 
if ( $c < $this->batchSize ) {
@@ -230,11 +238,18 @@
 * @param string $text the term's text
 * @param string $lang the term's language
 *
-* @return string the search key
+* @return string|bool the search key, or false if no search key could 
be calculated.
 */
protected function updateSearchKey( \DatabaseBase $dbw, $rowId, $text, 
$lang ) {
$key = Term::normalizeText( $text, $lang );
 
+   if ( $key === '' ) {
+   wfDebugLog( __CLASS__, __FUNCTION__ . ": failed to 
normalized term: $text" );
+   return false;
+   }
+
+   wfDebugLog( __CLASS__, __FUNCTION__ . ": row_id = $rowId, 
search_key = `$key`" );
+
$dbw->update(
$this->table->getTableName(),
array(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iedd9cc3b56c0db2e5ed6c02a398d7c35b1c96a1b
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Reedy 
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 class name of query entity - change (mediawiki...Wikibase)

2013-07-10 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fix class name of query entity
..


Fix class name of query entity

Change-Id: I607d2ae2d39f8ddb4d5258897309a30abc3a2bca
---
M lib/includes/EntityFactory.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/EntityFactory.php b/lib/includes/EntityFactory.php
index b7ea123..65ae11d 100644
--- a/lib/includes/EntityFactory.php
+++ b/lib/includes/EntityFactory.php
@@ -44,7 +44,7 @@
Property::ENTITY_TYPE => '\Wikibase\Property',
 
// TODO: Query::ENTITY_TYPE
-   'query' => '\Wikibase\Query'
+   'query' => '\Wikibase\Query\QueryEntity'
);
 
/**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I607d2ae2d39f8ddb4d5258897309a30abc3a2bca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 QueryDeserializer - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added QueryDeserializer
..


Added QueryDeserializer

* Added QueryDeserializer
* Added QueryDeserializerTest
* Added QueryRountripTest (integration)
* Fixed some misalignments between serialization and deserialization code

Change-Id: I82d6fac3af661c44c1550e949521ea9f61654785
---
R Tests/Integration/Serialization/DescriptionRoundtripTest.php
A Tests/Integration/Serialization/QueryRoundtripTest.php
R Tests/Integration/Serialization/QuerySerialializationTest.php
A Tests/Phpunit/Deserializers/QueryDeserializerTest.php
M Tests/Phpunit/Serializers/Exceptions/UnsupportedObjectExceptionTest.php
M Tests/Phpunit/Serializers/QueryOptionsSerializerTest.php
M Tests/Phpunit/Serializers/QuerySerializerTest.php
M Tests/Phpunit/Serializers/SelectionRequestSerializerTest.php
M src/Ask/Deserializers/DispatchingDeserializer.php
A src/Ask/Deserializers/QueryDeserializer.php
M src/Ask/Deserializers/Strategies/SelectionRequestDeserializationStrategy.php
M src/Ask/Deserializers/Strategies/SortExpressionDeserializationStrategy.php
M src/Ask/Deserializers/TypedObjectDeserializer.php
M src/Ask/Serializers/QueryOptionsSerializer.php
M src/Ask/Serializers/QuerySerializer.php
M src/Ask/Serializers/SelectionRequestSerializer.php
16 files changed, 412 insertions(+), 30 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Integration/Serializers/DescriptionRoundtripTest.php 
b/Tests/Integration/Serialization/DescriptionRoundtripTest.php
similarity index 97%
rename from Tests/Integration/Serializers/DescriptionRoundtripTest.php
rename to Tests/Integration/Serialization/DescriptionRoundtripTest.php
index 8f75421..b0d81f6 100644
--- a/Tests/Integration/Serializers/DescriptionRoundtripTest.php
+++ b/Tests/Integration/Serialization/DescriptionRoundtripTest.php
@@ -1,6 +1,6 @@
 
+ */
+class QueryRoundtripTest extends \PHPUnit_Framework_TestCase {
+
+   protected function newQueryDeserializer() {
+   $componentDeserializer = new DispatchingDeserializer();
+
+   $componentDeserializer->addDeserializer( new 
QueryOptionsDeserializer( $componentDeserializer ) );
+
+   $dvFactory = new DataValueFactory();
+   $dvFactory->registerDataValue( 'string', 
'DataValues\StringValue' );
+
+   $componentDeserializer->addDeserializer( new 
DescriptionDeserializer( $dvFactory ) );
+   $componentDeserializer->addDeserializer( new 
SortExpressionDeserializer( $dvFactory ) );
+   $componentDeserializer->addDeserializer( new 
SelectionRequestDeserializer( $dvFactory ) );
+
+   return new QueryDeserializer( $componentDeserializer );
+   }
+
+   protected function newQuerySerializer() {
+   $dispatchingSerializer = new DispatchingSerializer();
+
+   $dispatchingSerializer->addSerializer( new 
DescriptionSerializer() );
+   $dispatchingSerializer->addSerializer( new 
SelectionRequestSerializer() );
+   $dispatchingSerializer->addSerializer( new 
QueryOptionsSerializer( $dispatchingSerializer ) );
+   $dispatchingSerializer->addSerializer( new 
SortExpressionSerializer() );
+
+   return new QuerySerializer( $dispatchingSerializer );
+   }
+
+   /**
+* @dataProvider queryProvider
+* @param Query $query
+*/
+   public function testCanRoundtripQueryThroughSerialization( Query $query 
) {
+   $serialization = $this->newQuerySerializer()->serialize( $query 
);
+   $deserialization = $this->newQueryDeserializer()->deserialize( 
$serialization );
+
+   $this->assertEquals( $query, $deserialization );
+   }
+
+   public function queryProvider() {
+   $p42 = new StringValue( 'p42' );
+   $p9001 = new StringValue( 'p9001' );
+   $foo = new StringValue( 'foo' );
+
+   $argLists = array();
+
+   $argLists[] = array( new Query(
+   new AnyValue(),
+   array(
+   ),
+   new QueryOptions(
+   10,
+   0
+   )
+   ) );
+
+   $argLists[] = array( new Query(
+   new Conjunction( array(
+   new SomeProperty( $p42, new AnyValue() ),
+   new SomeProperty( $p9001, new ValueDescription( 
$foo ) ),
+   ) ),
+   array(
+   new SubjectSelection(),
+   new PropertySelection( $p42 ),
+   new PropertySelection( $p9001 ),
+   ),
+   new QueryOptions(
+  

[MediaWiki-commits] [Gerrit] Split off StrategicDeserializer from TypedObjectDeserializer... - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Split off StrategicDeserializer from TypedObjectDeserializer 
and added QueryOptionsDeserializer
..


Split off StrategicDeserializer from TypedObjectDeserializer and added 
QueryOptionsDeserializer

Change-Id: Ia808de8b65fdcc61466bc5c152b79583407c02a5
---
A Tests/Phpunit/Deserializers/QueryOptionsDeserializerTest.php
M src/Ask/Deserializers/DescriptionDeserializer.php
M src/Ask/Deserializers/QueryOptionsDeserializer.php
M src/Ask/Deserializers/SelectionRequestDeserializer.php
M src/Ask/Deserializers/SortExpressionDeserializer.php
A src/Ask/Deserializers/StrategicDeserializer.php
M src/Ask/Deserializers/TypedObjectDeserializer.php
7 files changed, 305 insertions(+), 34 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Deserializers/QueryOptionsDeserializerTest.php 
b/Tests/Phpunit/Deserializers/QueryOptionsDeserializerTest.php
new file mode 100644
index 000..4601e9b
--- /dev/null
+++ b/Tests/Phpunit/Deserializers/QueryOptionsDeserializerTest.php
@@ -0,0 +1,190 @@
+
+ */
+class QueryOptionsDeserializerTest extends \PHPUnit_Framework_TestCase {
+
+   protected function newQueryOptionsDeserializer() {
+   $dvFactory = new DataValueFactory();
+   $dvFactory->registerDataValue( 'string', 
'DataValues\StringValue' );
+
+   $sortExpressionSerializer = new SortExpressionDeserializer( 
$dvFactory );
+
+   return new QueryOptionsDeserializer( $sortExpressionSerializer 
);
+   }
+
+   /**
+* @dataProvider invalidObjectTypeProvider
+*/
+   public function testCannotDeserializeWithInvalidObjectType( 
$notQueryOptions ) {
+   $serializer = $this->newQueryOptionsDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notQueryOptions ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\UnsupportedTypeException' );
+   $serializer->deserialize( $notQueryOptions );
+   }
+
+   public function invalidObjectTypeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( array(
+   'objectType' => 'foobar',
+   'limit' => 10,
+   'offset' => 0,
+   'sort' => array(
+   'expressions' => array()
+   )
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => 'QUERYOPTIONS',
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => null,
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => array(),
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => 42,
+   ) );
+
+   return $argLists;
+   }
+
+   /**
+* @dataProvider missingObjectTypeProvider
+*/
+   public function testCannotDeserilaizeWithoutObjectType( 
$notQueryOptions ) {
+   $serializer = $this->newQueryOptionsDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notQueryOptions ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\MissingTypeException' );
+   $serializer->deserialize( $notQueryOptions );
+   }
+
+   public function missingObjectTypeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( null );
+   $argLists[] = array( array() );
+   $argLists[] = array( 'foo bar' );
+
+   $argLists[] = array( array(
+   'limit' => 10,
+   'offset' => 0,
+   'sort' => array(
+   'expressions' => array()
+   )
+   ) );
+
+   $argLists[] = array( array(
+   'ObjectType' => 'sortExpression',
+   ) );
+
+   $argLists[] = array( array(
+   'OBJECTTYPE' => 'sortExpression',
+   ) );
+
+   return $argLists;
+   }
+
+   /**
+* @dataProvider optionsWithMissingAttributeProvider
+*/
+   public function testPropertySelectionRequiresAllAttributes( array 
$incompleteSerialization ) {
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\MissingAttributeException' );
+   $this->newQueryOptionsDeserializer()->deserialize( 
$incompleteSerialization );
+   }
+
+
+
+   public function optionsWithMissingAttributeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( array(
+   'objectType' => 'queryO

[MediaWiki-commits] [Gerrit] Added attributeValue to InvalidAttributeException - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added attributeValue to InvalidAttributeException
..


Added attributeValue to InvalidAttributeException

Change-Id: I522941a30609aa6307142ac36857548a7bfa894a
---
M Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
M src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
M src/Ask/Deserializers/Strategies/DescriptionDeserializationStrategy.php
M src/Ask/Deserializers/Strategies/SelectionRequestDeserializationStrategy.php
M src/Ask/Deserializers/Strategies/SortExpressionDeserializationStrategy.php
M src/Ask/Deserializers/Strategies/TypedDeserializationStrategy.php
M src/Ask/Deserializers/TypedObjectDeserializer.php
7 files changed, 26 insertions(+), 10 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php 
b/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
index 844c53d..a8110fb 100644
--- a/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
+++ b/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
@@ -20,26 +20,29 @@
 
public function testConstructorWithOnlyRequiredArguments() {
$attributeName = 'theGame';
+   $attributeValue = 'youJustLostIt';
 
-   $exception = new InvalidAttributeException( $attributeName );
+   $exception = new InvalidAttributeException( $attributeName, 
$attributeValue );
 
-   $this->assertRequiredFieldsAreSet( $exception, $attributeName );
+   $this->assertRequiredFieldsAreSet( $exception, $attributeName, 
$attributeValue );
}
 
public function testConstructorWithAllArguments() {
$attributeName = 'theGame';
+   $attributeValue = 'youJustLostIt';
$message = 'NyanData all the way across the sky!';
$previous = new \Exception( 'Onoez!' );
 
-   $exception = new InvalidAttributeException( $attributeName, 
$message, $previous );
+   $exception = new InvalidAttributeException( $attributeName, 
$attributeValue, $message, $previous );
 
-   $this->assertRequiredFieldsAreSet( $exception, $attributeName );
+   $this->assertRequiredFieldsAreSet( $exception, $attributeName, 
$attributeValue );
$this->assertEquals( $message, $exception->getMessage() );
$this->assertEquals( $previous, $exception->getPrevious() );
}
 
-   protected function assertRequiredFieldsAreSet( 
InvalidAttributeException $exception, $attributeName ) {
+   protected function assertRequiredFieldsAreSet( 
InvalidAttributeException $exception, $attributeName, $attributeValue ) {
$this->assertEquals( $attributeName, 
$exception->getAttributeName() );
+   $this->assertEquals( $attributeValue, 
$exception->getAttributeValue() );
}
 
 }
diff --git a/src/Ask/Deserializers/Exceptions/InvalidAttributeException.php 
b/src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
index de70237..834d77a 100644
--- a/src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
+++ b/src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
@@ -14,14 +14,17 @@
 class InvalidAttributeException extends DeserializationException {
 
protected $attributeName;
+   protected $attributeValue;
 
/**
 * @param string $attributeName
+* @param mixed $attributeValue
 * @param string $message
 * @param \Exception $previous
 */
-   public function __construct( $attributeName, $message = '', \Exception 
$previous = null ) {
+   public function __construct( $attributeName, $attributeValue, $message 
= '', \Exception $previous = null ) {
$this->attributeName = $attributeName;
+   $this->attributeValue = $attributeValue;
 
parent::__construct( $message, $previous );
}
@@ -33,4 +36,11 @@
return $this->attributeName;
}
 
+   /**
+* @return string
+*/
+   public function getAttributeValue() {
+   return $this->attributeValue;
+   }
+
 }
diff --git 
a/src/Ask/Deserializers/Strategies/DescriptionDeserializationStrategy.php 
b/src/Ask/Deserializers/Strategies/DescriptionDeserializationStrategy.php
index f020e99..67da399 100644
--- a/src/Ask/Deserializers/Strategies/DescriptionDeserializationStrategy.php
+++ b/src/Ask/Deserializers/Strategies/DescriptionDeserializationStrategy.php
@@ -69,6 +69,7 @@
 
throw new InvalidAttributeException(
'descriptionType',
+   $descriptionType,
'The provided descriptionType is not supported by this 
deseriali

[MediaWiki-commits] [Gerrit] Remove Serializer from SerializationException - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Remove Serializer from SerializationException
..


Remove Serializer from SerializationException

Change-Id: I7e3be7547c14b2c7c4d9d2102a1f0ae8031aaf39
---
M Tests/Phpunit/Serializers/Exceptions/UnsupportedObjectExceptionTest.php
M src/Ask/Serializers/DescriptionSerializer.php
M src/Ask/Serializers/DispatchingSerializer.php
M src/Ask/Serializers/Exceptions/SerializationException.php
M src/Ask/Serializers/Exceptions/UnsupportedObjectException.php
M src/Ask/Serializers/QueryOptionsSerializer.php
M src/Ask/Serializers/QuerySerializer.php
M src/Ask/Serializers/SelectionRequestSerializer.php
M src/Ask/Serializers/SortExpressionSerializer.php
9 files changed, 17 insertions(+), 36 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/Tests/Phpunit/Serializers/Exceptions/UnsupportedObjectExceptionTest.php 
b/Tests/Phpunit/Serializers/Exceptions/UnsupportedObjectExceptionTest.php
index 5b67a5f..5b4a3f1 100644
--- a/Tests/Phpunit/Serializers/Exceptions/UnsupportedObjectExceptionTest.php
+++ b/Tests/Phpunit/Serializers/Exceptions/UnsupportedObjectExceptionTest.php
@@ -20,29 +20,26 @@
 
public function testConstructorWithOnlyRequiredArguments() {
$object = (object)array( 'the' => 'game' );
-   $serializer = $this->getMock( 'Ask\Serializers\Serializer' );
 
-   $exception = new UnsupportedObjectException( $object, 
$serializer );
+   $exception = new UnsupportedObjectException( $object );
 
-   $this->assertRequiredFieldsAreSet( $exception, $object, 
$serializer );
+   $this->assertRequiredFieldsAreSet( $exception, $object );
}
 
public function testConstructorWithAllArguments() {
$object = (object)array( 'the' => 'game' );
-   $serializer = $this->getMock( 'Ask\Serializers\Serializer' );
$message = 'NyanData all the way across the sky!';
$previous = new \Exception( 'Onoez!' );
 
-   $exception = new UnsupportedObjectException( $object, 
$serializer, $message, $previous );
+   $exception = new UnsupportedObjectException( $object, $message, 
$previous );
 
-   $this->assertRequiredFieldsAreSet( $exception, $object, 
$serializer );
+   $this->assertRequiredFieldsAreSet( $exception, $object );
$this->assertEquals( $message, $exception->getMessage() );
$this->assertEquals( $previous, $exception->getPrevious() );
}
 
-   protected function assertRequiredFieldsAreSet( 
UnsupportedObjectException $exception, $object, $serializer ) {
+   protected function assertRequiredFieldsAreSet( 
UnsupportedObjectException $exception, $object ) {
$this->assertEquals( $object, 
$exception->getUnsupportedObject() );
-   $this->assertEquals( $serializer, $exception->getSerializer() );
}
 
 }
diff --git a/src/Ask/Serializers/DescriptionSerializer.php 
b/src/Ask/Serializers/DescriptionSerializer.php
index 40bf0a6..a998fe3 100644
--- a/src/Ask/Serializers/DescriptionSerializer.php
+++ b/src/Ask/Serializers/DescriptionSerializer.php
@@ -66,12 +66,12 @@
);
}
 
-   throw new UnsupportedObjectException( $description, $this );
+   throw new UnsupportedObjectException( $description );
}
 
protected function assertCanSerialize( $askObject ) {
if ( !$this->canSerialize( $askObject ) ) {
-   throw new UnsupportedObjectException( $askObject, $this 
);
+   throw new UnsupportedObjectException( $askObject );
}
}
 
diff --git a/src/Ask/Serializers/DispatchingSerializer.php 
b/src/Ask/Serializers/DispatchingSerializer.php
index db9a9ac..7f1aab2 100644
--- a/src/Ask/Serializers/DispatchingSerializer.php
+++ b/src/Ask/Serializers/DispatchingSerializer.php
@@ -44,7 +44,7 @@
}
}
 
-   throw new UnsupportedObjectException( $askObject, $this );
+   throw new UnsupportedObjectException( $askObject );
}
 
public function canSerialize( $askObject ) {
diff --git a/src/Ask/Serializers/Exceptions/SerializationException.php 
b/src/Ask/Serializers/Exceptions/SerializationException.php
index d7ac062..6593eb6 100644
--- a/src/Ask/Serializers/Exceptions/SerializationException.php
+++ b/src/Ask/Serializers/Exceptions/SerializationException.php
@@ -2,8 +2,6 @@
 
 namespace Ask\Serializers\Exceptions;
 
-use Ask\Serializers\Serializer;
-
 /**
  * @since 0.1
  *
@@ -15,19 +13,8 @@
  */
 abstract class SerializationException extends \RuntimeException {
 
-   protected $serializer;
-
-   public function __construct( Serializer $deserializer, $message =

[MediaWiki-commits] [Gerrit] Optimized imports - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Optimized imports
..


Optimized imports

Change-Id: I40d48a0935981e49c8ca97c95b0ad45c05373314
---
M src/Ask/Deserializers/DescriptionDeserializer.php
A src/Ask/Deserializers/QueryOptionsDeserializer.php
M src/Ask/Deserializers/SortExpressionDeserializer.php
M src/Ask/Deserializers/TypedObjectDeserializer.php
M src/Ask/Serializers/QuerySerializer.php
M src/Ask/Serializers/SelectionRequestSerializer.php
6 files changed, 9 insertions(+), 9 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/Ask/Deserializers/DescriptionDeserializer.php 
b/src/Ask/Deserializers/DescriptionDeserializer.php
index 553b25d..a296498 100644
--- a/src/Ask/Deserializers/DescriptionDeserializer.php
+++ b/src/Ask/Deserializers/DescriptionDeserializer.php
@@ -4,15 +4,12 @@
 
 use Ask\Deserializers\Exceptions\DeserializationException;
 use Ask\Deserializers\Exceptions\InvalidAttributeException;
-use Ask\Deserializers\Exceptions\MissingAttributeException;
-use Ask\Deserializers\Exceptions\MissingTypeException;
 use Ask\Language\Description\AnyValue;
 use Ask\Language\Description\Conjunction;
 use Ask\Language\Description\Description;
 use Ask\Language\Description\Disjunction;
 use Ask\Language\Description\SomeProperty;
 use Ask\Language\Description\ValueDescription;
-use Ask\Deserializers\Exceptions\UnsupportedTypeException;
 use DataValues\DataValueFactory;
 
 /**
diff --git a/src/Ask/Deserializers/QueryOptionsDeserializer.php 
b/src/Ask/Deserializers/QueryOptionsDeserializer.php
new file mode 100644
index 000..1388bd5
--- /dev/null
+++ b/src/Ask/Deserializers/QueryOptionsDeserializer.php
@@ -0,0 +1,8 @@
+requireAttribute( $serialization, $this->getSubTypeKey() 
);
-   $this->requireAttribute( $serialization, 'value' );
+   $this->requireAttributes( $serialization, 'value' );
$this->assertAttributeIsArray( $serialization, 'value' );
 
$specificType = $serialization[$this->getSubTypeKey()];
diff --git a/src/Ask/Serializers/QuerySerializer.php 
b/src/Ask/Serializers/QuerySerializer.php
index 93138c6..3073a05 100644
--- a/src/Ask/Serializers/QuerySerializer.php
+++ b/src/Ask/Serializers/QuerySerializer.php
@@ -3,7 +3,6 @@
 namespace Ask\Serializers;
 
 use Ask\Language\Query;
-use Ask\Language\Selection\SelectionRequest;
 use Ask\Serializers\Exceptions\UnsupportedObjectException;
 
 /**
diff --git a/src/Ask/Serializers/SelectionRequestSerializer.php 
b/src/Ask/Serializers/SelectionRequestSerializer.php
index dbbf972..0f86c2c 100644
--- a/src/Ask/Serializers/SelectionRequestSerializer.php
+++ b/src/Ask/Serializers/SelectionRequestSerializer.php
@@ -2,7 +2,6 @@
 
 namespace Ask\Serializers;
 
-use Ask\Language\Option\QueryOptions;
 use Ask\Language\Selection\PropertySelection;
 use Ask\Language\Selection\SelectionRequest;
 use Ask\Language\Selection\SubjectSelection;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I40d48a0935981e49c8ca97c95b0ad45c05373314
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Rename source folder to src - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Rename source folder to src
..


Rename source folder to src

Change-Id: I64f4c844300f701b4391f9bc356d39af2fa3d1eb
---
M Ask.php
R src/Ask/Comparable.php
R src/Ask/Deserializers/DescriptionDeserializer.php
R src/Ask/Deserializers/Deserializer.php
R src/Ask/Deserializers/DispatchingDeserializer.php
R src/Ask/Deserializers/Exceptions/DeserializationException.php
R src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
R src/Ask/Deserializers/Exceptions/MissingAttributeException.php
R src/Ask/Deserializers/Exceptions/MissingTypeException.php
R src/Ask/Deserializers/Exceptions/UnsupportedTypeException.php
R src/Ask/Deserializers/SelectionRequestDeserializer.php
R src/Ask/Deserializers/SortExpressionDeserializer.php
R src/Ask/Deserializers/TypedObjectDeserializer.php
R src/Ask/Hashable.php
R src/Ask/Immutable.php
R src/Ask/Language/Description/AnyValue.php
R src/Ask/Language/Description/Conjunction.php
R src/Ask/Language/Description/Description.php
R src/Ask/Language/Description/DescriptionCollection.php
R src/Ask/Language/Description/Disjunction.php
R src/Ask/Language/Description/SomeProperty.php
R src/Ask/Language/Description/ValueDescription.php
R src/Ask/Language/Option/PropertyValueSortExpression.php
R src/Ask/Language/Option/QueryOptions.php
R src/Ask/Language/Option/SortExpression.php
R src/Ask/Language/Option/SortOptions.php
R src/Ask/Language/Query.php
R src/Ask/Language/Selection/PropertySelection.php
R src/Ask/Language/Selection/SelectionRequest.php
R src/Ask/Language/Selection/SubjectSelection.php
R src/Ask/Serializers/DescriptionSerializer.php
R src/Ask/Serializers/DispatchingSerializer.php
R src/Ask/Serializers/Exceptions/SerializationException.php
R src/Ask/Serializers/Exceptions/UnsupportedObjectException.php
R src/Ask/Serializers/QueryOptionsSerializer.php
R src/Ask/Serializers/QuerySerializer.php
R src/Ask/Serializers/SelectionRequestSerializer.php
R src/Ask/Serializers/Serializer.php
R src/Ask/Serializers/SortExpressionSerializer.php
R src/Ask/Typeable.php
40 files changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Ask.php b/Ask.php
index 508f5ea..792d8e1 100644
--- a/Ask.php
+++ b/Ask.php
@@ -70,7 +70,7 @@
 
if ( $namespaceSegments[0] === 'Ask' ) {
if ( count( $namespaceSegments ) === 1 || $namespaceSegments[1] 
!== 'Tests' ) {
-   require_once __DIR__ . '/includes/' . $fileName;
+   require_once __DIR__ . '/src/' . $fileName;
}
}
 } );
diff --git a/includes/Ask/Comparable.php b/src/Ask/Comparable.php
similarity index 100%
rename from includes/Ask/Comparable.php
rename to src/Ask/Comparable.php
diff --git a/includes/Ask/Deserializers/DescriptionDeserializer.php 
b/src/Ask/Deserializers/DescriptionDeserializer.php
similarity index 100%
rename from includes/Ask/Deserializers/DescriptionDeserializer.php
rename to src/Ask/Deserializers/DescriptionDeserializer.php
diff --git a/includes/Ask/Deserializers/Deserializer.php 
b/src/Ask/Deserializers/Deserializer.php
similarity index 100%
rename from includes/Ask/Deserializers/Deserializer.php
rename to src/Ask/Deserializers/Deserializer.php
diff --git a/includes/Ask/Deserializers/DispatchingDeserializer.php 
b/src/Ask/Deserializers/DispatchingDeserializer.php
similarity index 100%
rename from includes/Ask/Deserializers/DispatchingDeserializer.php
rename to src/Ask/Deserializers/DispatchingDeserializer.php
diff --git a/includes/Ask/Deserializers/Exceptions/DeserializationException.php 
b/src/Ask/Deserializers/Exceptions/DeserializationException.php
similarity index 100%
rename from includes/Ask/Deserializers/Exceptions/DeserializationException.php
rename to src/Ask/Deserializers/Exceptions/DeserializationException.php
diff --git 
a/includes/Ask/Deserializers/Exceptions/InvalidAttributeException.php 
b/src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
similarity index 100%
rename from includes/Ask/Deserializers/Exceptions/InvalidAttributeException.php
rename to src/Ask/Deserializers/Exceptions/InvalidAttributeException.php
diff --git 
a/includes/Ask/Deserializers/Exceptions/MissingAttributeException.php 
b/src/Ask/Deserializers/Exceptions/MissingAttributeException.php
similarity index 100%
rename from includes/Ask/Deserializers/Exceptions/MissingAttributeException.php
rename to src/Ask/Deserializers/Exceptions/MissingAttributeException.php
diff --git a/includes/Ask/Deserializers/Exceptions/MissingTypeException.php 
b/src/Ask/Deserializers/Exceptions/MissingTypeException.php
similarity index 100%
rename from includes/Ask/Deserializers/Exceptions/MissingTypeException.php
rename to src/Ask/Deserializers/Exceptions/MissingTypeException.php
diff --git a/includes/Ask/Deserializers/Exceptions/UnsupportedTypeException.php 
b/s

[MediaWiki-commits] [Gerrit] Tweaks to entry point file - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Tweaks to entry point file
..


Tweaks to entry point file

Change-Id: I280f19a0e0f0f7913afcc14b2edda5ba644f9fe5
---
M Ask.php
1 file changed, 6 insertions(+), 6 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Ask.php b/Ask.php
index 508f5ea..c7ea60c 100644
--- a/Ask.php
+++ b/Ask.php
@@ -36,15 +36,15 @@
 define( 'Ask_VERSION', '0.1 alpha' );
 
 // Attempt to include the DataValues lib if that hasn't been done yet.
-// This is the path the DataValues entry point will be at when loaded as 
MediaWiki extension.
-if ( !defined( 'DataValues_VERSION' ) && file_exists( __DIR__ . 
'/../DataValues/DataValues.php' ) ) {
-   include_once( __DIR__ . '/../DataValues/DataValues.php' );
+// This is the path to the autoloader generated by composer in case of a 
composer install.
+if ( !defined( 'DataValues_VERSION' ) && is_readable( __DIR__ . 
'/vendor/autoload.php' ) ) {
+   include_once( __DIR__ . '/vendor/autoload.php' );
 }
 
 // Attempt to include the DataValues lib if that hasn't been done yet.
-// This is the path to the autoloader generated by composer in case of a 
composer install.
-if ( !defined( 'DataValues_VERSION' ) && file_exists( __DIR__ . 
'/vendor/autoload.php' ) ) {
-   include_once( __DIR__ . '/vendor/autoload.php' );
+// This is the path the DataValues entry point will be at when loaded as 
MediaWiki extension.
+if ( !defined( 'DataValues_VERSION' ) && is_readable( __DIR__ . 
'/../DataValues/DataValues.php' ) ) {
+   include_once( __DIR__ . '/../DataValues/DataValues.php' );
 }
 
 // Only initialize the extension when all dependencies are present.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I280f19a0e0f0f7913afcc14b2edda5ba644f9fe5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 SelectionRequestDeserializer - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added SelectionRequestDeserializer
..


Added SelectionRequestDeserializer

Change-Id: Ibaaf7d0c4a263370a65c190939e96b20d721880e
---
A Tests/Phpunit/Deserializers/SelectionRequestDeserializerTest.php
M Tests/Phpunit/Deserializers/SortExpressionDeserializerTest.php
A includes/Ask/Deserializers/SelectionRequestDeserializer.php
M includes/Ask/Deserializers/SortExpressionDeserializer.php
4 files changed, 286 insertions(+), 21 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Deserializers/SelectionRequestDeserializerTest.php 
b/Tests/Phpunit/Deserializers/SelectionRequestDeserializerTest.php
new file mode 100644
index 000..65e6960
--- /dev/null
+++ b/Tests/Phpunit/Deserializers/SelectionRequestDeserializerTest.php
@@ -0,0 +1,194 @@
+
+ */
+class SelectionRequestDeserializerTest extends \PHPUnit_Framework_TestCase {
+
+   protected function newSelectionRequestDeserializer() {
+   $dvFactory = new DataValueFactory();
+   $dvFactory->registerDataValue( 'string', 
'DataValues\StringValue' );
+
+   return new SelectionRequestDeserializer( $dvFactory );
+   }
+
+   /**
+* @dataProvider invalidObjectTypeProvider
+*/
+   public function testCannotDeserializeWithInvalidObjectType( 
$notASelectionRequest ) {
+   $serializer = $this->newSelectionRequestDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notASelectionRequest ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\UnsupportedTypeException' );
+   $serializer->deserialize( $notASelectionRequest );
+   }
+
+   public function invalidObjectTypeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( array(
+   'objectType' => 'foobar',
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => 'DESCRIPTION',
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => null,
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => array(),
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => 42,
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   return $argLists;
+   }
+
+   /**
+* @dataProvider missingObjectTypeProvider
+*/
+   public function testCannotDeserilaizeWithoutObjectType( 
$notASelectionRequest ) {
+   $serializer = $this->newSelectionRequestDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notASelectionRequest ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\MissingTypeException' );
+   $serializer->deserialize( $notASelectionRequest );
+   }
+
+   public function missingObjectTypeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( null );
+   $argLists[] = array( array() );
+   $argLists[] = array( 'foo bar' );
+
+   $argLists[] = array( array(
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'ObjectType' => 'sortExpression',
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'OBJECTTYPE' => 'sortExpression',
+   'selectionRequestType' => 'property',
+   'value' => array()
+   ) );
+
+   return $argLists;
+   }
+
+   public function testCannotDeserilaizeWithUnknownDescriptionType() {
+   $notASelectionRequest = array(
+   'objectType' => 'selectionRequest',
+   'selectionRequestType' => 'fooBar',
+   'value' => array()
+   );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\InvalidAttributeException' );
+   $this->newSelectionRequestDeserializ

[MediaWiki-commits] [Gerrit] Introduced TypedObjectDeserializer to avoid code duplication - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Introduced TypedObjectDeserializer to avoid code duplication
..


Introduced TypedObjectDeserializer to avoid code duplication

Change-Id: I03dbd3321a7ddb66651bf98c8129cd8365bc4483
---
M includes/Ask/Deserializers/DescriptionDeserializer.php
M includes/Ask/Deserializers/SortExpressionDeserializer.php
A includes/Ask/Deserializers/TypedObjectDeserializer.php
3 files changed, 188 insertions(+), 109 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Ask/Deserializers/DescriptionDeserializer.php 
b/includes/Ask/Deserializers/DescriptionDeserializer.php
index 0eb7de7..553b25d 100644
--- a/includes/Ask/Deserializers/DescriptionDeserializer.php
+++ b/includes/Ask/Deserializers/DescriptionDeserializer.php
@@ -27,7 +27,7 @@
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < jeroended...@gmail.com >
  */
-class DescriptionDeserializer implements Deserializer {
+class DescriptionDeserializer extends TypedObjectDeserializer {
 
protected $dataValueFactory;
 
@@ -35,62 +35,40 @@
$this->dataValueFactory = $dataValueFactory;
}
 
-   public function deserialize( $serialization ) {
-   $this->assertCanDeserialize( $serialization );
-   return $this->getDeserializedDescription( $serialization );
+   /**
+* @see TypedObjectDeserializer::getObjectType
+*
+* @since 0.1
+*
+* @return string
+*/
+   protected function getObjectType() {
+   return 'description';
}
 
-   protected function assertCanDeserialize( $serialization ) {
-   if ( !$this->hasObjectType( $serialization ) ) {
-   throw new MissingTypeException( $this );
-   }
-
-   if ( !$this->hasCorrectObjectType( $serialization ) ) {
-   throw new UnsupportedTypeException( 
$serialization['objectType'], $this );
-   }
+   /**
+* @see TypedObjectDeserializer::getSubTypeKey
+*
+* @since 0.1
+*
+* @return string
+*/
+   protected function getSubTypeKey() {
+   return 'descriptionType';
}
 
-   public function canDeserialize( $serialization ) {
-   return $this->hasObjectType( $serialization ) && 
$this->hasCorrectObjectType( $serialization );
-   }
-
-   protected function hasCorrectObjectType( $serialization ) {
-   return $serialization['objectType'] === 'description';
-   }
-
-   protected function hasObjectType( $serialization ) {
-   return is_array( $serialization )
-   && array_key_exists( 'objectType', $serialization );
-   }
-
-   protected function getDeserializedDescription( array $serialization ) {
-   if ( !array_key_exists( 'descriptionType', $serialization ) ) {
-   throw new MissingAttributeException(
-   'descriptionType',
-   $this
-   );
-   }
-
-   $this->requireAttribute( $serialization, 'descriptionType' );
-   $this->requireAttribute( $serialization, 'value' );
-   $this->assertAttributeIsArray( $serialization, 'value' );
-
-   $descriptionType = $serialization['descriptionType'];
-   $descriptionValue = $serialization['value'];
-
-   return $this->getDeserializedValue( $descriptionType, 
$descriptionValue );
-   }
-
-   protected function requireAttributes( array $array ) {
-   $requiredAttributes = func_get_args();
-   array_shift( $requiredAttributes );
-
-   foreach ( $requiredAttributes as $attribute ) {
-   $this->requireAttribute( $array, $attribute );
-   }
-   }
-
-   protected function getDeserializedValue( $descriptionType, 
$descriptionValue ) {
+   /**
+* @see TypedObjectDeserializer::getDeserializedValue
+*
+* @since 0.1
+*
+* @param string $descriptionType
+* @param array $descriptionValue
+*
+* @return object
+* @throws DeserializationException
+*/
+   protected function getDeserializedValue( $descriptionType, array 
$descriptionValue ) {
if ( $descriptionType === 'anyValue' ) {
return new AnyValue();
}
@@ -184,24 +162,6 @@
}
 
return $descriptions;
-   }
-
-   protected function requireAttribute( array $array, $attributeName ) {
-   if ( !array_key_exists( $attributeName, $array ) ) {
-   throw new MissingAttributeException(
-   $at

[MediaWiki-commits] [Gerrit] Added DispatchingDeserializer - change (mediawiki...Ask)

2013-07-09 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added DispatchingDeserializer
..


Added DispatchingDeserializer

Change-Id: I53802bf1ebb98887b6fe9d37974d732196d00cdb
---
A Tests/Phpunit/Deserializers/DispatchingDeserializerTest.php
A includes/Ask/Deserializers/DispatchingDeserializer.php
M includes/Ask/Serializers/DispatchingSerializer.php
3 files changed, 198 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Deserializers/DispatchingDeserializerTest.php 
b/Tests/Phpunit/Deserializers/DispatchingDeserializerTest.php
new file mode 100644
index 000..ac31d7a
--- /dev/null
+++ b/Tests/Phpunit/Deserializers/DispatchingDeserializerTest.php
@@ -0,0 +1,123 @@
+
+ */
+class DispatchingDeserializerTest extends \PHPUnit_Framework_TestCase {
+
+   public function testCanConstructWithNoDeserializers() {
+   new DispatchingDeserializer( array() );
+   $this->assertTrue( true );
+   }
+
+   public function testCannotConstructWithNonDeserializers() {
+   $this->setExpectedException( 'InvalidArgumentException' );
+   new DispatchingDeserializer( array( 42, 'foobar' ) );
+   }
+
+   public function testCanDeserialize() {
+   $subDeserializer = $this->getMock( 
'Ask\Deserializers\Deserializer' );
+
+   $subDeserializer->expects( $this->exactly( 4 ) )
+   ->method( 'canDeserialize' )
+   ->will( $this->returnCallback( function( $value ) {
+   return $value > 9000;
+   } ) );
+
+   $serializer = new DispatchingDeserializer( array( 
$subDeserializer ) );
+
+   $this->assertFalse( $serializer->canDeserialize( 0 ) );
+   $this->assertFalse( $serializer->canDeserialize( 42 ) );
+   $this->assertTrue( $serializer->canDeserialize( 9001 ) );
+   $this->assertTrue( $serializer->canDeserialize( 31337 ) );
+   }
+
+   public function testDeserializeWithDeserializableValues() {
+   $subDeserializer = $this->getMock( 
'Ask\Deserializers\Deserializer' );
+
+   $subDeserializer->expects( $this->any() )
+   ->method( 'canDeserialize' )
+   ->will( $this->returnValue( true ) );
+
+   $subDeserializer->expects( $this->any() )
+   ->method( 'deserialize' )
+   ->will( $this->returnValue( 42 ) );
+
+   $serializer = new DispatchingDeserializer( array( 
$subDeserializer ) );
+
+   $this->assertEquals( 42, $serializer->deserialize( 'foo' ) );
+   $this->assertEquals( 42, $serializer->deserialize( null ) );
+   }
+
+   public function testSerializeWithUnserializableValue() {
+   $subDeserializer = $this->getMock( 
'Ask\Deserializers\Deserializer' );
+
+   $subDeserializer->expects( $this->once() )
+   ->method( 'canDeserialize' )
+   ->will( $this->returnValue( false ) );
+
+   $serializer = new DispatchingDeSerializer( array( 
$subDeserializer ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\DeserializationException' );
+   $serializer->deserialize( 0 );
+   }
+
+   public function testSerializeWithMultipleSubSerializers() {
+   $subDeserializer0 = $this->getMock( 
'Ask\Deserializers\Deserializer' );
+
+   $subDeserializer0->expects( $this->any() )
+   ->method( 'canDeserialize' )
+   ->will( $this->returnValue( true ) );
+
+   $subDeserializer0->expects( $this->any() )
+   ->method( 'deserialize' )
+   ->will( $this->returnValue( 42 ) );
+
+   $subDeserializer1 = $this->getMock( 
'Ask\Deserializers\Deserializer' );
+
+   $subDeserializer1->expects( $this->any() )
+   ->method( 'canDeserialize' )
+   ->will( $this->returnValue( false ) );
+
+   $subDeserializer2 = clone $subDeserializer1;
+
+   $serializer = new DispatchingDeserializer( array( 
$subDeserializer1, $subDeserializer0, $subDeserializer2 ) );
+
+   $this->assertEquals( 42, $serializer->deserialize( 'foo' ) );
+   }
+
+   public function testAddSerializer() {
+   $deserializer = new DispatchingDeserializer( array() );
+
+   $subDeserializer = $this->getMock( 
'Ask\Deserializers\Deserializer' );
+
+   $subDeserializer->expects( $this->any() )
+   ->method( 'canDeserialize' )
+   ->will( $this->returnValue( true ) );
+
+   $subDeserializer->expects( $this->any() )

[MediaWiki-commits] [Gerrit] Added SortExpressionDeserializer - change (mediawiki...Ask)

2013-07-08 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added SortExpressionDeserializer
..


Added SortExpressionDeserializer

Change-Id: I8986394c6b4c726a2adc2138b29e72750a9d42b4
---
M Tests/Integration/Serializers/QuerySerialializationTest.php
A Tests/Phpunit/Deserializers/SortExpressionDeserializerTest.php
M Tests/Phpunit/Serializers/SortExpressionSerializerTest.php
M includes/Ask/Deserializers/DescriptionDeserializer.php
A includes/Ask/Deserializers/SortExpressionDeserializer.php
M includes/Ask/Language/Option/PropertyValueSortExpression.php
M includes/Ask/Language/Option/SortExpression.php
7 files changed, 345 insertions(+), 29 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/Tests/Integration/Serializers/QuerySerialializationTest.php 
b/Tests/Integration/Serializers/QuerySerialializationTest.php
index 386e257..a394097 100644
--- a/Tests/Integration/Serializers/QuerySerialializationTest.php
+++ b/Tests/Integration/Serializers/QuerySerialializationTest.php
@@ -120,7 +120,7 @@
'expressions' => (object)array(
array(
'objectType' => 
'sortExpression',
-   'sortExpressionType' => 
'PropertyValue',
+   'sortExpressionType' => 
'propertyValue',
'value' => array(
'direction' => 
SortExpression::ASCENDING, // TODO: this should be a string
'property' => 
$p42->toArray(),
diff --git a/Tests/Phpunit/Deserializers/SortExpressionDeserializerTest.php 
b/Tests/Phpunit/Deserializers/SortExpressionDeserializerTest.php
new file mode 100644
index 000..06d9e11
--- /dev/null
+++ b/Tests/Phpunit/Deserializers/SortExpressionDeserializerTest.php
@@ -0,0 +1,209 @@
+
+ */
+class SortExpressionDeserializerTest extends \PHPUnit_Framework_TestCase {
+
+   protected function newSortExpressionDeserializer() {
+   $dvFactory = new DataValueFactory();
+   $dvFactory->registerDataValue( 'string', 
'DataValues\StringValue' );
+
+   return new SortExpressionDeserializer( $dvFactory );
+   }
+
+   /**
+* @dataProvider invalidObjectTypeProvider
+*/
+   public function testCannotDeserializeWithInvalidObjectType( 
$notADescription ) {
+   $serializer = $this->newSortExpressionDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notADescription ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\UnsupportedTypeException' );
+   $serializer->deserialize( $notADescription );
+   }
+
+   public function invalidObjectTypeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( array(
+   'objectType' => 'foobar',
+   'sortExpressionType' => 'propertyValue',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => 'DESCRIPTION',
+   'sortExpressionType' => 'propertyValue',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => null,
+   'sortExpressionType' => 'propertyValue',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => array(),
+   'sortExpressionType' => 'propertyValue',
+   'value' => array()
+   ) );
+
+   $argLists[] = array( array(
+   'objectType' => 42,
+   'sortExpressionType' => 'propertyValue',
+   'value' => array()
+   ) );
+
+   return $argLists;
+   }
+
+   /**
+* @dataProvider missingObjectTypeProvider
+*/
+   public function testCannotDeserilaizeWithoutObjectType( 
$notADescription ) {
+   $serializer = $this->newSortExpressionDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notADescription ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\MissingTypeException' );
+   $serializer->deserialize( $notADescription );
+   }
+
+   public function missingObjectTypeProvider() {
+   $argLists = array();
+
+   $argLists[] = array( null );
+   $argLists[] = array( array() );
+   $argLists[] = array( 'foo bar' )

[MediaWiki-commits] [Gerrit] Preliminary implementation of DescriptionDeserializer - change (mediawiki...Ask)

2013-07-08 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Preliminary implementation of DescriptionDeserializer
..


Preliminary implementation of DescriptionDeserializer

* Added preliminary DescriptionDeserializer (remaining TODOs are marked)
* Added InvalidAttributeException
* Added MissingAttributeException

Change-Id: I4eefd6e59b83fb3b28438cfc5fd9d9abc679a519
---
A Tests/Phpunit/Deserializers/DescriptionDeserializerTest.php
A Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
A Tests/Phpunit/Deserializers/Exceptions/MissingAttributeExceptionTest.php
A includes/Ask/Deserializers/DescriptionDeserializer.php
A includes/Ask/Deserializers/Exceptions/InvalidAttributeException.php
A includes/Ask/Deserializers/Exceptions/MissingAttributeException.php
6 files changed, 389 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Deserializers/DescriptionDeserializerTest.php 
b/Tests/Phpunit/Deserializers/DescriptionDeserializerTest.php
new file mode 100644
index 000..43897e3
--- /dev/null
+++ b/Tests/Phpunit/Deserializers/DescriptionDeserializerTest.php
@@ -0,0 +1,114 @@
+
+ */
+class DescriptionDeserializerTest extends \PHPUnit_Framework_TestCase {
+
+   /**
+* @dataProvider nonDescriptionProvider
+*/
+   public function testCannotSerializeNonDescriptions( $notADescription ) {
+   $serializer = $this->newDescriptionDeserializer();
+
+   $this->assertFalse( $serializer->canDeserialize( 
$notADescription ) );
+
+   $this->setExpectedException( 
'Ask\Deserializers\Exceptions\UnsupportedTypeException' );
+   $serializer->deserialize( $notADescription );
+   }
+
+   protected function newDescriptionDeserializer() {
+   $dvFactory = new DataValueFactory();
+   $dvFactory->registerDataValue( 'string', 
'DataValues\StringValue' );
+
+   return new DescriptionDeserializer( $dvFactory );
+   }
+
+   public function nonDescriptionProvider() {
+   $argLists = array();
+
+// $argLists[] = array( null );
+// $argLists[] = array( array() );
+// $argLists[] = array( 'foo bar' );
+//
+// $argLists[] = array( array(
+// 'descriptionType' => 'anyValue',
+// 'value' => null
+// ) );
+
+   $argLists[] = array( array(
+   'objectType' => 'foobar',
+   'descriptionType' => 'anyValue',
+   'value' => null
+   ) );
+
+   return $argLists;
+   }
+
+   /**
+* @dataProvider descriptionProvider
+*/
+   public function testSerializeDescription( Description 
$expectedDescription, $serialization ) {
+   $actualDescription = 
$this->newDescriptionDeserializer()->deserialize( $serialization );
+
+   $this->assertEquals( $expectedDescription, $actualDescription );
+   }
+
+   public function descriptionProvider() {
+   $argLists = array();
+
+   $p1337 = new StringValue( '1337prop' );
+
+   $argLists[] = array(
+   new AnyValue(
+   ),
+   array(
+   'objectType' => 'description',
+   'descriptionType' => 'anyValue',
+   'value' => null
+   )
+   );
+
+   $argLists[] = array(
+   new SomeProperty(
+   $p1337,
+   new AnyValue()
+   ),
+   array(
+   'objectType' => 'description',
+   'descriptionType' => 'someProperty',
+   'value' => array(
+   'property' => $p1337->toArray(),
+   'description' => array(
+   'objectType' => 'description',
+   'descriptionType' => 'anyValue',
+   'value' => null
+   ),
+   'isSubProperty' => false
+   ),
+   )
+   );
+
+   return $argLists;
+   }
+
+}
diff --git 
a/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php 
b/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
new file mode 100644
index 000..d8c8eb4
--- /dev/null
+++ b/Tests/Phpunit/Deserializers/Exceptions/InvalidAttributeExceptionTest.php
@@ -0,0 +1,48 @@
+
+ */
+

[MediaWiki-commits] [Gerrit] Ground work for deserialization code - change (mediawiki...Ask)

2013-07-08 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Ground work for deserialization code
..


Ground work for deserialization code

* Added Deserializer interface
* Added DeserializationException
* Added objectType key to serialization so objects can be
  unserialized without the need for further context
* Changed various keys and values in the serialization from
  alllowercase to camelCase

Change-Id: Ibb143de40736a789fd60d864a7c6644453021569
---
M Tests/Integration/Serializers/QuerySerialializationTest.php
A Tests/Phpunit/Deserializers/Exceptions/UnsupportedTypeExceptionTest.php
M Tests/Phpunit/Serializers/DescriptionSerializerTest.php
M Tests/Phpunit/Serializers/QueryOptionsSerializerTest.php
M Tests/Phpunit/Serializers/QuerySerializerTest.php
M Tests/Phpunit/Serializers/SelectionRequestSerializerTest.php
M Tests/Phpunit/Serializers/SortExpressionSerializerTest.php
A includes/Ask/Deserializers/Deserializer.php
A includes/Ask/Deserializers/Exceptions/DeserializationException.php
A includes/Ask/Deserializers/Exceptions/UnsupportedTypeException.php
M includes/Ask/Language/Description/AnyValue.php
M includes/Ask/Language/Description/SomeProperty.php
M includes/Ask/Language/Description/ValueDescription.php
M includes/Ask/Serializers/DescriptionSerializer.php
M includes/Ask/Serializers/Exceptions/SerializationException.php
M includes/Ask/Serializers/Exceptions/UnsupportedObjectException.php
M includes/Ask/Serializers/QueryOptionsSerializer.php
M includes/Ask/Serializers/QuerySerializer.php
M includes/Ask/Serializers/SelectionRequestSerializer.php
M includes/Ask/Serializers/SortExpressionSerializer.php
20 files changed, 218 insertions(+), 36 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Integration/Serializers/QuerySerialializationTest.php 
b/Tests/Integration/Serializers/QuerySerialializationTest.php
index 63f6307..6bd2be3 100644
--- a/Tests/Integration/Serializers/QuerySerialializationTest.php
+++ b/Tests/Integration/Serializers/QuerySerialializationTest.php
@@ -74,66 +74,77 @@
 
protected function getExpectedSerialization( StringValue $p42, 
StringValue $p9001, StringValue $foo ) {
return array(
+   'objectType' => 'query',
'description' => array(
-   'type' => 'conjunction',
+   'objectType' => 'description',
+   'descriptionType' => 'conjunction',
'value' => array(
'descriptions' => array(
array(
-   'type' => 
'someproperty',
+   'objectType' => 
'description',
+   'descriptionType' => 
'someProperty',
'value' => array(
'property' => 
$p42->toArray(),
'description' 
=> array(
-   'type' 
=> 'anyvalue',
+   
'objectType' => 'description',
+   
'descriptionType' => 'anyValue',
'value' 
=> null
),
-   'issubproperty' 
=> false
+   'isSubProperty' 
=> false
),
),
array(
-   'type' => 
'someproperty',
+   'objectType' => 
'description',
+   'descriptionType' => 
'someProperty',
'value' => array(
'property' => 
$p9001->toArray(),
'description' 
=> array(
-   'type' 
=> 'valuedescription',
+   
'objectType' => 'description',
+   
'descriptionType' => 'valueDescription',
  

[MediaWiki-commits] [Gerrit] Make MultiLangSerializationOptions aware of fallback chains - change (mediawiki...Wikibase)

2013-07-05 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Make MultiLangSerializationOptions aware of fallback chains
..


Make MultiLangSerializationOptions aware of fallback chains

Change-Id: I61e51f32f1e495e885210a835f37dd9c41a670af
---
M lib/includes/serializers/SerializationOptions.php
M lib/tests/phpunit/serializers/SerializationOptionsTest.php
2 files changed, 154 insertions(+), 10 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/serializers/SerializationOptions.php 
b/lib/includes/serializers/SerializationOptions.php
index d713702..a026d76 100644
--- a/lib/includes/serializers/SerializationOptions.php
+++ b/lib/includes/serializers/SerializationOptions.php
@@ -1,10 +1,12 @@
 languageCodes = $languageCodes;
+   public function setLanguages( array $languages = null ) {
+   if ( $languages === null ) {
+   $this->languages = null;
+
+   return;
+   }
+
+   $this->languages = array();
+
+   foreach ( $languages as $languageCode => $languageFallbackChain 
) {
+   // back-compat
+   if ( is_numeric( $languageCode ) ) {
+   $languageCode = $languageFallbackChain;
+   $languageFallbackChain = 
$this->getLanguageFallbackChainFactory()->newFromLanguage(
+   Language::factory( $languageCode ), 
LanguageFallbackChainFactory::FALLBACK_SELF
+   );
+   }
+
+   $this->languages[$languageCode] = 
$languageFallbackChain;
+   }
}
 
/**
@@ -159,7 +191,50 @@
 * @return array|null
 */
public function getLanguages() {
-   return $this->languageCodes;
+   if ( $this->languages === null ) {
+   return null;
+   } else {
+   return array_keys( $this->languages );
+   }
+   }
+
+   /**
+* Gets an associative array with language codes as keys and their 
fallback chains as values, or null.
+*
+* @since 0.4
+*
+* @return array|null
+*/
+   public function getLanguageFallbackChains() {
+   return $this->languages;
+   }
+
+   /**
+* Get the language fallback chain factory previously set, or a new one 
if none was set.
+*
+* @since 0.4
+*
+* @return LanguageFallbackChainFactory
+*/
+   public function getLanguageFallbackChainFactory() {
+   if ( $this->languageFallbackChainFactory === null ) {
+   $this->languageFallbackChainFactory = new 
LanguageFallbackChainFactory();
+   }
+
+   return $this->languageFallbackChainFactory;
+   }
+
+   /**
+* Set language fallback chain factory and return the previously set 
one.
+*
+* @since 0.4
+*
+* @param LanguageFallbackChainFactory $factory
+*
+* @return LanguageFallbackChainFactory|null
+*/
+   public function setLanguageFallbackChainFactory( 
LanguageFallbackChainFactory $factory ) {
+   return wfSetVar( $this->languageFallbackChainFactory, $factory 
);
}
 }
 
diff --git a/lib/tests/phpunit/serializers/SerializationOptionsTest.php 
b/lib/tests/phpunit/serializers/SerializationOptionsTest.php
index 1cf5114..106ba97 100644
--- a/lib/tests/phpunit/serializers/SerializationOptionsTest.php
+++ b/lib/tests/phpunit/serializers/SerializationOptionsTest.php
@@ -2,6 +2,8 @@
 
 namespace Wikibase\Test;
 use Wikibase\Lib\Serializers\SerializationOptions;
+use Wikibase\Lib\Serializers\MultiLangSerializationOptions;
+use Wikibase\LanguageFallbackChainFactory;
 
 /**
  * Tests for the Wikibase\SerializationOptions class.
@@ -33,12 +35,79 @@
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < jeroended...@gmail.com >
+ * @author Liangent < liang...@gmail.com >
  */
 class SerializationOptionsTest extends \MediaWikiTestCase {
 
-   public function testConstructor() {
+   public function testSerializationOptionsConstructor() {
new SerializationOptions();
$this->assertTrue( true );
}
 
+   public function testMultiLangSerializationOptionsConstructor() {
+   new MultiLangSerializationOptions();
+   $this->assertTrue( true );
+   }
+
+   private function preprocessTestMultiLangSerializationOptionsLanguages( 
$languages ) {
+   if ( $languages === null ) {
+   return null;
+   }
+
+   $factory = new LanguageFallbackChainFactory();
+
+   foreach ( $languages as $languageKey => &$languageValu

[MediaWiki-commits] [Gerrit] Improve class LanguageFallbackChain and its factory - change (mediawiki...Wikibase)

2013-07-05 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Improve class LanguageFallbackChain and its factory
..


Improve class LanguageFallbackChain and its factory

Change-Id: I55516170998e983ef7bc0b7c99cf63d31098d46c
---
M lib/includes/LanguageFallbackChain.php
M lib/includes/LanguageFallbackChainFactory.php
M lib/tests/phpunit/LanguageFallbackChainFactoryTest.php
3 files changed, 157 insertions(+), 24 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/LanguageFallbackChain.php 
b/lib/includes/LanguageFallbackChain.php
index e9e78e5..ee91987 100644
--- a/lib/includes/LanguageFallbackChain.php
+++ b/lib/includes/LanguageFallbackChain.php
@@ -66,13 +66,14 @@
public function extractPreferredValue( $data ) {
 
foreach ( $this->chain as $languageWithConversion ) {
-   if ( isset( 
$data[$languageWithConversion->getFetchLanguage()->getCode()] ) ) {
+   $fetchCode = 
$languageWithConversion->getFetchLanguage()->getCode();
+   $languageCode = 
$languageWithConversion->getLanguage()->getCode();
+
+   if ( isset( $data[$fetchCode] ) ) {
return array(
-   'value' => 
$languageWithConversion->translate(
-   
$data[$languageWithConversion->getFetchLanguage()->getCode()]
-   ),
-   'language' => 
$languageWithConversion->getLanguage()->getCode(),
-   'source' => 
$languageWithConversion->getFetchLanguage()->getCode(),
+   'value' => 
$languageWithConversion->translate( $data[$fetchCode] ),
+   'language' => $languageCode,
+   'source' => $fetchCode,
);
}
}
diff --git a/lib/includes/LanguageFallbackChainFactory.php 
b/lib/includes/LanguageFallbackChainFactory.php
index e5ede9d..5bcfda1 100644
--- a/lib/includes/LanguageFallbackChainFactory.php
+++ b/lib/includes/LanguageFallbackChainFactory.php
@@ -84,14 +84,17 @@
}
 
/**
-* Build fallback chain for a given language.
+* Build fallback chain array for a given language.
 *
 * @param Language $language
 * @param $mode bitfield of self::FALLBACK_*
 * @param LanguageFallbackChain[] $chain for recursive calls
 * @param array $fetched for recursive calls
+*
+* @return LanguageWithConversion[]
 */
-   private function buildFromLanguage( Language $language, $mode, &$chain 
= array(), &$fetched = array() ) {
+   public function buildFromLanguage( Language $language, $mode, &$chain = 
array(), &$fetched = array() ) {
+   wfProfileIn( __METHOD__ );
 
if ( $mode & self::FALLBACK_SELF ) {
if ( !isset( $fetched[$language->getCode()] ) ) {
@@ -140,6 +143,7 @@
}
}
 
+   wfProfileOut( __METHOD__ );
return $chain;
}
 
@@ -152,15 +156,20 @@
 */
public function newFromContext( IContextSource $context ) {
global $wgBabelCategoryNames;
+   wfProfileIn( __METHOD__ );
 
$user = $context->getUser();
 
if ( !class_exists( 'Babel' ) || $user->isAnon() ) {
-   return $this->newFromLanguage( $context->getLanguage(), 
self::FALLBACK_ALL );
+   $cached =  $this->newFromLanguage( 
$context->getLanguage(), self::FALLBACK_ALL );
+   wfProfileOut( __METHOD__ );
+   return $cached;
}
 
if ( isset( 
$this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()] 
) ) {
-   return 
$this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()];
+   $cached = 
$this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()];
+   wfProfileOut( __METHOD__ );
+   return $cached;
}
 
$babel = array();
@@ -187,15 +196,19 @@
 

$this->userLanguageCache[$user->getName()][$context->getLanguage()->getCode()] 
= $languageFallbackChain;
 
+   wfProfileOut( __METHOD__ );
return $languageFallbackChain;
}
 
/**
-* Build fallback chain for a given babel array.
+* Build fallback chain array for a given babel array.
 *
 * @param array $babel
+*
+* @return LanguageWithConversion[]
 */
-  

[MediaWiki-commits] [Gerrit] Fix action=purge for Special:EntityData - change (mediawiki...Wikibase)

2013-05-29 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fix action=purge for Special:EntityData
..


Fix action=purge for Special:EntityData

Previous check was silly.

Change-Id: Ie92e8245e5f665432fa4c07142c3644e51552af5
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Verified; Looks good to me, approved



diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index bb41151..7fd2b9a 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -155,7 +155,7 @@
}
 
//XXX: allow for logged in users only?
-   if ( $this->getRequest()->getText( 'action', 'purge' ) ) {
+   if ( $this->getRequest()->getText( 'action' ) === 'purge' ) {
$this->purge( $id, $format, $revision );
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie92e8245e5f665432fa4c07142c3644e51552af5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf5
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] Fix action=purge for Special:EntityData - change (mediawiki...Wikibase)

2013-05-29 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fix action=purge for Special:EntityData
..


Fix action=purge for Special:EntityData

Previous check was silly.

Change-Id: Ie92e8245e5f665432fa4c07142c3644e51552af5
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index bb41151..7fd2b9a 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -155,7 +155,7 @@
}
 
//XXX: allow for logged in users only?
-   if ( $this->getRequest()->getText( 'action', 'purge' ) ) {
+   if ( $this->getRequest()->getText( 'action' ) === 'purge' ) {
$this->purge( $id, $format, $revision );
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie92e8245e5f665432fa4c07142c3644e51552af5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Denny Vrandecic 
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 EntityUpdater - change (mediawiki...Wikibase)

2013-05-29 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added EntityUpdater
..


Added EntityUpdater

Change-Id: I809273a8b21ff08522c9d9331b8f917478e51cc8
---
A QueryEngine/includes/SQLStore/EntityUpdater.php
A QueryEngine/tests/phpunit/SQLStore/EntityUpdaterTest.php
2 files changed, 170 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/EntityUpdater.php 
b/QueryEngine/includes/SQLStore/EntityUpdater.php
new file mode 100644
index 000..255d735
--- /dev/null
+++ b/QueryEngine/includes/SQLStore/EntityUpdater.php
@@ -0,0 +1,57 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseSQLStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class EntityUpdater {
+
+   private $remover;
+   private $inserter;
+
+   /**
+* @since 0.1
+*
+*/
+   public function __construct( EntityRemover $remover, EntityInserter 
$inserter ) {
+   $this->remover = $remover;
+   $this->inserter = $inserter;
+   }
+
+   /**
+* @since 0.1
+*
+* @param Entity $entity
+*/
+   public function updateEntity( Entity $entity ) {
+   $this->remover->removeEntity( $entity );
+   $this->inserter->insertEntity( $entity );
+   }
+
+}
diff --git a/QueryEngine/tests/phpunit/SQLStore/EntityUpdaterTest.php 
b/QueryEngine/tests/phpunit/SQLStore/EntityUpdaterTest.php
new file mode 100644
index 000..d449278
--- /dev/null
+++ b/QueryEngine/tests/phpunit/SQLStore/EntityUpdaterTest.php
@@ -0,0 +1,113 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseQueryEngineTest
+ *
+ * @group Wikibase
+ * @group WikibaseQueryEngine
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class EntityUpdaterTest extends \PHPUnit_Framework_TestCase {
+
+   /**
+* @dataProvider entityProvider
+*/
+   public function testUpdateEntity( Entity $entity ) {
+   $remover = $this->getMockBuilder( 
'Wikibase\QueryEngine\SQLStore\EntityRemover' )
+   ->disableOriginalConstructor()
+   ->getMock();
+
+   $remover->expects( $this->once() )
+   ->method( 'removeEntity' )
+   ->with( $this->equalTo( $entity ) );
+
+   $inserter = $this->getMockBuilder( 
'Wikibase\QueryEngine\SQLStore\EntityInserter' )
+   ->disableOriginalConstructor()
+   ->getMock();
+
+   $inserter->expects( $this->once() )
+   ->method( 'insertEntity' )
+   ->with( $this->equalTo( $entity ) );
+
+   $updater = new EntityUpdater( $remover, $inserter );
+
+   $updater->updateEntity( $entity );
+   }
+
+   public function entityProvider() {
+   $argLists = array();
+
+   $item = Item::newEmpty();
+   $item->setId( 42 );
+
+   $argLists[] = array( $item );
+
+
+   $item = Item::newEmpty();
+   $item->setId( 31337 );
+
+   $argLists[] = array( $item );
+
+
+   $property = Property::newEmpty();
+   $property->setDataTypeId( 'string' );
+   $property->setId( 9001 );
+
+   $argLists[] = array( $property );
+
+
+   $property = Property::newEmpty();
+   $property->setDataTypeId( 'string' );
+   $property->setId( 1 );
+   $property->addAliases( 'en', array( 'foo', 'bar', 'baz' ) );
+   $property->addClaim( new Claim( new PropertyNoValueSnak( 42 ) ) 
);
+
+   $argLists[] = array( $property );
+
+
+   $item = Item::newEmpty();
+   $item->setId( 2 );
+   $item->addClaim( new Claim( new PropertyNoValueSnak( 42 ) ) );
+   $item->addClaim( new Claim( new PropertyNoValueSnak( 43 ) ) );
+   $item->addClaim( new Claim( new PropertyNoValueSnak( 44 ) ) );
+
+   $argLists[] = array( $item );
+
+   return $argLists;
+   }
+
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I809273a8b21ff08522c9d9331b8f917478e51cc8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Hooked up EntityRemover to lower level components - change (mediawiki...Wikibase)

2013-05-29 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Hooked up EntityRemover to lower level components
..


Hooked up EntityRemover to lower level components

Change-Id: I97f44b88051c5e3dd65e0d84b8233056ed775e72
---
D QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php
M QueryEngine/includes/SQLStore/ClaimStore/ClaimsTable.php
M QueryEngine/includes/SQLStore/EntityRemover.php
D QueryEngine/tests/phpunit/SQLStore/ClaimStore/ClaimRemoverTest.php
M QueryEngine/tests/phpunit/SQLStore/ClaimStore/ClaimsTableTest.php
M QueryEngine/tests/phpunit/SQLStore/EntityRemoverTest.php
6 files changed, 53 insertions(+), 225 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php 
b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php
deleted file mode 100644
index 7d2ef43..000
--- a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php
+++ /dev/null
@@ -1,71 +0,0 @@
-http://www.gnu.org/copyleft/gpl.html
- *
- * @since 0.1
- *
- * @file
- * @ingroup WikibaseSQLStore
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < jeroended...@gmail.com >
- */
-class ClaimRemover {
-
-// protected $claimsTable;
-// protected $snakInserter;
-// protected $claimRowBuilder;
-//
-// public function __construct( ClaimsTable $claimsTable, SnakInserter 
$snakInserter, ClaimRowBuilder $claimRowBuilder ) {
-// $this->claimsTable = $claimsTable;
-// $this->snakInserter = $snakInserter;
-// $this->claimRowBuilder = $claimRowBuilder;
-// }
-
-   /**
-* @param Claim $claim
-* @param int $internalSubjectId
-*/
-   public function removeClaim( Claim $claim, $internalSubjectId ) {
-// $internalClaimId = $this->insertIntoClaimsTable( $claim, 
$internalSubjectId );
-// $this->insertSnaks( $claim, $internalClaimId, 
$internalSubjectId );
-   }
-
-// protected function insertIntoClaimsTable( Claim $claim, 
$internalSubjectId ) {
-// $claimRow = $this->claimRowBuilder->newClaimRow( $claim, 
$internalSubjectId );
-// return $this->claimsTable->insertClaimRow( $claimRow );
-// }
-//
-// protected function insertSnaks( Claim $claim, $internalClaimId, 
$internalSubjectId ) {
-// $this->insertSnak( $claim->getMainSnak(), SnakRole::MAIN_SNAK, 
$internalClaimId, $internalSubjectId );
-//
-// foreach ( $claim->getQualifiers() as $qualifier ) {
-// $this->insertSnak( $qualifier, SnakRole::QUALIFIER, 
$internalClaimId, $internalSubjectId );
-// }
-// }
-//
-// protected function insertSnak( Snak $snak, $snakRole, $internalClaimId, 
$internalSubjectId ) {
-// $this->snakInserter->insertSnak( $snak, $snakRole, 
$internalClaimId, $internalSubjectId );
-// }
-
-}
diff --git a/QueryEngine/includes/SQLStore/ClaimStore/ClaimsTable.php 
b/QueryEngine/includes/SQLStore/ClaimStore/ClaimsTable.php
index 970cacf..b312789 100644
--- a/QueryEngine/includes/SQLStore/ClaimStore/ClaimsTable.php
+++ b/QueryEngine/includes/SQLStore/ClaimStore/ClaimsTable.php
@@ -71,4 +71,13 @@
);
}
 
+   public function removeClaimsOfSubject( $internalSubjectId ) {
+   $this->queryInterface->delete(
+   $this->tableName,
+   array(
+   'subject_id' => $internalSubjectId
+   )
+   );
+   }
+
 }
diff --git a/QueryEngine/includes/SQLStore/EntityRemover.php 
b/QueryEngine/includes/SQLStore/EntityRemover.php
index 260e63d..6d4363c 100644
--- a/QueryEngine/includes/SQLStore/EntityRemover.php
+++ b/QueryEngine/includes/SQLStore/EntityRemover.php
@@ -5,6 +5,8 @@
 use Wikibase\Entity;
 use Wikibase\EntityId;
 use Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimRemover;
+use Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimsTable;
+use Wikibase\QueryEngine\SQLStore\SnakStore\SnakRemover;
 
 /**
  * Use case for removing entities from the store.
@@ -34,18 +36,21 @@
  */
 class EntityRemover {
 
-   private $claimRemover;
+   private $claimsTable;
private $idFinder;
+   private $snakRemover;
 
/**
 * @since 0.1
 *
-* @param ClaimRemover $claimRemover
+* @param ClaimsTable $claimsTable
+* @param SnakRemover $snakRemover
 * @param InternalEntityIdFinder $idFinder
 */
-   public function __construct( ClaimRemover $claimRemover, 
InternalEntityIdFinder $idFinder ) {
-   $this->claimRemover = $claimRemover;
+   public function __construct( ClaimsTable $claimsTable, SnakRemover 
$snakRemover, InternalEntityIdFinder $idFinder ) {
+   $this->claimsTable = $claimsTable;
$this->idFinder = $idFinder;
+ 

[MediaWiki-commits] [Gerrit] Added testPatchMapRaisesError to ListPatcherTest - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added testPatchMapRaisesError to ListPatcherTest
..


Added testPatchMapRaisesError to ListPatcherTest

Also removed an unreachable line in ListPatcher

Change-Id: I49e99e31b478206148bdbe1689e36ba2098be333
---
M includes/patcher/ListPatcher.php
M tests/phpunit/patcher/ListPatcherTest.php
2 files changed, 11 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/patcher/ListPatcher.php b/includes/patcher/ListPatcher.php
index b005d0a..03ad3bb 100644
--- a/includes/patcher/ListPatcher.php
+++ b/includes/patcher/ListPatcher.php
@@ -67,8 +67,6 @@
 
unset( $base[$key] );
break;
-   default:
-   $this->handleError( 'Non-add and 
non-remove diff operation cannot be applied to a list' );
}
}
 
diff --git a/tests/phpunit/patcher/ListPatcherTest.php 
b/tests/phpunit/patcher/ListPatcherTest.php
index 6b67937..a02f521 100644
--- a/tests/phpunit/patcher/ListPatcherTest.php
+++ b/tests/phpunit/patcher/ListPatcherTest.php
@@ -237,4 +237,15 @@
return $argLists;
}
 
+   public function testPatchMapRaisesError() {
+   $patcher = new ListPatcher();
+
+   $patcher->patch( array(), new Diff( array(), true ) );
+
+   $patcher->throwErrors();
+   $this->setExpectedException( 'Diff\PatcherException' );
+
+   $patcher->patch( array(), new Diff( array(), true ) );
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I49e99e31b478206148bdbe1689e36ba2098be333
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Jeroen De Dauw 
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 EntityRemover - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added EntityRemover
..


Added EntityRemover

Change-Id: I7c2781d400b7008a936703f406622fdbdf4f214f
---
A QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php
A QueryEngine/includes/SQLStore/EntityRemover.php
M QueryEngine/includes/SQLStore/EntityTable.php
A QueryEngine/tests/phpunit/SQLStore/ClaimStore/ClaimRemoverTest.php
A QueryEngine/tests/phpunit/SQLStore/EntityRemoverTest.php
5 files changed, 411 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php 
b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php
new file mode 100644
index 000..7d2ef43
--- /dev/null
+++ b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRemover.php
@@ -0,0 +1,71 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseSQLStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class ClaimRemover {
+
+// protected $claimsTable;
+// protected $snakInserter;
+// protected $claimRowBuilder;
+//
+// public function __construct( ClaimsTable $claimsTable, SnakInserter 
$snakInserter, ClaimRowBuilder $claimRowBuilder ) {
+// $this->claimsTable = $claimsTable;
+// $this->snakInserter = $snakInserter;
+// $this->claimRowBuilder = $claimRowBuilder;
+// }
+
+   /**
+* @param Claim $claim
+* @param int $internalSubjectId
+*/
+   public function removeClaim( Claim $claim, $internalSubjectId ) {
+// $internalClaimId = $this->insertIntoClaimsTable( $claim, 
$internalSubjectId );
+// $this->insertSnaks( $claim, $internalClaimId, 
$internalSubjectId );
+   }
+
+// protected function insertIntoClaimsTable( Claim $claim, 
$internalSubjectId ) {
+// $claimRow = $this->claimRowBuilder->newClaimRow( $claim, 
$internalSubjectId );
+// return $this->claimsTable->insertClaimRow( $claimRow );
+// }
+//
+// protected function insertSnaks( Claim $claim, $internalClaimId, 
$internalSubjectId ) {
+// $this->insertSnak( $claim->getMainSnak(), SnakRole::MAIN_SNAK, 
$internalClaimId, $internalSubjectId );
+//
+// foreach ( $claim->getQualifiers() as $qualifier ) {
+// $this->insertSnak( $qualifier, SnakRole::QUALIFIER, 
$internalClaimId, $internalSubjectId );
+// }
+// }
+//
+// protected function insertSnak( Snak $snak, $snakRole, $internalClaimId, 
$internalSubjectId ) {
+// $this->snakInserter->insertSnak( $snak, $snakRole, 
$internalClaimId, $internalSubjectId );
+// }
+
+}
diff --git a/QueryEngine/includes/SQLStore/EntityRemover.php 
b/QueryEngine/includes/SQLStore/EntityRemover.php
new file mode 100644
index 000..fa25cf8
--- /dev/null
+++ b/QueryEngine/includes/SQLStore/EntityRemover.php
@@ -0,0 +1,76 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseSQLStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class EntityRemover {
+
+   private $claimRemover;
+   private $idFinder;
+
+   /**
+* @since 0.1
+*
+* @param ClaimRemover $claimRemover
+* @param InternalEntityIdFinder $idFinder
+*/
+   public function __construct( ClaimRemover $claimRemover, 
InternalEntityIdFinder $idFinder ) {
+   $this->claimRemover = $claimRemover;
+   $this->idFinder = $idFinder;
+   }
+
+   /**
+* @since 0.1
+*
+* @param Entity $entity
+*/
+   public function removeEntity( Entity $entity ) {
+   $internalSubjectId = $this->getInternalId( $entity->getId() );
+
+   foreach ( $entity->getClaims() as $claim ) {
+   $this->claimRemover->removeClaim(
+   $claim,
+   $internalSubjectId
+   );
+   }
+
+   // TODO: obtain and remove virtual claims
+   }
+
+   protected function getInternalId( EntityId $entityId ) {
+   return $this->idFinder->getInternalIdForEntity(
+   $entityId->getEntityType(),
+   $entityId->getNumericId()
+   );
+   }
+
+}
diff --git a/QueryEngine/includes/SQLStore/EntityTable.php 
b/QueryEngine/includes/SQLStore/EntityTable.php
index 9e9c1e7..4c08ae8 100644
--- a/QueryEngine/includes/SQLStore/EntityTable.php
+++ b/QueryEngine/includes/SQLStore/EntityTable.php
@@ -65,4 +65,14 @@
);
}
 
+
+   /**
+* @since 0.1
+*
+* @param Entity $entity
+*/
+   public function removeEntity( Entity $entity 

[MediaWiki-commits] [Gerrit] Fix fetching of a TableBuilder after it got moved about - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fix fetching of a TableBuilder after it got moved about
..


Fix fetching of a TableBuilder after it got moved about

Change-Id: I55f04c4e81ba20c5e97236a39519ba79f38dc6d2
---
M QueryEngine/includes/SQLStore/Store.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/Store.php 
b/QueryEngine/includes/SQLStore/Store.php
index 68a7cfa..9b4a30b 100644
--- a/QueryEngine/includes/SQLStore/Store.php
+++ b/QueryEngine/includes/SQLStore/Store.php
@@ -119,7 +119,7 @@
$this->config,
$this->factory->getSchema(),
$this->queryInterface,
-   $this->tableBuilder,
+   $this->factory->getTableBuilder(),
$messageReporter
);
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I55f04c4e81ba20c5e97236a39519ba79f38dc6d2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] Implemented ValuelessSnakStore->removeSnaksOfSubject - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Implemented ValuelessSnakStore->removeSnaksOfSubject
..


Implemented ValuelessSnakStore->removeSnaksOfSubject

Change-Id: Ie6a7bd62fe67465c4794c07f1bc695a95749c89b
---
M QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
2 files changed, 25 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
index 0959559..8f57013 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
@@ -65,7 +65,10 @@
}
 
public function removeSnaksOfSubject( $internalSubjectId ) {
-
+   $this->queryInterface->delete(
+   $this->tableName,
+   array( 'subject_id' => $internalSubjectId )
+   );
}
 
 }
diff --git 
a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php 
b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
index 0c45706..9bdf06f 100644
--- a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
@@ -138,4 +138,25 @@
$store->storeSnakRow( $snakRow );
}
 
+   public function testRemoveSnaksOfSubject() {
+   $internalSubjectId = 4242;
+   $tableName = 'test_snaks_nyan';
+
+   $queryInterface = $this->getMock( 
'Wikibase\Database\QueryInterface' );
+
+   $queryInterface->expects( $this->once() )
+   ->method( 'delete' )
+   ->with(
+   $this->equalTo( $tableName ),
+   $this->equalTo( array( 'subject_id' => 
$internalSubjectId ) )
+   );
+
+   $store = new ValuelessSnakStore(
+   $queryInterface,
+   $tableName
+   );
+
+   $store->removeSnaksOfSubject( $internalSubjectId );
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie6a7bd62fe67465c4794c07f1bc695a95749c89b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] Implemented ValueSnakStore->removeSnaksOfSubject - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Implemented ValueSnakStore->removeSnaksOfSubject
..


Implemented ValueSnakStore->removeSnaksOfSubject

Change-Id: I12700dc1e898fccf2f6254302fcefdfc2a127e57
---
M QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
2 files changed, 31 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
index b0fcc15..4f3e80e 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
@@ -98,7 +98,12 @@
}
 
public function removeSnaksOfSubject( $internalSubjectId ) {
-
+   foreach ( $this->dataValueHandlers as $dvHandler ) {
+   $this->queryInterface->delete(
+   
$dvHandler->getDataValueTable()->getTableDefinition()->getName(),
+   array( 'subject_id' => $internalSubjectId )
+   );
+   }
}
 
 }
diff --git 
a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php 
b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
index 61d3046..efe3a82 100644
--- a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
@@ -179,4 +179,29 @@
$store->storeSnakRow( $snakRow );
}
 
+   public function testRemoveSnaksOfSubject() {
+   $internalSubjectId = 4242;
+
+   $stringHandler = $this->newStringHandler();
+
+   $queryInterface = $this->getMock( 
'Wikibase\Database\QueryInterface' );
+
+   $queryInterface->expects( $this->atLeastOnce() )
+   ->method( 'delete' )
+   ->with(
+   $this->equalTo( 
$stringHandler->getDataValueTable()->getTableDefinition()->getName() ),
+   $this->equalTo( array( 'subject_id' => 
$internalSubjectId ) )
+   );
+
+   $store = new ValueSnakStore(
+   $queryInterface,
+   array(
+   'string' => $stringHandler
+   ),
+   SnakRole::MAIN_SNAK
+   );
+
+   $store->removeSnaksOfSubject( $internalSubjectId );
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I12700dc1e898fccf2f6254302fcefdfc2a127e57
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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 @throws docs - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added @throws docs
..


Added @throws docs

Change-Id: I47c7ad264501c884be28566167fd4dd17e6f03de
---
M includes/patcher/ListPatcher.php
M includes/patcher/MapPatcher.php
M includes/patcher/ThrowingPatcher.php
3 files changed, 3 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/includes/patcher/ListPatcher.php b/includes/patcher/ListPatcher.php
index b005d0a..3525e57 100644
--- a/includes/patcher/ListPatcher.php
+++ b/includes/patcher/ListPatcher.php
@@ -43,6 +43,7 @@
 * @param Diff $diff
 *
 * @return array
+* @throws PatcherException
 */
public function patch( array $base, Diff $diff ) {
if ( $this->throwErrors && $diff->looksAssociative() ) {
diff --git a/includes/patcher/MapPatcher.php b/includes/patcher/MapPatcher.php
index fc6e82a..9354107 100644
--- a/includes/patcher/MapPatcher.php
+++ b/includes/patcher/MapPatcher.php
@@ -4,7 +4,6 @@
 
 use Diff\Comparer\StrictComparer;
 use Diff\Comparer\ValueComparer;
-use RuntimeException;
 
 /**
  * Map patcher.
@@ -80,7 +79,7 @@
 * @param Diff $diff
 *
 * @return array
-* @throws RuntimeException
+* @throws PatcherException
 */
public function patch( array $base, Diff $diff ) {
/**
diff --git a/includes/patcher/ThrowingPatcher.php 
b/includes/patcher/ThrowingPatcher.php
index da0eb7a..658723e 100644
--- a/includes/patcher/ThrowingPatcher.php
+++ b/includes/patcher/ThrowingPatcher.php
@@ -88,6 +88,7 @@
 * @param Diff $diff
 *
 * @return Diff
+* @throws PatcherException
 */
public function getApplicableDiff( array $base, Diff $diff ) {
$throwErrors = $this->throwErrors;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I47c7ad264501c884be28566167fd4dd17e6f03de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 Set and RemoveQualifier api modules out of experimental - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Move Set and RemoveQualifier api modules out of experimental
..


Move Set and RemoveQualifier api modules out of experimental

we've had qualifiers for a while now

Change-Id: Icabf411478590103f198f6630abcaf6176c902e2
---
M repo/Wikibase.classes.php
M repo/Wikibase.hooks.php
M repo/Wikibase.php
M repo/config/Wikibase.experimental.php
4 files changed, 6 insertions(+), 6 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/Wikibase.classes.php b/repo/Wikibase.classes.php
index 5b6fb22..55b67c0 100644
--- a/repo/Wikibase.classes.php
+++ b/repo/Wikibase.classes.php
@@ -85,6 +85,8 @@
'Wikibase\Api\SetReference' => 'includes/api/SetReference.php',
'Wikibase\Api\RemoveReferences' => 
'includes/api/RemoveReferences.php',
'Wikibase\Api\SetClaim' => 'includes/api/SetClaim.php',
+   'Wikibase\Api\RemoveQualifiers' => 
'includes/api/RemoveQualifiers.php',
+   'Wikibase\Api\SetQualifier' => 'includes/api/SetQualifier.php',
 
// includes/content
'Wikibase\EntityContent' => 
'includes/content/EntityContent.php',
diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index 5b1114b..45a63bc 100755
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -183,6 +183,8 @@
'api/SetReference',
'api/RemoveReferences',
'api/SetClaim',
+   'api/RemoveQualifiers',
+   'api/SetQualifier',
 
'content/EntityContentFactory',
'content/EntityHandler',
diff --git a/repo/Wikibase.php b/repo/Wikibase.php
index 5a9b682..5c0dc80 100755
--- a/repo/Wikibase.php
+++ b/repo/Wikibase.php
@@ -114,6 +114,8 @@
 $wgAPIModules['wbsetreference']= 
'Wikibase\Api\SetReference';
 $wgAPIModules['wbremovereferences']= 
'Wikibase\Api\RemoveReferences';
 $wgAPIModules['wbsetclaim']= 
'Wikibase\Api\SetClaim';
+$wgAPIModules['wbremovequalifiers'] = 
'Wikibase\Api\RemoveQualifiers';
+$wgAPIModules['wbsetqualifier'] = 
'Wikibase\Api\SetQualifier';
 
 // Special page registration
 $wgSpecialPages['NewItem'] 
= 'SpecialNewItem';
diff --git a/repo/config/Wikibase.experimental.php 
b/repo/config/Wikibase.experimental.php
index ef1f13d..3668584 100644
--- a/repo/config/Wikibase.experimental.php
+++ b/repo/config/Wikibase.experimental.php
@@ -40,14 +40,10 @@
 
 $dir = __DIR__ . '/../';
 
-$wgAutoloadClasses['Wikibase\Api\RemoveQualifiers']= $dir . 
'includes/api/RemoveQualifiers.php';
-$wgAutoloadClasses['Wikibase\Api\SetQualifier']= $dir . 
'includes/api/SetQualifier.php';
 $wgAutoloadClasses['Wikibase\Api\SetStatementRank']= $dir . 
'includes/api/SetStatementRank.php';
 
 unset( $dir );
 
-$wgAPIModules['wbremovequalifiers']= 
'Wikibase\Api\RemoveQualifiers';
-$wgAPIModules['wbsetqualifier']= 
'Wikibase\Api\SetQualifier';
 $wgAPIModules['wbsetstatementrank']= 
'Wikibase\Api\SetStatementRank';
 
 /**
@@ -63,9 +59,7 @@
 $wgHooks['UnitTestsList'][] = function( array &$files ) {
// @codeCoverageIgnoreStart
$testFiles = array(
-   'api/RemoveQualifiers',
'api/SetStatementRank',
-   'api/SetQualifier',
);
 
foreach ( $testFiles as $file ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icabf411478590103f198f6630abcaf6176c902e2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Denny Vrandecic 
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] Fixed paths in test suite config - change (mediawiki...DataValues)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fixed paths in test suite config
..


Fixed paths in test suite config

Change-Id: I5a55b88217f172df2698ab991812c5f158775ae2
---
M phpunit.xml.dist
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index ed2c202..d862e4a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -23,8 +23,8 @@
 ValueFormatters/tests
 
 
-/ValueParsers/tests
-/DataValues/ValueParsers/tests/includes/api
+ValueParsers/tests
+ValueParsers/tests/includes/api
 
 
 ValueValidators/tests

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5a55b88217f172df2698ab991812c5f158775ae2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 testErrorOnUnknownDiffOpType to MapPatcherTest - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added testErrorOnUnknownDiffOpType to MapPatcherTest
..


Added testErrorOnUnknownDiffOpType to MapPatcherTest

Change-Id: I7b764195a7d752325afd5f5a8c92668cd849fc29
---
M tests/phpunit/patcher/MapPatcherTest.php
1 file changed, 19 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/patcher/MapPatcherTest.php 
b/tests/phpunit/patcher/MapPatcherTest.php
index adf38a6..e389c82 100644
--- a/tests/phpunit/patcher/MapPatcherTest.php
+++ b/tests/phpunit/patcher/MapPatcherTest.php
@@ -360,4 +360,23 @@
$this->assertEquals( $expectedMap, $patchedMap );
}
 
+   public function testErrorOnUnknownDiffOpType() {
+   $patcher = new MapPatcher();
+
+   $diffOp = $this->getMock( 'Diff\DiffOp' );
+
+   $diffOp->expects( $this->any() )
+   ->method( 'getType' )
+   ->will( $this->returnValue( 'diff' ) );
+
+   $diff = new Diff( array( $diffOp ), true );
+
+   $patcher->patch( array(), $diff );
+
+   $patcher->throwErrors();
+   $this->setExpectedException( 'Diff\PatcherException' );
+
+   $patcher->patch( array(), $diff );
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7b764195a7d752325afd5f5a8c92668cd849fc29
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Removed impossible to test else case, only there for legacy ... - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Removed impossible to test else case, only there for legacy 
reasons, from Diff
..


Removed impossible to test else case, only there for legacy reasons, from Diff

Change-Id: I3ef31699c9bcce5a6597be207c0221837d8f9fde
---
M includes/diffop/diff/Diff.php
1 file changed, 1 insertion(+), 5 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/diffop/diff/Diff.php b/includes/diffop/diff/Diff.php
index ac0c306..237f2a1 100644
--- a/includes/diffop/diff/Diff.php
+++ b/includes/diffop/diff/Diff.php
@@ -24,7 +24,7 @@
 *
 * @var boolean|null
 */
-   protected $isAssociative;
+   protected $isAssociative = null;
 
/**
 * Pointers to the operations of certain types for quick lookup.
@@ -192,10 +192,6 @@
elseif ( $this instanceof ListDiff ) {
$this->isAssociative = false;
}
-   else {
-   $this->isAssociative = null;
-   }
-
 
return $serializationData;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3ef31699c9bcce5a6597be207c0221837d8f9fde
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 ListDiff::newEmpty - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Remove ListDiff::newEmpty
..


Remove ListDiff::newEmpty

Change-Id: I51467c1245f86d90d646e4d757f5864160e0d6f9
---
M includes/diffop/diff/ListDiff.php
1 file changed, 0 insertions(+), 13 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/diffop/diff/ListDiff.php 
b/includes/diffop/diff/ListDiff.php
index 6b5d8d3..8599cf9 100644
--- a/includes/diffop/diff/ListDiff.php
+++ b/includes/diffop/diff/ListDiff.php
@@ -25,19 +25,6 @@
}
 
/**
-* Creates and returns an empty ListDiff.
-* @see Diff::newEmpty
-*
-* @since 0.1
-* @deprecated since 0.4, just use the constructor
-*
-* @return ListDiff
-*/
-   public static function newEmpty() {
-   return new static( array() );
-   }
-
-   /**
 * @see DiffOp::getType
 *
 * @since 0.1

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I51467c1245f86d90d646e4d757f5864160e0d6f9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 FIXME to broken code - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added FIXME to broken code
..


Added FIXME to broken code

Change-Id: I04cb8c0c3362de03c6344e0c1e2a2b173dd35413
---
M includes/differ/ListDiffer.php
1 file changed, 2 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/differ/ListDiffer.php b/includes/differ/ListDiffer.php
index e1d9808..3018847 100644
--- a/includes/differ/ListDiffer.php
+++ b/includes/differ/ListDiffer.php
@@ -83,6 +83,8 @@
 * Sets a callback to use for comparison. The callback should accept two
 * arguments.
 *
+* FIXME: this field is not used!
+*
 * @since 0.5
 *
 * @param callable $comparisonCallback

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I04cb8c0c3362de03c6344e0c1e2a2b173dd35413
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 ThrowingPatcherTest to test throwErrors and ignoreErrors - change (mediawiki...Diff)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added ThrowingPatcherTest to test throwErrors and ignoreErrors
..


Added ThrowingPatcherTest to test throwErrors and ignoreErrors

Change-Id: Ic4c5d90a0cc3b38dc68088051f3812e8b0d22c55
---
A tests/phpunit/patcher/ThrowingPatcherTest.php
1 file changed, 60 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/patcher/ThrowingPatcherTest.php 
b/tests/phpunit/patcher/ThrowingPatcherTest.php
new file mode 100644
index 000..0ec613c
--- /dev/null
+++ b/tests/phpunit/patcher/ThrowingPatcherTest.php
@@ -0,0 +1,60 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.7
+ *
+ * @ingroup DiffTest
+ *
+ * @group Diff
+ * @group DiffPatcher
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class ThrowingPatcherTest extends DiffTestCase {
+
+   public function testChangeThrowErrors() {
+   $patcher = $this->getMockForAbstractClass( 
'Diff\ThrowingPatcher' );
+
+   $class = new ReflectionClass( 'Diff\ThrowingPatcher' );
+   $method = $class->getMethod( 'handleError' );
+   $method->setAccessible( true );
+
+   $errorMessage = 'foo bar';
+
+   $method->invokeArgs( $patcher, array( $errorMessage ) );
+
+   $patcher->throwErrors();
+   $patcher->ignoreErrors();
+
+   $method->invokeArgs( $patcher, array( $errorMessage ) );
+
+   $patcher->throwErrors();
+   $this->setExpectedException( 'Diff\PatcherException' );
+
+   $method->invokeArgs( $patcher, array( $errorMessage ) );
+   }
+
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic4c5d90a0cc3b38dc68088051f3812e8b0d22c55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Simplified FQNs and imported classes - change (mediawiki...Ask)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Simplified FQNs and imported classes
..


Simplified FQNs and imported classes

Change-Id: I04e4eb99fe829e29b058d3dc9fd33d33840477c8
---
M Tests/Phpunit/Language/Description/ConjunctionTest.php
M Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
M Tests/Phpunit/Language/Description/DisjunctionTest.php
3 files changed, 18 insertions(+), 8 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Language/Description/ConjunctionTest.php 
b/Tests/Phpunit/Language/Description/ConjunctionTest.php
index 417923b..240a159 100644
--- a/Tests/Phpunit/Language/Description/ConjunctionTest.php
+++ b/Tests/Phpunit/Language/Description/ConjunctionTest.php
@@ -2,10 +2,13 @@
 
 namespace Ask\Tests\Phpunit\Language\Description;
 
+use Ask\Language\Description\AnyValue;
 use Ask\Language\Description\Conjunction;
 use Ask\Language\Description\Description;
 use Ask\Language\Description\DescriptionCollection;
 use Ask\Language\Description\Disjunction;
+use Ask\Language\Description\ValueDescription;
+use DataValues\StringValue;
 
 /**
  * @covers Ask\Language\Description\Conjunction
@@ -48,8 +51,8 @@
$instances[] = new Conjunction( array() );
$instances[] = new Conjunction( array( new Conjunction( array() 
) ) );
$instances[] = new Conjunction( array( new Disjunction( array() 
), new Disjunction( array() ) ) );
-   $instances[] = new Conjunction( array( new 
\Ask\Language\Description\AnyValue() ) );
-   $instances[] = new Conjunction( array( new 
\Ask\Language\Description\ValueDescription( new \DataValues\StringValue( 'ohi' 
) ) ) );
+   $instances[] = new Conjunction( array( new AnyValue() ) );
+   $instances[] = new Conjunction( array( new ValueDescription( 
new StringValue( 'ohi' ) ) ) );
 
foreach ( $this->descriptionsProvider() as $argList ) {
$instances[] = new Conjunction( $argList[0] );
diff --git a/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php 
b/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
index e545229..3b434f1 100644
--- a/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
+++ b/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
@@ -7,6 +7,9 @@
 use Ask\Language\Description\Description;
 use Ask\Language\Description\DescriptionCollection;
 use Ask\Language\Description\SomeProperty;
+use Ask\Language\Description\ValueDescription;
+use DataValues\NumberValue;
+use DataValues\StringValue;
 
 /**
  * Base class for unit tests for the 
Ask\Language\Description\DescriptionCollection deriving classes.
@@ -42,8 +45,8 @@
$descriptionLists[] = array();
 
$descriptionLists[] = array(
-   new \Ask\Language\Description\AnyValue(),
-   new \Ask\Language\Description\ValueDescription( new 
\DataValues\StringValue( 'nyan nyan' ) )
+   new AnyValue(),
+   new ValueDescription( new StringValue( 'nyan nyan' ) )
);
 
$descriptionList = array();
@@ -51,7 +54,7 @@
shuffle( $numbers );
 
foreach ( $numbers as $number ) {
-   $descriptionList[] = new 
\Ask\Language\Description\ValueDescription( new \DataValues\NumberValue( 
$number ) );
+   $descriptionList[] = new ValueDescription( new 
NumberValue( $number ) );
}
 
$descriptionLists[] = $descriptionList;
diff --git a/Tests/Phpunit/Language/Description/DisjunctionTest.php 
b/Tests/Phpunit/Language/Description/DisjunctionTest.php
index a87e978..5a2b595 100644
--- a/Tests/Phpunit/Language/Description/DisjunctionTest.php
+++ b/Tests/Phpunit/Language/Description/DisjunctionTest.php
@@ -2,9 +2,13 @@
 
 namespace Ask\Tests\Phpunit\Language\Description;
 
+use Ask\Language\Description\AnyValue;
+use Ask\Language\Description\Conjunction;
 use Ask\Language\Description\Description;
 use Ask\Language\Description\DescriptionCollection;
 use Ask\Language\Description\Disjunction;
+use Ask\Language\Description\ValueDescription;
+use DataValues\StringValue;
 
 /**
  * @covers Ask\Language\Description\Disjunction
@@ -45,10 +49,10 @@
$instances = array();
 
$instances[] = new Disjunction( array() );
-   $instances[] = new Disjunction( array( new 
\Ask\Language\Description\Conjunction( array() ) ) );
+   $instances[] = new Disjunction( array( new Conjunction( array() 
) ) );
$instances[] = new Disjunction( array( new Disjunction( array() 
), new Disjunction( array() ) ) );
-   $instances[] = new Disjunction( array( new 
\Ask\Language\Description\AnyValue() ) );

[MediaWiki-commits] [Gerrit] Added tests for DescriptionCollection::equals - change (mediawiki...Ask)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added tests for DescriptionCollection::equals
..


Added tests for DescriptionCollection::equals

Change-Id: I56540d45131a9fde8243932b94043be122bb66fe
---
M Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
1 file changed, 25 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php 
b/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
index 3294eca..e545229 100644
--- a/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
+++ b/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
@@ -2,8 +2,11 @@
 
 namespace Ask\Tests\Phpunit\Language\Description;
 
+use Ask\Language\Description\AnyValue;
+use Ask\Language\Description\Conjunction;
 use Ask\Language\Description\Description;
 use Ask\Language\Description\DescriptionCollection;
+use Ask\Language\Description\SomeProperty;
 
 /**
  * Base class for unit tests for the 
Ask\Language\Description\DescriptionCollection deriving classes.
@@ -96,4 +99,26 @@
$this->assertEquals( $description->getHash(), 
$sameDescription->getHash() );
}
 
+   /**
+* @dataProvider descriptionsProvider
+*
+* @param Description[] $descriptions
+*/
+   public function testDifferentSizeNotEquals( array $descriptions ) {
+   $firstDescription = $this->newFromDescriptions( $descriptions );
+
+   $descriptions[] = new AnyValue();
+
+   $secondDescription = $this->newFromDescriptions( $descriptions 
);
+
+   $this->assertFalse( $firstDescription->equals( 
$secondDescription ) );
+   }
+
+   public function testDifferentContainedDescriptionCausesInequality() {
+   $firstDescription = $this->newFromDescriptions( array( new 
AnyValue() ) );
+   $secondDescription = $this->newFromDescriptions( array( new 
Conjunction( array() ) ) );
+
+   $this->assertFalse( $secondDescription->equals( 
$firstDescription ) );
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I56540d45131a9fde8243932b94043be122bb66fe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 covers tags for DescriptionCollection covering tests - change (mediawiki...Ask)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added covers tags for DescriptionCollection covering tests
..


Added covers tags for DescriptionCollection covering tests

Change-Id: I8a19c2f563ed1426b11244893721a9883768ae17
---
M Tests/Phpunit/Language/Description/ConjunctionTest.php
M Tests/Phpunit/Language/Description/DisjunctionTest.php
2 files changed, 2 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Tests/Phpunit/Language/Description/ConjunctionTest.php 
b/Tests/Phpunit/Language/Description/ConjunctionTest.php
index e9e380b..417923b 100644
--- a/Tests/Phpunit/Language/Description/ConjunctionTest.php
+++ b/Tests/Phpunit/Language/Description/ConjunctionTest.php
@@ -9,6 +9,7 @@
 
 /**
  * @covers Ask\Language\Description\Conjunction
+ * @covers Ask\Language\Description\DescriptionCollection
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/Tests/Phpunit/Language/Description/DisjunctionTest.php 
b/Tests/Phpunit/Language/Description/DisjunctionTest.php
index c3feabb..a87e978 100644
--- a/Tests/Phpunit/Language/Description/DisjunctionTest.php
+++ b/Tests/Phpunit/Language/Description/DisjunctionTest.php
@@ -8,6 +8,7 @@
 
 /**
  * @covers Ask\Language\Description\Disjunction
+ * @covers Ask\Language\Description\DescriptionCollection
  *
  * 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

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8a19c2f563ed1426b11244893721a9883768ae17
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 obsolete test registration code - change (mediawiki...Ask)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Remove obsolete test registration code
..


Remove obsolete test registration code

Change-Id: I5c75f1132b55db53617b8c0d406e51ca173d1b7d
---
M Ask.mw.php
1 file changed, 0 insertions(+), 42 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Ask.mw.php b/Ask.mw.php
index f1093d7..4ed858f 100644
--- a/Ask.mw.php
+++ b/Ask.mw.php
@@ -28,8 +28,6 @@
  * @author Jeroen De Dauw < jeroended...@gmail.com >
  */
 
-// @codeCoverageIgnoreStart
-
 if ( !defined( 'MEDIAWIKI' ) ) {
die( 'Not an entry point.' );
 }
@@ -43,43 +41,3 @@
 if ( defined( 'MW_PHPUNIT_TEST' ) ) {
require_once __DIR__ . '/Tests/testLoader.php';
 }
-
-/**
- * Hook to add PHPUnit test cases.
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
- *
- * TODO: register the Tests directory itself so this list does not need to be 
maintained
- *
- * @since 0.1
- *
- * @param array $files
- *
- * @return boolean
- */
-$wgHooks['UnitTestsList'][]= function( array &$files ) {
-
-   $testFiles = array(
-   'Language/Description/AnyValue',
-   'Language/Description/Conjunction',
-   'Language/Description/SomeProperty',
-   'Language/Description/Disjunction',
-   'Language/Description/ValueDescription',
-
-   'Language/Option/PropertyValueSortExpression',
-   'Language/Option/QueryOptions',
-   'Language/Option/SortOptions',
-
-   'Language/Selection/PropertySelection',
-   'Language/Selection/SubjectSelection',
-
-   'Language/Query',
-   );
-
-   foreach ( $testFiles as $file ) {
-   $files[] = __DIR__ . '/Tests/Phpunit/' . $file . 'Test.php';
-   }
-
-   return true;
-};
-
-// @codeCoverageIgnoreEnd

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5c75f1132b55db53617b8c0d406e51ca173d1b7d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] getInternalIdForEntity now takes an EntityId rather than its... - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: getInternalIdForEntity now takes an EntityId rather than its 
components
..


getInternalIdForEntity now takes an EntityId rather than its components

Change-Id: I2a176114eeb68bb4f3e986d81ebc748f7a651bbc
---
M QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
M QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
M QueryEngine/includes/SQLStore/EntityIdTransformer.php
M QueryEngine/includes/SQLStore/EntityInserter.php
M QueryEngine/includes/SQLStore/InternalEntityIdFinder.php
M QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php
M QueryEngine/tests/phpunit/SQLStore/EntityIdTransformerTest.php
M QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
8 files changed, 20 insertions(+), 32 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php 
b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
index 9b01ad0..27dce1b 100644
--- a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
+++ b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
@@ -53,10 +53,7 @@
}
 
protected function getInternalIdFor( EntityId $entityId ) {
-   return $this->idFinder->getInternalIdForEntity(
-   $entityId->getEntityType(),
-   $entityId->getNumericId()
-   );
+   return $this->idFinder->getInternalIdForEntity( $entityId );
}
 
 }
\ No newline at end of file
diff --git a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php 
b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
index b91d52d..b038f01 100644
--- a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
+++ b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
@@ -114,10 +114,7 @@
}
 
protected function getInternalId( EntityId $id ) {
-   return $this->idFinder->getInternalIdForEntity(
-   $id->getEntityType(),
-   $id->getNumericId()
-   );
+   return $this->idFinder->getInternalIdForEntity( $id );
}
 
protected function getExtraConditions( SomeProperty $description, 
DataValueHandler $dvHandler ) {
diff --git a/QueryEngine/includes/SQLStore/EntityIdTransformer.php 
b/QueryEngine/includes/SQLStore/EntityIdTransformer.php
index dd019cb..c73b517 100644
--- a/QueryEngine/includes/SQLStore/EntityIdTransformer.php
+++ b/QueryEngine/includes/SQLStore/EntityIdTransformer.php
@@ -2,6 +2,8 @@
 
 namespace Wikibase\QueryEngine\SQLStore;
 
+use Wikibase\EntityId;
+
 /**
  * Transforms entity types and numbers into internal store ids.
  *
@@ -43,15 +45,14 @@
/**
 * @see InternalEntityIdFinder::getInternalIdForEntity
 *
-* @param string $entityType
-* @param int $entityNumber
+* @param EntityId $entityId
 *
 * @return int
 */
-   public function getInternalIdForEntity( $entityType, $entityNumber ) {
-   $this->ensureEntityTypeIsKnown( $entityType );
+   public function getInternalIdForEntity( EntityId $entityId ) {
+   $this->ensureEntityTypeIsKnown( $entityId->getEntityType() );
 
-   return $this->getComputedId( $entityType, $entityNumber );
+   return $this->getComputedId( $entityId );
}
 
protected function ensureEntityTypeIsKnown( $entityType ) {
@@ -60,8 +61,8 @@
}
}
 
-   protected function getComputedId( $entityType, $entityNumber ) {
-   return $entityNumber * 10 + $this->idMap[$entityType];
+   protected function getComputedId( EntityId $entityId ) {
+   return $entityId->getNumericId() * 10 + 
$this->idMap[$entityId->getEntityType()];
}
 
 }
diff --git a/QueryEngine/includes/SQLStore/EntityInserter.php 
b/QueryEngine/includes/SQLStore/EntityInserter.php
index fc5eae8..b906205 100644
--- a/QueryEngine/includes/SQLStore/EntityInserter.php
+++ b/QueryEngine/includes/SQLStore/EntityInserter.php
@@ -74,10 +74,7 @@
}
 
protected function getInternalId( EntityId $entityId ) {
-   return $this->idFinder->getInternalIdForEntity(
-   $entityId->getEntityType(),
-   $entityId->getNumericId()
-   );
+   return $this->idFinder->getInternalIdForEntity( $entityId );
}
 
 }
diff --git a/QueryEngine/includes/SQLStore/InternalEntityIdFinder.php 
b/QueryEngine/includes/SQLStore/InternalEntityIdFinder.php
index 83b6f01..b537120 100644
--- a/QueryEngine/includes/SQLStore/InternalEntityIdFinder.php
+++ b/QueryEngine/includes/SQLStore/InternalEntityIdFinder.php
@@ -2,6 +2,8 @@
 
 namespace Wikibase\QueryEngine\SQLStore;
 
+us

[MediaWiki-commits] [Gerrit] Added SnakRemover - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added SnakRemover
..


Added SnakRemover

Change-Id: I01266d0f964186b539f45db7fc2fe1e0586d7fd2
---
A QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php
M QueryEngine/includes/SQLStore/SnakStore/SnakStore.php
M QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
M QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
A QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php
5 files changed, 152 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php 
b/QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php
new file mode 100644
index 000..bb7b400
--- /dev/null
+++ b/QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php
@@ -0,0 +1,63 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseSQLStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class SnakRemover {
+
+   /**
+* @var SnakStore[]
+*/
+   protected $snakStores;
+
+   /**
+* @param SnakStore[] $snakStores
+*/
+   public function __construct( array $snakStores ) {
+   $this->snakStores = $snakStores;
+   }
+
+   /**
+* @since 0.1
+*
+* @param int $internalSubjectId
+*/
+   public function removeSnaksOfSubject( $internalSubjectId ) {
+   foreach ( $this->snakStores as $snakStore ) {
+   $snakStore->removeSnaksOfSubject( $internalSubjectId );
+   }
+   }
+
+}
diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php
index 05524a9..ca71d8a 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php
@@ -44,4 +44,11 @@
 */
public abstract function storeSnakRow( SnakRow $snakRow );
 
+   /**
+* @since 0.1
+*
+* @param int $internalSubjectId
+*/
+   public abstract function removeSnaksOfSubject( $internalSubjectId );
+
 }
diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
index b61c18e..b0fcc15 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
@@ -97,4 +97,8 @@
);
}
 
+   public function removeSnaksOfSubject( $internalSubjectId ) {
+
+   }
+
 }
diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
index 30f8166..0959559 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
@@ -64,4 +64,8 @@
);
}
 
+   public function removeSnaksOfSubject( $internalSubjectId ) {
+
+   }
+
 }
diff --git a/QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php 
b/QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php
new file mode 100644
index 000..985927b
--- /dev/null
+++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php
@@ -0,0 +1,74 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseQueryEngineTest
+ *
+ * @group Wikibase
+ * @group WikibaseQueryEngine
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class SnakRemoverTest extends \PHPUnit_Framework_TestCase {
+
+   /**
+* @dataProvider subjectIdProvider
+*/
+   public function testRemoveSnaksOfSubject( $internalSubjectId ) {
+   $valuelessStore = $this->getMockBuilder( 
'Wikibase\QueryEngine\SQLStore\SnakStore\ValuelessSnakStore' )
+   ->disableOriginalConstructor()->getMock();
+   $valueStore = $this->getMockBuilder( 
'Wikibase\QueryEngine\SQLStore\SnakStore\ValueSnakStore' )
+   ->disableOriginalConstructor()->getMock();
+
+   $valuelessStore->expects( $this->once() )
+   ->method( 'removeSnaksOfSubject' )
+   ->with( $this->equalTo( $internalSubjectId ) );
+
+   $valueStore->expects( $this->once() )
+   ->method( 'removeSnaksOfSubject' )
+   ->with( $this->equalTo( $internalSubjectId ) );
+
+   $snakRemover = new SnakRemover( array( $valuelessStore, 
$valueStore ) );
+
+   $snakRemover->removeSnaksOfSubject( $internalSubjectId );
+   }
+
+   public function subjectIdProvider() {
+   $argLists = array();
+
+   $argLists[] = array(

[MediaWiki-commits] [Gerrit] Removed unused import in EntityInserterTest - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Removed unused import in EntityInserterTest
..


Removed unused import in EntityInserterTest

Change-Id: Ib452ae78522f43603af127386d16d5d8c2d21be6
---
M QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
1 file changed, 0 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php 
b/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
index df36c1b..8aa714a 100644
--- a/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
@@ -10,7 +10,6 @@
 use Wikibase\Property;
 use Wikibase\PropertyNoValueSnak;
 use Wikibase\QueryEngine\SQLStore\DataValueTable;
-use Wikibase\QueryEngine\SQLStore\EntityIdTransformer;
 use Wikibase\QueryEngine\SQLStore\EntityInserter;
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib452ae78522f43603af127386d16d5d8c2d21be6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 EntityTable from EntityInserter - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Remove EntityTable from EntityInserter
..


Remove EntityTable from EntityInserter

We currently have no need to insert into this table.

Change-Id: I0245ea1bc344e69eeac887cca2f1c223113b2147
---
M QueryEngine/includes/SQLStore/EntityInserter.php
M QueryEngine/includes/SQLStore/Factory.php
M QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
3 files changed, 2 insertions(+), 17 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/EntityInserter.php 
b/QueryEngine/includes/SQLStore/EntityInserter.php
index ea886fa..c306bd0 100644
--- a/QueryEngine/includes/SQLStore/EntityInserter.php
+++ b/QueryEngine/includes/SQLStore/EntityInserter.php
@@ -34,19 +34,16 @@
  */
 class EntityInserter {
 
-   private $entityTable;
private $claimInserter;
private $idFinder;
 
/**
 * @since 0.1
 *
-* @param EntityTable $entityTable
 * @param ClaimInserter $claimInserter
 * @param InternalEntityIdFinder $idFinder
 */
-   public function __construct( EntityTable $entityTable, ClaimInserter 
$claimInserter, InternalEntityIdFinder $idFinder ) {
-   $this->entityTable = $entityTable;
+   public function __construct( ClaimInserter $claimInserter, 
InternalEntityIdFinder $idFinder ) {
$this->claimInserter = $claimInserter;
$this->idFinder = $idFinder;
}
@@ -57,8 +54,6 @@
 * @param Entity $entity
 */
public function insertEntity( Entity $entity ) {
-   $this->entityTable->insertEntity( $entity );
-
$internalSubjectId = $this->getInternalId( $entity->getId() );
 
foreach ( $entity->getClaims() as $claim ) {
diff --git a/QueryEngine/includes/SQLStore/Factory.php 
b/QueryEngine/includes/SQLStore/Factory.php
index c00562c..24c9299 100644
--- a/QueryEngine/includes/SQLStore/Factory.php
+++ b/QueryEngine/includes/SQLStore/Factory.php
@@ -72,7 +72,6 @@
 
public function newEntityInserter() {
return new EntityInserter(
-   $this->newEntityTable(),
$this->newClaimInserter(),
$this->getInternalEntityIdFinder()
);
diff --git a/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php 
b/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
index df36c1b..e0d19f8 100644
--- a/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
@@ -48,15 +48,6 @@
 * @dataProvider entityProvider
 */
public function testInsertEntity( Entity $entity ) {
-   $entityTable = $this
-   ->getMockBuilder( 
'Wikibase\QueryEngine\SQLStore\EntityTable' )
-   ->disableOriginalConstructor()
-   ->getMock();
-
-   $entityTable->expects( $this->once() )
-   ->method( 'insertEntity' )
-   ->with( $this->equalTo( $entity ) );
-
$claimInserter = $this
->getMockBuilder( 
'Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimInserter' )
->disableOriginalConstructor()
@@ -84,7 +75,7 @@
)
->will( $this->returnValue( 1234 ) );
 
-   $inserter = new EntityInserter( $entityTable, $claimInserter, 
$idFinder );
+   $inserter = new EntityInserter( $claimInserter, $idFinder );
 
$inserter->insertEntity( $entity );
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0245ea1bc344e69eeac887cca2f1c223113b2147
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] Fixed some docs in EntityInserter - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fixed some docs in EntityInserter
..


Fixed some docs in EntityInserter

Change-Id: Ibaf8fb7f2c677a40c73eb57114d6c16b1ee8f94b
---
M QueryEngine/includes/SQLStore/EntityInserter.php
1 file changed, 1 insertion(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/EntityInserter.php 
b/QueryEngine/includes/SQLStore/EntityInserter.php
index 2c1326e..ea886fa 100644
--- a/QueryEngine/includes/SQLStore/EntityInserter.php
+++ b/QueryEngine/includes/SQLStore/EntityInserter.php
@@ -43,6 +43,7 @@
 *
 * @param EntityTable $entityTable
 * @param ClaimInserter $claimInserter
+* @param InternalEntityIdFinder $idFinder
 */
public function __construct( EntityTable $entityTable, ClaimInserter 
$claimInserter, InternalEntityIdFinder $idFinder ) {
$this->entityTable = $entityTable;
@@ -51,8 +52,6 @@
}
 
/**
-* @see QueryStoreUpdater::insertEntity
-*
 * @since 0.1
 *
 * @param Entity $entity

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibaf8fb7f2c677a40c73eb57114d6c16b1ee8f94b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] Removed unused import in EntityInserter - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Removed unused import in EntityInserter
..


Removed unused import in EntityInserter

Change-Id: If4970eec3ace422ec624196b2bab73c1fcca3de0
---
M QueryEngine/includes/SQLStore/EntityInserter.php
1 file changed, 0 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/EntityInserter.php 
b/QueryEngine/includes/SQLStore/EntityInserter.php
index fc5eae8..2c1326e 100644
--- a/QueryEngine/includes/SQLStore/EntityInserter.php
+++ b/QueryEngine/includes/SQLStore/EntityInserter.php
@@ -2,7 +2,6 @@
 
 namespace Wikibase\QueryEngine\SQLStore;
 
-use Wikibase\Database\QueryInterface;
 use Wikibase\Entity;
 use Wikibase\EntityId;
 use Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimInserter;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If4970eec3ace422ec624196b2bab73c1fcca3de0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] Take care of TableBuilder TODO in QueryEngine component - change (mediawiki...Wikibase)

2013-05-28 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Take care of TableBuilder TODO in QueryEngine component
..


Take care of TableBuilder TODO in QueryEngine component

Change-Id: I8599380fdc8b931a112eae98213ee402a855982d
---
M QueryEngine/includes/SQLStore/Factory.php
M QueryEngine/includes/SQLStore/Store.php
M QueryEngine/tests/phpunit/SQLStore/FactoryTest.php
3 files changed, 12 insertions(+), 23 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/Factory.php 
b/QueryEngine/includes/SQLStore/Factory.php
index c00562c..c07f695 100644
--- a/QueryEngine/includes/SQLStore/Factory.php
+++ b/QueryEngine/includes/SQLStore/Factory.php
@@ -3,6 +3,7 @@
 namespace Wikibase\QueryEngine\SQLStore;
 
 use Wikibase\Database\QueryInterface;
+use Wikibase\Database\TableBuilder;
 use Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimInserter;
 use Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimRowBuilder;
 use Wikibase\QueryEngine\SQLStore\ClaimStore\ClaimsTable;
@@ -154,4 +155,8 @@
);
}
 
+   public function getTableBuilder() {
+   return new TableBuilder( $this->queryInterface );
+   }
+
 }
diff --git a/QueryEngine/includes/SQLStore/Store.php 
b/QueryEngine/includes/SQLStore/Store.php
index ac14857..68a7cfa 100644
--- a/QueryEngine/includes/SQLStore/Store.php
+++ b/QueryEngine/includes/SQLStore/Store.php
@@ -4,7 +4,6 @@
 
 use MessageReporter;
 use Wikibase\Database\QueryInterface;
-use Wikibase\Database\TableBuilder;
 use Wikibase\QueryEngine\QueryStore;
 use Wikibase\QueryEngine\SQLStore\Engine\DescriptionMatchFinder;
 use Wikibase\QueryEngine\SQLStore\Engine\Engine;
@@ -54,13 +53,6 @@
/**
 * @since 0.1
 *
-* @var TableBuilder|null
-*/
-   private $tableBuilder;
-
-   /**
-* @since 0.1
-*
 * @var Factory
 */
private $factory;
@@ -75,21 +67,6 @@
$this->config = $config;
$this->queryInterface = $queryInterface;
$this->factory = new Factory( $config, $queryInterface );
-
-   $this->tableBuilder = new TableBuilder( $this->queryInterface );
-   }
-
-   /**
-* Sets the table builder to use for creating tables.
-*
-* @deprecated TODO: move to config
-*
-* @since 0.1
-*
-* @param TableBuilder $tableBuilder
-*/
-   public function setTableBuilder( TableBuilder $tableBuilder ) {
-   $this->tableBuilder = $tableBuilder;
}
 
/**
diff --git a/QueryEngine/tests/phpunit/SQLStore/FactoryTest.php 
b/QueryEngine/tests/phpunit/SQLStore/FactoryTest.php
index 72cbb59..7081b5c 100644
--- a/QueryEngine/tests/phpunit/SQLStore/FactoryTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/FactoryTest.php
@@ -83,4 +83,11 @@
);
}
 
+   public function testGetTableBuilderReturnType() {
+   $this->assertInstanceOf(
+   'Wikibase\Database\TableBuilder',
+   $this->newInstance()->getTableBuilder()
+   );
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8599380fdc8b931a112eae98213ee402a855982d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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 InsertFailedException - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added InsertFailedException
..


Added InsertFailedException

Change-Id: I12a18822c4f4ee2e8ea3cf950edba33fa53e59dc
---
M Database/includes/DeleteFailedException.php
A Database/includes/InsertFailedException.php
A Database/tests/phpunit/InsertFailedExceptionTest.php
3 files changed, 119 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Database/includes/DeleteFailedException.php 
b/Database/includes/DeleteFailedException.php
index e940cc0..41b135b 100644
--- a/Database/includes/DeleteFailedException.php
+++ b/Database/includes/DeleteFailedException.php
@@ -31,11 +31,11 @@
protected $tableName;
protected $conditions;
 
-   public function __construct( $tableName, array $conditions, $message = 
'', \Exception $previous = null ) {
+   public function __construct( $tableName, array $values, $message = '', 
\Exception $previous = null ) {
parent::__construct( $message, 0, $previous );
 
$this->tableName = $tableName;
-   $this->conditions = $conditions;
+   $this->conditions = $values;
}
 
/**
diff --git a/Database/includes/InsertFailedException.php 
b/Database/includes/InsertFailedException.php
new file mode 100644
index 000..aa7cb19
--- /dev/null
+++ b/Database/includes/InsertFailedException.php
@@ -0,0 +1,55 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class InsertFailedException extends QueryInterfaceException {
+
+   protected $tableName;
+   protected $values;
+
+   public function __construct( $tableName, array $values, $message = '', 
\Exception $previous = null ) {
+   parent::__construct( $message, 0, $previous );
+
+   $this->tableName = $tableName;
+   $this->values = $values;
+   }
+
+   /**
+* @return string
+*/
+   public function getTableName() {
+   return $this->tableName;
+   }
+
+   /**
+* @return array
+*/
+   public function getValues() {
+   return $this->values;
+   }
+
+}
diff --git a/Database/tests/phpunit/InsertFailedExceptionTest.php 
b/Database/tests/phpunit/InsertFailedExceptionTest.php
new file mode 100644
index 000..d3dc897
--- /dev/null
+++ b/Database/tests/phpunit/InsertFailedExceptionTest.php
@@ -0,0 +1,62 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseDatabaseTest
+ *
+ * @group Wikibase
+ * @group WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class InsertFailedExceptionTest extends \PHPUnit_Framework_TestCase {
+
+   public function testConstructorWithOnlyRequiredArguments() {
+   $tableName = 'nyancats';
+   $values = array( 'foo' => 42, 'awesome > 9000' );
+
+   $exception = new InsertFailedException( $tableName, $values );
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $values, $exception->getValues() );
+   }
+
+   public function testConstructorWithAllArguments() {
+   $tableName = 'users';
+   $values = array( 'foo' => 42 );
+   $message = 'NyanData all the way accross the sky!';
+   $previous = new \Exception( 'Onoez!' );
+
+   $exception = new InsertFailedException( $tableName, $values, 
$message, $previous );
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $values, $exception->getValues() );
+   $this->assertEquals( $message, $exception->getMessage() );
+   $this->assertEquals( $previous, $exception->getPrevious() );
+   }
+
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I12a18822c4f4ee2e8ea3cf950edba33fa53e59dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Updated depenedencies in composer.json - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Updated depenedencies in composer.json
..


Updated depenedencies in composer.json

Change-Id: I8c1efb6f10681aa3ddcc0011e1a64210a1933c03
---
M composer.json
1 file changed, 4 insertions(+), 3 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/composer.json b/composer.json
index e59854a..d19b577 100644
--- a/composer.json
+++ b/composer.json
@@ -13,8 +13,9 @@
 ],
 "require": {
 "php": ">=5.3.0",
-"mediawiki/mediawiki": ">=1.20",
-"diff/diff": ">=0.3",
-"datavalues/datavalues": "*"
+"mediawiki/core": ">=1.20",
+"mediawiki/data-values": "*",
+"diff/diff": ">=0.6",
+"ask/ask": "*"
 }
 }
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8c1efb6f10681aa3ddcc0011e1a64210a1933c03
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Hoo man 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: Nikerabbit 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Add @throws to QueryInterface interface - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add @throws to QueryInterface interface
..


Add @throws to QueryInterface interface

Change-Id: I8caf8db70dbd4ab82b651767f7780aa6444526f3
---
M Database/includes/QueryInterface.php
1 file changed, 2 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/Database/includes/QueryInterface.php 
b/Database/includes/QueryInterface.php
index 79ffc8e..052bbc5 100644
--- a/Database/includes/QueryInterface.php
+++ b/Database/includes/QueryInterface.php
@@ -49,6 +49,7 @@
 * @param TableDefinition $table
 *
 * @return boolean Success indicator
+* @throws TableCreationFailedException
 */
public function createTable( TableDefinition $table );
 
@@ -129,6 +130,7 @@
 * @param array $conditions
 *
 * @return ResultIterator
+* @throws SelectFailedException
 */
public function select( $tableName, array $fields, array $conditions );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8caf8db70dbd4ab82b651767f7780aa6444526f3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 DeleteFailedException - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added DeleteFailedException
..


Added DeleteFailedException

Change-Id: Ib70c85b202c1db9c8735baa94f9eb373c4b022f3
---
A Database/includes/DeleteFailedException.php
A Database/tests/phpunit/DeleteFailedExceptionTest.php
2 files changed, 117 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Database/includes/DeleteFailedException.php 
b/Database/includes/DeleteFailedException.php
new file mode 100644
index 000..e940cc0
--- /dev/null
+++ b/Database/includes/DeleteFailedException.php
@@ -0,0 +1,55 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class DeleteFailedException extends QueryInterfaceException {
+
+   protected $tableName;
+   protected $conditions;
+
+   public function __construct( $tableName, array $conditions, $message = 
'', \Exception $previous = null ) {
+   parent::__construct( $message, 0, $previous );
+
+   $this->tableName = $tableName;
+   $this->conditions = $conditions;
+   }
+
+   /**
+* @return string
+*/
+   public function getTableName() {
+   return $this->tableName;
+   }
+
+   /**
+* @return array
+*/
+   public function getConditions() {
+   return $this->conditions;
+   }
+
+}
diff --git a/Database/tests/phpunit/DeleteFailedExceptionTest.php 
b/Database/tests/phpunit/DeleteFailedExceptionTest.php
new file mode 100644
index 000..4ffc7c6
--- /dev/null
+++ b/Database/tests/phpunit/DeleteFailedExceptionTest.php
@@ -0,0 +1,62 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseDatabaseTest
+ *
+ * @group Wikibase
+ * @group WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class DeleteFailedExceptionTest extends \PHPUnit_Framework_TestCase {
+
+   public function testConstructorWithOnlyRequiredArguments() {
+   $tableName = 'nyancats';
+   $conditions = array( 'foo' => 42, 'awesome > 9000' );
+
+   $exception = new DeleteFailedException( $tableName, $conditions 
);
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $conditions, $exception->getConditions() );
+   }
+
+   public function testConstructorWithAllArguments() {
+   $tableName = 'users';
+   $conditions = array( 'foo' => 42 );
+   $message = 'NyanData all the way accross the sky!';
+   $previous = new \Exception( 'Onoez!' );
+
+   $exception = new DeleteFailedException( $tableName, 
$conditions, $message, $previous );
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $conditions, $exception->getConditions() );
+   $this->assertEquals( $message, $exception->getMessage() );
+   $this->assertEquals( $previous, $exception->getPrevious() );
+   }
+
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib70c85b202c1db9c8735baa94f9eb373c4b022f3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] trim incoming string values - change (mediawiki...DataValues)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: trim incoming string values
..


trim incoming string values

Change-Id: I0055dddbb0b810432879d275e1e102069e7736c2
---
M DataValues/includes/values/StringValue.php
M DataValues/tests/phpunit/includes/values/StringValueTest.php
2 files changed, 5 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DataValues/includes/values/StringValue.php 
b/DataValues/includes/values/StringValue.php
index 678fa6d..3c57840 100644
--- a/DataValues/includes/values/StringValue.php
+++ b/DataValues/includes/values/StringValue.php
@@ -63,7 +63,10 @@
throw new InvalidArgumentException( 'String length 
exceeds limit of 400 characters' );
}
 
-   $this->value = $value;
+   // The trim is not at the right place, but the right place 
would either need us to have
+   // the parsers or the options in place. So for now it seems 
that it is not hurting much
+   // here. It is only in the deployment branch. Like the one in 
the previous line of code.
+   $this->value = trim( $value );
}
 
/**
diff --git a/DataValues/tests/phpunit/includes/values/StringValueTest.php 
b/DataValues/tests/phpunit/includes/values/StringValueTest.php
index 3b588a1..ea0227d 100644
--- a/DataValues/tests/phpunit/includes/values/StringValueTest.php
+++ b/DataValues/tests/phpunit/includes/values/StringValueTest.php
@@ -64,7 +64,7 @@
$argLists[] = array( false, null );
$argLists[] = array( true, 'foo' );
$argLists[] = array( true, '' );
-   $argLists[] = array( true, ' foo bar baz foo bar baz foo bar 
baz foo bar baz foo bar baz foo bar baz ' );
+   $argLists[] = array( true, 'foo bar baz foo bar baz foo bar baz 
foo bar baz foo bar baz foo bar baz' );
 
return $argLists;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0055dddbb0b810432879d275e1e102069e7736c2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: mw1.22-wmf5
Gerrit-Owner: Tobias Gritschacher 
Gerrit-Reviewer: Denny Vrandecic 
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 UpdateFailedException - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added UpdateFailedException
..


Added UpdateFailedException

Change-Id: Ifd963ef53a0c18566c502e08b58a3888b7e1a6e8
---
A Database/includes/UpdateFailedException.php
M Database/tests/phpunit/SelectFailedExceptionTest.php
M Database/tests/phpunit/TableCreationFailedExceptionTest.php
A Database/tests/phpunit/UpdateFailedExceptionTest.php
4 files changed, 132 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Database/includes/UpdateFailedException.php 
b/Database/includes/UpdateFailedException.php
new file mode 100644
index 000..efd1e38
--- /dev/null
+++ b/Database/includes/UpdateFailedException.php
@@ -0,0 +1,64 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class UpdateFailedException extends QueryInterfaceException {
+
+   protected $tableName;
+   protected $values;
+   protected $conditions;
+
+   public function __construct( $tableName, array $values, array 
$conditions, $message = '', \Exception $previous = null ) {
+   parent::__construct( $message, 0, $previous );
+
+   $this->tableName = $tableName;
+   $this->conditions = $conditions;
+   $this->values = $values;
+   }
+
+   /**
+* @return string
+*/
+   public function getTableName() {
+   return $this->tableName;
+   }
+
+   /**
+* @return array
+*/
+   public function getConditions() {
+   return $this->conditions;
+   }
+
+   /**
+* @return array
+*/
+   public function getValues() {
+   return $this->values;
+   }
+
+}
\ No newline at end of file
diff --git a/Database/tests/phpunit/SelectFailedExceptionTest.php 
b/Database/tests/phpunit/SelectFailedExceptionTest.php
index 52a1462..7496190 100644
--- a/Database/tests/phpunit/SelectFailedExceptionTest.php
+++ b/Database/tests/phpunit/SelectFailedExceptionTest.php
@@ -5,7 +5,7 @@
 use Wikibase\Database\SelectFailedException;
 
 /**
- * @covers Wikibase\Database\SelectFailedException class.
+ * @covers Wikibase\Database\SelectFailedException
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/Database/tests/phpunit/TableCreationFailedExceptionTest.php 
b/Database/tests/phpunit/TableCreationFailedExceptionTest.php
index 3b6a719..2570293 100644
--- a/Database/tests/phpunit/TableCreationFailedExceptionTest.php
+++ b/Database/tests/phpunit/TableCreationFailedExceptionTest.php
@@ -5,7 +5,7 @@
 use Wikibase\Database\TableCreationFailedException;
 
 /**
- * @covers Wikibase\Database\TableCreationFailedException class.
+ * @covers Wikibase\Database\TableCreationFailedException
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/Database/tests/phpunit/UpdateFailedExceptionTest.php 
b/Database/tests/phpunit/UpdateFailedExceptionTest.php
new file mode 100644
index 000..46627a7
--- /dev/null
+++ b/Database/tests/phpunit/UpdateFailedExceptionTest.php
@@ -0,0 +1,66 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseDatabaseTest
+ *
+ * @group Wikibase
+ * @group WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class UpdateFailedExceptionTest extends \PHPUnit_Framework_TestCase {
+
+   public function testConstructorWithOnlyRequiredArguments() {
+   $tableName = 'nyancats';
+   $values = array( 'bar', 'baz', 'bah' );
+   $conditions = array( 'foo' => 42, 'awesome > 9000' );
+
+   $exception = new UpdateFailedException( $tableName, $values, 
$conditions );
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $values, $exception->getValues() );
+   $this->assertEquals( $conditions, $exception->getConditions() );
+   }
+
+   public function testConstructorWithAllArguments() {
+   $tableName = 'users';
+   $fields = array( 'bar' );
+   $conditions = array( 'foo' => 42 );
+   $message = 'NyanData all the way accross the sky!';
+   $previous = new \Exception( 'Onoez!' );
+
+   $exception = new UpdateFailedException( $tableName, $fields, 
$conditions, $message, $previous );
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $fields, $exception->getValues() );
+   $t

[MediaWiki-commits] [Gerrit] Stopgap to avoid excessively long string values (backport) - change (mediawiki...DataValues)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Stopgap to avoid excessively long string values (backport)
..


Stopgap to avoid excessively long string values (backport)

Change-Id: I9b20d0d4bad5f68cd0cc440ee1995193ecec9abd
---
M DataValues/includes/values/StringValue.php
1 file changed, 12 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DataValues/includes/values/StringValue.php 
b/DataValues/includes/values/StringValue.php
index a9164f8..678fa6d 100644
--- a/DataValues/includes/values/StringValue.php
+++ b/DataValues/includes/values/StringValue.php
@@ -51,6 +51,18 @@
throw new InvalidArgumentException( 'Can only construct 
StringValue from strings' );
}
 
+   // This is backporting the very evil hack I added for the last 
deployment as can be found
+   // here:
+   // 
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/DataValues.git;a=commitdiff;h=8a980bc893824dcf86be51350ede893fe950bce2
+   // 
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/DataValues.git;a=commitdiff;h=f049d35c3fd8cd69969396238a89e4dc31701f39
+   // It is still very evil. Last time I pledged that I would be 
loosing karma for a week.
+   // Since the following I had the unfortunate incident of a 
pulled hamstring - which, by
+   // the way, hurts a lot - I will refrain from committing any 
new karma this time. I hope
+   // that by the next deployment or two we can get rid of this 
terrible hack.
+   if ( mb_strlen( $value ) > 400 ) {
+   throw new InvalidArgumentException( 'String length 
exceeds limit of 400 characters' );
+   }
+
$this->value = $value;
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9b20d0d4bad5f68cd0cc440ee1995193ecec9abd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: mw1.22-wmf5
Gerrit-Owner: Tobias Gritschacher 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] (hotfix) Fixed diff of claims with a time property - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: (hotfix) Fixed diff of claims with a time property
..


(hotfix) Fixed diff of claims with a time property

Bug: 48709

Change-Id: Icd7612f60b6595aa567fa634fa981d0be014f968
---
M lib/includes/ClaimDifferenceVisualizer.php
M repo/includes/ClaimSummaryBuilder.php
2 files changed, 10 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/ClaimDifferenceVisualizer.php 
b/lib/includes/ClaimDifferenceVisualizer.php
index 226829b..87abdc9 100644
--- a/lib/includes/ClaimDifferenceVisualizer.php
+++ b/lib/includes/ClaimDifferenceVisualizer.php
@@ -1,6 +1,7 @@
 getEntityLabel( 
$dataValue );
+   } else if ( $dataValue instanceof TimeValue ) {
+   // TODO: this will just display the plain 
ISO8601-string,
+   // we should instead use a decent formatter
+   $diffValueString = $dataValue->getTime();
} else {
$diffValueString = $dataValue->getValue();
}
diff --git a/repo/includes/ClaimSummaryBuilder.php 
b/repo/includes/ClaimSummaryBuilder.php
index 50057d7..b1e2675 100644
--- a/repo/includes/ClaimSummaryBuilder.php
+++ b/repo/includes/ClaimSummaryBuilder.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase;
 
+use DataValues\TimeValue;
 use InvalidArgumentException;
 use Wikibase\Lib\EntityIdFormatter;
 
@@ -129,6 +130,10 @@
 
if ( $snak instanceof PropertyValueSnak ) {
$value = $snak->getDataValue();
+   // TODO: we should use value formatters 
here!
+   if ( $value instanceof TimeValue ) {
+   $value = $value->getTime();
+   }
} else {
$value = '-'; // todo handle no values 
in general way (needed elsewhere)
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icd7612f60b6595aa567fa634fa981d0be014f968
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Allow ntriples in Special:EntityData - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Allow ntriples in Special:EntityData
..


Allow ntriples in Special:EntityData

Change-Id: I410166bb96a60dc4851ac21917aee8fcd3eabb25
---
M repo/includes/specials/SpecialEntityData.php
M repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
2 files changed, 6 insertions(+), 3 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index c086a97..7207cf0 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -44,7 +44,8 @@
'xml',
'rdfxml',
'n3',
-   'turtle'
+   'turtle',
+   'ntriples'
);
 
/**
diff --git a/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php 
b/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
index 32f7c47..30601ad 100644
--- a/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
@@ -276,18 +276,20 @@
'text/rdf+n3',
'text/turtle',
'application/turtle',
+   'application/ntriples',
);
 
static $rdfExtensions = array(
'rdf',
'n3',
-   'ttl'
+   'ttl',
+   'nt'
);
 
static $badMimeTypes = array(
'text/html',
'text/text',
-   'text/plain',
+   // 'text/plain', // ntriples presents as text/plain!
);
 
static $badExtensions = array(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I410166bb96a60dc4851ac21917aee8fcd3eabb25
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Config setting for cache duration of entity data. - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Config setting for cache duration of entity data.
..


Config setting for cache duration of entity data.

This introduces $wgWBRepoSettings['dataSquidMaxage'] instead
of using $wgSquidMaxage to determine the cache duration for
the output of Special:EntityData. $wgWBRepoSettings['dataSquidMaxage']
defaults to $wgSquidMaxage, but should be overwritten when and where
$wgSquidMaxage is larger than a few hours, since entity data isn't
automatically purged from HTTP caches.

Change-Id: I1dabe792619c5ebd690bfe3e7bf5cd28eb5f19c9
---
M repo/config/Wikibase.default.php
M repo/includes/specials/SpecialEntityData.php
2 files changed, 18 insertions(+), 8 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/config/Wikibase.default.php b/repo/config/Wikibase.default.php
index da4768c..2bf1276 100644
--- a/repo/config/Wikibase.default.php
+++ b/repo/config/Wikibase.default.php
@@ -30,6 +30,7 @@
  */
 
 return call_user_func( function() {
+   global $wgSquidMaxage;
 
$defaults = array(
 
@@ -72,6 +73,10 @@
 
// Should the page names (titles) be normalized against the 
external site
'normalizeItemByTitlePageNames' => false,
+
+   // Number of seconds for which data output shall be cached.
+   // Note: keep that low, because such caches can not always be 
purged easily.
+   'dataSquidMaxage' => $wgSquidMaxage,
);
 
return $defaults;
diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index c086a97..368445b 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -89,6 +89,11 @@
protected $idFormatter = null;
 
/**
+* @var int Cache dureation in seconds
+*/
+   protected $maxAge = 0;
+
+   /**
 * @var null|array Associative array from MIME type to format name
 * @note: initialized by initFormats()
 */
@@ -173,6 +178,7 @@
$this->entityLookup = 
\Wikibase\StoreFactory::getStore()->getEntityLookup();
$this->dataTypeFactory = $repo->getDataTypeFactory();
$this->idFormatter = $repo->getIdFormatter();
+   $this->maxAge = \Wikibase\Settings::get( 'dataSquidMaxage' );
 
$this->showData( $format, $id, $revision );
}
@@ -606,25 +612,24 @@
 * @param Revision $revision
 */
public function outputData( $data, $contentType, Revision $revision = 
null ) {
-   global $wgSquidMaxage;
-
// NOTE: similar code as in RawAction::onView, keep in sync.
 
$request = $this->getRequest();
$response = $request->response();
 
-   $maxage = $request->getInt( 'maxage', $wgSquidMaxage );
-   $smaxage = $request->getInt( 'smaxage', $wgSquidMaxage );
+   $maxage = $request->getInt( 'maxage', $this->maxAge );
+   $smaxage = $request->getInt( 'smaxage', $this->maxAge );
 
-   // Sanity: 0 to 30 days. // todo: Hard maximum could be 
configurable somehow.
-   $maxage  = max( 0, min( 60 * 60 * 24 * 30, $maxage ) );
-   $smaxage = max( 0, min( 60 * 60 * 24 * 30, $smaxage ) );
+   // XXX: do we want public caching even for data from old 
revisions?
+   // Sanity: 0 to 31 days. // todo: Hard maximum could be 
configurable somehow.
+   $maxage  = max( 0, min( 60 * 60 * 24 * 31, $maxage ) );
+   $smaxage = max( 0, min( 60 * 60 * 24 * 31, $smaxage ) );
 
$response->header( 'Content-Type: ' . $contentType . '; 
charset=UTF-8' );
$response->header( 'Content-Length: ' . strlen( $data ) );
 
if ( $revision ) {
-   $response->header( 'Last-Modified: ' . wfTimestamp( 
TS_ISO_8601, $revision->getTimestamp() ) );
+   $response->header( 'Last-Modified: ' . wfTimestamp( 
TS_RFC2822, $revision->getTimestamp() ) );
}
 
//Set X-Frame-Options API results (bug 39180)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1dabe792619c5ebd690bfe3e7bf5cd28eb5f19c9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Denny Vrandecic 
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] Purging of cached output from Special:EntityData. - change (mediawiki...Wikibase)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Purging of cached output from Special:EntityData.
..


Purging of cached output from Special:EntityData.

This will cause Special:EntityData to purge HTTP caches
if action=purge is given in the URL. Note that currently,
only the presently requested format of the output is purged.

Change-Id: Ic13fb09ad5abbeafe2b527c07245cf20ea4f737a
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 46 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index c086a97..a241509 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -120,6 +120,8 @@
$revision = 0;
$format = '';
 
+   $requestedSubPage = $subPage;
+
// get format from $subPage or request param
if ( preg_match( '#\.([-./\w]+)$#', $subPage, $m ) ) {
$subPage = preg_replace( '#\.([-./\w]+)$#', '', 
$subPage );
@@ -144,6 +146,11 @@
if ( $id === null || $id === '' ) {
$this->showForm();
return;
+   }
+
+   //XXX: allow for logged in users only?
+   if ( $this->getRequest()->getText( 'action', 'purge' ) ) {
+   $this->purge( $id, $format, $revision );
}
 
if ( $format === null || $format === '' ) {
@@ -178,6 +185,45 @@
}
 
/**
+* Purges the entity data identified by the subPage parameter from any 
HTTP caches.
+*
+* @param string $id
+* @param string $format
+* @param int$revision
+*/
+   protected function purge( $id, $format = '', $revision = 0 ) {
+   global $wgUseSquid;
+
+   if ( $wgUseSquid ) {
+   //TODO: purge all formats based on the ID, instead of 
just the one currently requested
+   $subPage = $this->getSubPageName( $id, $format, 
$revision );
+
+   $title = $this->getTitle( $subPage );
+
+   $urls = array();
+   $urls[] = $title->getInternalURL();
+
+   $u = new SquidUpdate( $urls );
+   $u->doUpdate();
+   }
+   }
+
+   public function getSubPageName( $id, $format, $revision ) {
+   //TODO: force canonical ID (upper- or lower case) by redirecting
+   $subPage = $id;
+
+   if ( $revision > 0 ) {
+   $subPage .= ':' . $revision;
+   }
+
+   if ( $format !== null && $format !== '' ) {
+   $subPage .= '.' . $format;
+   }
+
+   return $subPage;
+   }
+
+   /**
 * Returns the list of supported MIME types that can be used to specify 
the
 * output format.
 *

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic13fb09ad5abbeafe2b527c07245cf20ea4f737a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Jeroen De Dauw 
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] Removed word 'proleptic' from message - change (mediawiki...DataValues)

2013-05-22 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Removed word 'proleptic' from message
..


Removed word 'proleptic' from message

- this was misleading and just wrong in some cases

Change-Id: I52af5203b012ed50af8bf2f307c9ef69eb6b4014
---
M ValueView/ValueView.i18n.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ValueView/ValueView.i18n.php b/ValueView/ValueView.i18n.php
index 62cce5d..de50785 100644
--- a/ValueView/ValueView.i18n.php
+++ b/ValueView/ValueView.i18n.php
@@ -48,7 +48,7 @@
// TimeInput expert:
'valueview-expert-timeinput-precision' => 'Precision:',
'valueview-expert-timeinput-calendar' => 'Calendar:',
-   'valueview-expert-timeinput-calendarhint' => '(proleptic $1 calendar)',
+   'valueview-expert-timeinput-calendarhint' => '($1 calendar)',
'valueview-expert-timeinput-calendarhint-switch' => '→ change to 
$1',
 
'valueview-preview-label' => 'will be displayed as:',

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I52af5203b012ed50af8bf2f307c9ef69eb6b4014
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher 
Gerrit-Reviewer: Denny Vrandecic 
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] (bug 44576) Select format based on Accept header. - change (mediawiki...Wikibase)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: (bug 44576) Select format based on Accept header.
..


(bug 44576) Select format based on Accept header.

This implements content negotiation for Special:EntityData,
based on the Accept header.

NOTE: this does not yet implement a redirect to a canonical
URL, so it does not resolve the ticket.

Change-Id: I73ebc6c9936fabd8eb0fb29ed1bce63ced514a4a
---
M lib/WikibaseLib.classes.php
M lib/WikibaseLib.hooks.php
A lib/includes/util/HttpAcceptNegotiator.php
A lib/includes/util/HttpAcceptParser.php
A lib/tests/phpunit/util/HttpAcceptNegotiatorTest.php
A lib/tests/phpunit/util/HttpAcceptParserTest.php
M repo/includes/specials/SpecialEntityData.php
M repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
8 files changed, 826 insertions(+), 8 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/WikibaseLib.classes.php b/lib/WikibaseLib.classes.php
index 6262c0c..f6a050d 100644
--- a/lib/WikibaseLib.classes.php
+++ b/lib/WikibaseLib.classes.php
@@ -131,6 +131,10 @@
'Wikibase\SiteLinkTable' => 
'includes/store/sql/SiteLinkTable.php',
'Wikibase\WikiPageEntityLookup' => 
'includes/store/sql/WikiPageEntityLookup.php',
 
+   // includes/util
+   'Wikibase\HttpAcceptNegotiator' => 
'includes/util/HttpAcceptNegotiator.php',
+   'Wikibase\HttpAcceptParser' => 
'includes/util/HttpAcceptParser.php',
+
// tests
'Wikibase\Test\SpecialPageTestBase' => 
'tests/phpunit/specials/SpecialPageTestBase.php',
'Wikibase\Test\TemplateTest' => 
'tests/phpunit/TemplateTest.php',
diff --git a/lib/WikibaseLib.hooks.php b/lib/WikibaseLib.hooks.php
index 968e91e..e654bce 100644
--- a/lib/WikibaseLib.hooks.php
+++ b/lib/WikibaseLib.hooks.php
@@ -67,6 +67,9 @@
 
'store/TermPropertyLabelResolver',
 
+   'util/HttpAcceptParser',
+   'util/HttpAcceptNegotiator',
+
'ByPropertyIdArray',
'ChangesTable',
'ClaimDifference',
diff --git a/lib/includes/util/HttpAcceptNegotiator.php 
b/lib/includes/util/HttpAcceptNegotiator.php
new file mode 100644
index 000..ef0f338
--- /dev/null
+++ b/lib/includes/util/HttpAcceptNegotiator.php
@@ -0,0 +1,165 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @license GPL 2+
+ * @file
+ *
+ * @author Daniel Kinzler
+ */
+
+
+namespace Wikibase;
+
+
+/**
+ * Utility for negotiating a value from a set of supported values using a 
preference list.
+ * This is intended for use with HTTP headers like Accept, Accept-Language, 
Accept-Encoding, etc.
+ *
+ * To use this with a request header, first parse the header value into an 
array of weights
+ * using HttpAcceptParser, then call getBestSupportedKey.
+ *
+ * Class HttpAcceptNegotiator
+ * @package Wikibase
+ */
+
+class HttpAcceptNegotiator {
+
+   /**
+* @var array
+*/
+   protected $supportedValues;
+
+   /**
+* @var mixed
+*/
+   protected $defaultValue;
+
+   /**
+* @param array $supported A list of supported values.
+*/
+   public function __construct( array $supported ) {
+   $this->supportedValues = $supported;
+   $this->defaultValue = reset( $supported );
+   }
+
+   /**
+* Returns a supported value to be used as a default.
+*/
+   public function getDefaultSupportedValue() {
+   return $this->defaultValue;
+   }
+
+   /**
+* Returns the best supported key from the given weight map. Of the 
keys from the
+* $weights parameter that are also in the list of supported values 
supplied to
+* the constructor, this returns the key that has the highest value 
associated
+* with it. Keys that map to 0 or false are ignored. If no such key is 
found,
+* $default is returned.
+*
+* @param array $weights An associative array mapping accepted values 
to their
+*  respective weights.
+*
+* @param null|string $default The value to return if non of the keys 
in $weights
+*  is supported (null per default).
+*
+* @return null|string The best supported key from the $weights 
parameter.
+*/
+   public function getBestSupportedKey( array $weights, $default = null ) {
+   // it's an associative list. Sort by value and...
+   asort( $weights );
+
+   // remove any keys with values equal to 0 or false (HTTP/1.1 
section 3.9)
+   $weights = array_filter( $weights );
+
+   // ...use the ordered list of keys
+   $preferences = array_reverse( array_keys( $weights ) );
+
+   $

[MediaWiki-commits] [Gerrit] Add DataValues as requirement in composer.json - change (mediawiki...Ask)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add DataValues as requirement in composer.json
..


Add DataValues as requirement in composer.json

Change-Id: I72c129c3a63369862c98837f42c818cd3536fd5b
---
M composer.json
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/composer.json b/composer.json
index 0ef4ba6..33e243c 100644
--- a/composer.json
+++ b/composer.json
@@ -25,7 +25,8 @@
"wiki": "https://www.mediawiki.org/wiki/Extension:Ask";
},
"require": {
-   "php": ">=5.3.0"
+   "php": ">=5.3.0",
+   "mediawiki/data-values": "*"
},
"require-dev": {
"phpunit/phpunit": "*"

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I72c129c3a63369862c98837f42c818cd3536fd5b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 Travis CI build status image to readme.md - change (mediawiki...Ask)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added Travis CI build status image to readme.md
..


Added Travis CI build status image to readme.md

Change-Id: I665a0d04094b2b5a771f16a314a46d98b1c12c38
---
R README.md
1 file changed, 2 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/README b/README.md
similarity index 72%
rename from README
rename to README.md
index 0defcbc..3171275 100644
--- a/README
+++ b/README.md
@@ -1,3 +1,5 @@
+[![Build 
Status](https://secure.travis-ci.org/JeroenDeDauw/Ask.png?branch=master)](http://travis-ci.org/JeroenDeDauw/Ask)
+
 These is the readme file for the Ask library.
 
 Extension page on mediawiki.org: https://www.mediawiki.org/wiki/Extension:Ask

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I665a0d04094b2b5a771f16a314a46d98b1c12c38
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Throw an exception when DataValues is not loaded rather then... - change (mediawiki...Ask)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Throw an exception when DataValues is not loaded rather then 
outputting HTML
..


Throw an exception when DataValues is not loaded rather then outputting HTML

Change-Id: I6f492875d5ad5834247f3797a8e95afc5f798525
---
M Ask.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved



diff --git a/Ask.php b/Ask.php
index ac09743..ee09f6d 100644
--- a/Ask.php
+++ b/Ask.php
@@ -35,7 +35,7 @@
 
 // Only initialize the extension when all dependencies are present.
 if ( !defined( 'DataValues_VERSION' ) ) {
-   die( 'Error: You need to have https://www.mediawiki.org/wiki/Extension:DataValues";>DataValues 
installed in order to use http://www.mediawiki.org/wiki/Extension:Ask";>Ask.' );
+   throw new Exception( 'You need to have the DataValues library loaded in 
order to use Ask' );
 }
 
 define( 'Ask_VERSION', '0.1 alpha' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6f492875d5ad5834247f3797a8e95afc5f798525
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Improved ListPatcherTest - change (mediawiki...Diff)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Improved ListPatcherTest
..


Improved ListPatcherTest

Change-Id: Ie4be97512dd2831ffd5d88f7da5e859fcc5ac37c
---
M tests/phpunit/patcher/ListPatcherTest.php
1 file changed, 82 insertions(+), 18 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/patcher/ListPatcherTest.php 
b/tests/phpunit/patcher/ListPatcherTest.php
index 32bfaa4..8234c01 100644
--- a/tests/phpunit/patcher/ListPatcherTest.php
+++ b/tests/phpunit/patcher/ListPatcherTest.php
@@ -5,6 +5,7 @@
 use Diff\Diff;
 use Diff\DiffOpAdd;
 use Diff\DiffOpRemove;
+use Diff\ListPatcher;
 use Diff\MapPatcher;
 use Diff\Patcher;
 
@@ -42,14 +43,77 @@
public function patchProvider() {
$argLists = array();
 
-   $patcher = new \Diff\ListPatcher();
+   $patcher = new ListPatcher();
$base = array();
$diff = new Diff();
$expected = array();
 
$argLists[] = array( $patcher, $base, $diff, $expected );
 
-   // TODO
+
+   $patcher = new ListPatcher();
+   $base = array( 4, 2 );
+   $diff = new Diff();
+   $expected = array( 4, 2 );
+
+   $argLists[] = array( $patcher, $base, $diff, $expected );
+
+
+   $patcher = new ListPatcher();
+   $base = array();
+   $diff = new Diff( array(
+   new DiffOpAdd( 9001 )
+   ) );
+   $expected = array( 9001 );
+
+   $argLists[] = array( $patcher, $base, $diff, $expected );
+
+
+   $patcher = new ListPatcher();
+   $base = array( 4, 2 );
+   $diff = new Diff( array(
+   new DiffOpAdd( 9001 )
+   ) );
+   $expected = array( 4, 2, 9001 );
+
+   $argLists[] = array( $patcher, $base, $diff, $expected );
+
+
+   $patcher = new ListPatcher();
+   $base = array( 4, 2 );
+   $diff = new Diff( array(
+   new DiffOpAdd( 9001 ),
+   new DiffOpAdd( 9002 ),
+   new DiffOpAdd( 2 )
+   ) );
+   $expected = array( 4, 2, 9001, 9002, 2 );
+
+   $argLists[] = array( $patcher, $base, $diff, $expected );
+
+
+   $patcher = new ListPatcher();
+   $base = array( 0, 1, 2, 3, 4 );
+   $diff = new Diff( array(
+   new DiffOpRemove( 2 ),
+   new DiffOpRemove( 3 ),
+   ) );
+   $expected = array( 0, 1, 4 );
+
+   $argLists[] = array( $patcher, $base, $diff, $expected );
+
+
+   $patcher = new ListPatcher();
+   $base = array( 0, 1, 2, 2, 2, 3, 4 );
+   $diff = new Diff( array(
+   new DiffOpRemove( 2 ),
+   new DiffOpRemove( 3 ),
+   new DiffOpAdd( 6 ),
+   new DiffOpRemove( 2 ),
+   ) );
+   $expected = array( 0, 1, 2, 4, 6 );
+
+   $argLists[] = array( $patcher, $base, $diff, $expected );
+
 
return $argLists;
}
@@ -65,7 +129,22 @@
public function testPatch( Patcher $patcher, array $base, Diff $diff, 
array $expected ) {
$actual = $patcher->patch( $base, $diff );
 
-   $this->assertArrayEquals( $actual, $expected );
+   $this->assertArrayEquals( $expected, $actual );
+   }
+
+   /**
+* @dataProvider getApplicableDiffProvider
+*
+* @param Diff $diff
+* @param array $currentObject
+* @param Diff $expected
+* @param string|null $message
+*/
+   public function testGetApplicableDiff( Diff $diff, array 
$currentObject, Diff $expected, $message = null ) {
+   $patcher = new MapPatcher();
+   $actual = $patcher->getApplicableDiff( $currentObject, $diff );
+
+   $this->assertEquals( $expected->getOperations(), 
$actual->getOperations(), $message );
}
 
public function getApplicableDiffProvider() {
@@ -152,21 +231,6 @@
$argLists[] = array( $diff, $currentObject, $expected, 'list 
diffs containing only remove ops should be retained when present in the base' );
 
return $argLists;
-   }
-
-   /**
-* @dataProvider getApplicableDiffProvider
-*
-* @param Diff $diff
-* @param array $currentObject
-* @param Diff $expected
-* @param string|null $message
-*/
-   public function testGetApplicableDiff( Diff $diff, array 
$currentObject, Diff $expected, $message = null ) {
-   $patcher = new MapPatcher();
-   

[MediaWiki-commits] [Gerrit] Add unhappy path test to CallbackListDifferTest - change (mediawiki...Diff)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add unhappy path test to CallbackListDifferTest
..


Add unhappy path test to CallbackListDifferTest

Change-Id: Ifb2ea1f2f15febac9e879896e2dbeb4fafed7a01
---
M tests/phpunit/differ/CallbackListDifferTest.php
1 file changed, 10 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/differ/CallbackListDifferTest.php 
b/tests/phpunit/differ/CallbackListDifferTest.php
index d92c830..c1a9a03 100644
--- a/tests/phpunit/differ/CallbackListDifferTest.php
+++ b/tests/phpunit/differ/CallbackListDifferTest.php
@@ -231,4 +231,14 @@
);
}
 
+   public function testCallbackComparisonReturningNyanCat() {
+   $differ = new CallbackListDiffer( function( $foo, $bar ) {
+   return '~=[,,_,,]:3';
+   } );
+
+   $this->setExpectedException( 'Exception' );
+
+   $differ->doDiff( array( 1, '2', 'baz' ), array( 1, 'foo', '2' ) 
);
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifb2ea1f2f15febac9e879896e2dbeb4fafed7a01
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Add unhappy path test to MapDifferTest - change (mediawiki...Diff)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add unhappy path test to MapDifferTest
..


Add unhappy path test to MapDifferTest

Change-Id: Iba9b99b71852a4758a8fce7756cb0c2ef5da50c7
---
M tests/phpunit/differ/MapDifferTest.php
1 file changed, 12 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/differ/MapDifferTest.php 
b/tests/phpunit/differ/MapDifferTest.php
index 27a4d03..faf40ef 100644
--- a/tests/phpunit/differ/MapDifferTest.php
+++ b/tests/phpunit/differ/MapDifferTest.php
@@ -198,4 +198,16 @@
);
}
 
+   public function testCallbackComparisonReturningNyanCat() {
+   $differ = new MapDiffer();
+
+   $differ->setComparisonCallback( function( $foo, $bar ) {
+   return '~=[,,_,,]:3';
+   } );
+
+   $this->setExpectedException( 'Exception' );
+
+   $differ->doDiff( array( 1, '2', 'baz' ), array( 1, 'foo', '2' ) 
);
+   }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iba9b99b71852a4758a8fce7756cb0c2ef5da50c7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Add unhappy path test to DiffTest - change (mediawiki...Diff)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add unhappy path test to DiffTest
..


Add unhappy path test to DiffTest

Change-Id: I31abcd1a5273ce8b600a1bb33130924c4653f9c6
---
M tests/phpunit/diffop/diff/DiffTest.php
1 file changed, 19 insertions(+), 0 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/diffop/diff/DiffTest.php 
b/tests/phpunit/diffop/diff/DiffTest.php
index 137686d..5f41319 100644
--- a/tests/phpunit/diffop/diff/DiffTest.php
+++ b/tests/phpunit/diffop/diff/DiffTest.php
@@ -610,5 +610,24 @@
$this->assertArrayEquals( $list, $copy, true, true );
}
 
+   /**
+* @dataProvider instanceProvider
+*
+* @since 0.6
+*
+* @param Diff $list
+*/
+   public function testAddInvalidDiffOp( Diff $list ) {
+   $invalidDiffOp = $this->getMock( 'Diff\DiffOp' );
+
+   $invalidDiffOp->expects( $this->atLeastOnce() )
+   ->method( 'getType' )
+   ->will( $this->returnValue( '~=[,,_,,]:3' ) );
+
+   $this->setExpectedException( 'Exception' );
+
+   $list->append( $invalidDiffOp );
+   }
+
 }


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

Gerrit-MessageType: merged
Gerrit-Change-Id: I31abcd1a5273ce8b600a1bb33130924c4653f9c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
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 48145) Moves "Time" data type out of experimental - change (mediawiki...Wikibase)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: (bug 48145) Moves "Time" data type out of experimental
..


(bug 48145) Moves "Time" data type out of experimental

Change-Id: I6d137b9d4e55fdcf545562b41aa1c3d10b1da937
IMPORTANT: this should not be merged before I3743781 got merged into the 
DataValues repository.
---
M lib/config/WikibaseLib.default.php
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/config/WikibaseLib.default.php 
b/lib/config/WikibaseLib.default.php
index 2ab5c81..d98f6df 100644
--- a/lib/config/WikibaseLib.default.php
+++ b/lib/config/WikibaseLib.default.php
@@ -86,6 +86,7 @@
'wikibase-item',
'commonsMedia',
'string',
+   'time',
),
);
 
@@ -97,7 +98,6 @@
'quantity',
'monolingual-text',
'multilingual-text',
-   'time',
) );
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6d137b9d4e55fdcf545562b41aa1c3d10b1da937
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
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 some deprecated methods - change (mediawiki...Diff)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Remove some deprecated methods
..


Remove some deprecated methods

Change-Id: If918a7ed1346dbf2924dbc7106adbc19376abe59
---
M Diff.php
M RELEASE-NOTES
M includes/diffop/diff/ListDiff.php
M includes/diffop/diff/MapDiff.php
4 files changed, 8 insertions(+), 63 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Diff.php b/Diff.php
index 8ef7b23..a3a846a 100644
--- a/Diff.php
+++ b/Diff.php
@@ -28,7 +28,7 @@
  * @ingroup Test
  */
 
-define( 'Diff_VERSION', '0.6' );
+define( 'Diff_VERSION', '0.7 alpha' );
 
 // @codeCoverageIgnoreStart
 call_user_func( function() {
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 7975a00..a9b39a3 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -4,6 +4,13 @@
 Latest version of the release notes: 
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Diff.git;a=blob;f=RELEASE-NOTES
 
 
+=== Version 0.7 ===
+(dev)
+
+; Removals
+
+* Removed static methods from ListDiff and MapDiff (all deprecated since 0.4)
+
 === Version 0.6 ===
 2013-05-08
 
diff --git a/includes/diffop/diff/ListDiff.php 
b/includes/diffop/diff/ListDiff.php
index 859ac96..6b5d8d3 100644
--- a/includes/diffop/diff/ListDiff.php
+++ b/includes/diffop/diff/ListDiff.php
@@ -38,22 +38,6 @@
}
 
/**
-* Creates a new ListDiff given two arrays.
-*
-* @since 0.1
-* @deprecated since 0.4, use ListDiffer::doDiff instead
-*
-* @param array $firstList
-* @param array $secondList
-*
-* @return ListDiff
-*/
-   public static function newFromArrays( array $firstList, array 
$secondList ) {
-   $differ = new ListDiffer();
-   return new static( $differ->doDiff( $firstList, $secondList ) );
-   }
-
-   /**
 * @see DiffOp::getType
 *
 * @since 0.1
diff --git a/includes/diffop/diff/MapDiff.php b/includes/diffop/diff/MapDiff.php
index 2a30d81..5098e13 100644
--- a/includes/diffop/diff/MapDiff.php
+++ b/includes/diffop/diff/MapDiff.php
@@ -26,52 +26,6 @@
}
 
/**
-* Creates and returns an empty MapDiff.
-*
-* @since 0.1
-* @deprecated since 0.4, just use the constructor
-*
-* @return MapDiff
-*/
-   public static function newEmpty() {
-   return new self( array() );
-   }
-
-   /**
-* Creates a new MapDiff given two arrays.
-*
-* @since 0.1
-* @deprecated since 0.4, use MapDiffer::doDiff instead
-*
-* @param array $oldValues
-* @param array $newValues
-* @param boolean $recursively
-*
-* @return MapDiff
-*/
-   public static function newFromArrays( array $oldValues, array 
$newValues, $recursively = false ) {
-   $differ = new MapDiffer( $recursively );
-   return new static( $differ->doDiff( $oldValues, $newValues ) );
-   }
-
-   /**
-* Computes the diff between two associate arrays.
-*
-* @since 0.1
-* @deprecated since 0.4, use MapDiffer::doDiff instead
-*
-* @param array $oldValues The first array
-* @param array $newValues The second array
-* @param boolean $recursively If elements that are arrays should also 
be diffed.
-*
-* @return DiffOp[]
-*/
-   public static function doDiff( array $oldValues, array $newValues, 
$recursively = false ) {
-   $differ = new MapDiffer( $recursively );
-   return $differ->doDiff( $oldValues, $newValues );
-   }
-
-   /**
 * @see DiffOp::getType
 *
 * @since 0.1

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If918a7ed1346dbf2924dbc7106adbc19376abe59
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Anja Jentzsch 
Gerrit-Reviewer: Ataherivand 
Gerrit-Reviewer: Aude 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Daniel Werner 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: Henning Snater 
Gerrit-Reviewer: Jens Ohlig 
Gerrit-Reviewer: Jeroen De Dauw 
Gerrit-Reviewer: John Erling Blad 
Gerrit-Reviewer: Lydia Pintscher 
Gerrit-Reviewer: Markus Kroetzsch 
Gerrit-Reviewer: Nikola Smolenski 
Gerrit-Reviewer: Silke Meyer 
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] Fixed wrong decade precision - change (mediawiki...DataValues)

2013-05-21 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Fixed wrong decade precision
..


Fixed wrong decade precision

Bug: 48673
Change-Id: Ic819a280783ac0afe261988b913d14ee0d57c061
---
M DataValues/resources/time.js/src/time.js
1 file changed, 11 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DataValues/resources/time.js/src/time.js 
b/DataValues/resources/time.js/src/time.js
index 116d593..74fc6bd 100644
--- a/DataValues/resources/time.js/src/time.js
+++ b/DataValues/resources/time.js/src/time.js
@@ -146,8 +146,16 @@
};
 
var writeApproximateYear = function( year, precision ) {
-   var significant = Math.floor( (Math.abs( year ) - 1) / 
Math.pow( 10, 9 - precision ) ) + 1,
-   text = settings.outputprecision[precision].replace( 
'%', significant );
+   var significant = 0,
+   text = '';
+
+   if( precision == 8 ) {
+   significant = Math.floor( ( Math.abs( year ) ) / 
Math.pow( 10, 9 - precision ) );
+   } else {
+   significant = Math.floor( ( Math.abs( year ) - 1) / 
Math.pow( 10, 9 - precision ) ) + 1;
+   }
+
+   text = settings.outputprecision[precision].replace( '%', 
significant );
 
if( precision < 6 ) {
if( year < 0 ) {
@@ -160,6 +168,7 @@
text += ' ' + settings.bce[0];
}
}
+
return text;
};
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic819a280783ac0afe261988b913d14ee0d57c061
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] changed namespaces a bit, added license - change (mediawiki...Wikibase)

2013-05-19 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: changed namespaces a bit, added license
..

changed namespaces a bit, added license

Change-Id: Iea1d34372ba30466d8b76a3650c95cfabadc21dd
---
M repo/includes/rdf/RdfBuilder.php
1 file changed, 16 insertions(+), 13 deletions(-)


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

diff --git a/repo/includes/rdf/RdfBuilder.php b/repo/includes/rdf/RdfBuilder.php
index 2267357..da8aadd 100755
--- a/repo/includes/rdf/RdfBuilder.php
+++ b/repo/includes/rdf/RdfBuilder.php
@@ -56,9 +56,11 @@
 
const NS_SKOS = 'skos'; // SKOS vocabulary
const NS_SCHEMA_ORG = 'schema'; // schema.org vocabulary
+   const NS_CC = 'cc';
 
const SKOS_URI = 'http://www.w3.org/2004/02/skos/core#';
const SCHEMA_ORG_URI = 'http://schema.org/';
+   const CC_URI = 'http://creativecommons.org/ns#';
 
const WIKIBASE_STATEMENT_QNAME = 'wikibase:Statement';
 
@@ -99,14 +101,15 @@
 
$this->namespaces = array(
self::NS_ONTOLOGY => self::ONTOLOGY_BASE_URI,
-   self::NS_DATA => $this->baseUri . '/data/',
+   self::NS_DATA => $this->baseUri . '/entity/',
self::NS_ENTITY => $this->baseUri . '/entity/',
-   self::NS_PROPERTY => $this->baseUri . '/property/',
-   self::NS_VALUE => $this->baseUri . '/value/',
-   self::NS_QUALIFIER => $this->baseUri . '/qualifier/',
-   self::NS_STATEMENT => $this->baseUri . '/statement/',
+   self::NS_PROPERTY => $this->baseUri . '/entity/',
+   self::NS_VALUE => $this->baseUri . '/entity/value/',
+   self::NS_QUALIFIER => $this->baseUri . 
'/entity/qualifier/',
+   self::NS_STATEMENT => $this->baseUri . 
'/entity/statement/',
self::NS_SKOS => self::SKOS_URI,
self::NS_SCHEMA_ORG => self::SCHEMA_ORG_URI,
+   self::NS_CC => self::CC_URI,
);
 
//XXX: Ugh, static. Should go into $this->graph.
@@ -154,7 +157,7 @@
 * @return string
 */
public function getEntityQName( $prefix, EntityId $id ) {
-   return $prefix . ':' . $this->idFormatter->format( $id );
+   return $prefix . ':' . ucfirst( $this->idFormatter->format( $id 
) );
}
 
/**
@@ -205,7 +208,7 @@
 */
public function getDataURL( EntityId $id ) {
$base = $this->namespaces[ self::NS_DATA ];
-   $url = $base . $this->idFormatter->format( $id );
+   $url = $base . ucfirst( $this->idFormatter->format( $id ) ) . 
'.rdf';
return $url;
}
 
@@ -253,12 +256,12 @@
public function addEntityMetaData( Entity $entity, Revision $rev = null 
) {
$entityResource = $this->getEntityResource( $entity->getId() );
$entityResource->addResource( 'rdf:type', 
$this->getEntityTypeQName( $entity->getType() ) );
-
-   $dataResource = $this->graph->resource( '#' ); // "this 
document"
$dataURL = $this->getDataURL( $entity->getId() );
-   $dataResource->addResource( self::NS_SCHEMA_ORG . ':about', 
$entityResource );
-   $dataResource->addResource( self::NS_SCHEMA_ORG . ':url', 
$dataURL );
+
+   $dataResource = $this->graph->resource( $dataURL ); // "this 
document"
$dataResource->addResource( 'rdf:type', self::NS_SCHEMA_ORG . 
":Dataset" );
+   $dataResource->addResource( self::NS_SCHEMA_ORG . ':about', 
$entityResource );
+   $dataResource->addResource( self::NS_CC . ':license', 
'http://creativecommons.org/publicdomain/zero/1.0/' );
 
if ( $rev ) {
$dataResource->addLiteral( self::NS_SCHEMA_ORG . 
':version', $rev->getId() );
@@ -346,9 +349,9 @@
$url = wfExpandUrl( $link->getUrl(), PROTO_HTTP );
$pageRecourse = $this->graph->resource( $url );
 
-   $pageRecourse->addResource( self::NS_SCHEMA_ORG . 
':about', $entityResource );
-   $pageRecourse->addResource( self::NS_SCHEMA_ORG . 
':inLanguage', $languageCode );
$pageRecourse->addResource( 'rdf:type', 
self::NS_SCHEMA_ORG . ':Article' );
+   $pageRecourse->addResource( self::NS_SCHEMA_ORG . 
':about', $entityResource );
+   $pageRecourse->addLiteral( self::NS_SCHEMA_ORG . 
':inLanguage', $languageCode );
}
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/64538
To unsubscribe, visit https://gerrit.wikimedia.org/r/setting

[MediaWiki-commits] [Gerrit] Throw a TableCreationFailedException when table creation fai... - change (mediawiki...Wikibase)

2013-05-17 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Throw a TableCreationFailedException when table creation fails 
rather then returning false
..


Throw a TableCreationFailedException when table creation fails rather then 
returning false

Change-Id: Idf0e573df2a1349bcdcdd97096335ba1c7008c83
---
M Database/includes/MediaWikiQueryInterface.php
M Database/includes/TableBuilder.php
M Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
M QueryEngine/includes/SQLStore/Setup.php
4 files changed, 41 insertions(+), 18 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Database/includes/MediaWikiQueryInterface.php 
b/Database/includes/MediaWikiQueryInterface.php
index b404cd0..0c02e71 100644
--- a/Database/includes/MediaWikiQueryInterface.php
+++ b/Database/includes/MediaWikiQueryInterface.php
@@ -82,10 +82,14 @@
 *
 * @param TableDefinition $table
 *
-* @return boolean Success indicator
+* @throws TableCreationFailedException
 */
public function createTable( TableDefinition $table ) {
-   return $this->extendedAbstraction->createTable( $table );
+   $success = $this->extendedAbstraction->createTable( $table );
+
+   if ( $success !== true ) {
+   throw new TableCreationFailedException( $table );
+   }
}
 
/**
diff --git a/Database/includes/TableBuilder.php 
b/Database/includes/TableBuilder.php
index d0876cc..db35afc 100644
--- a/Database/includes/TableBuilder.php
+++ b/Database/includes/TableBuilder.php
@@ -72,8 +72,6 @@
 * @since 0.1
 *
 * @param TableDefinition $table
-*
-* @return boolean Success indicator
 */
public function createTable( TableDefinition $table ) {
if ( $this->db->tableExists( $table->getName() ) ) {
@@ -83,7 +81,7 @@
 
$this->report( 'Table "' . $table->getName() . '" not found, 
creating.' );
 
-   return $this->db->createTable( $table );
+   $this->db->createTable( $table );
}
 
 }
\ No newline at end of file
diff --git a/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php 
b/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
index 08c9520..f2d7b00 100644
--- a/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
+++ b/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
@@ -104,7 +104,32 @@
 
$extendedAbstraction->expects( $this->once() )
->method( 'createTable' )
-   ->with( $this->equalTo( $table ) );
+   ->with( $this->equalTo( $table ) )
+   ->will( $this->returnValue( true ) );
+
+   $queryInterface->createTable( $table );
+   }
+
+   /**
+* @dataProvider tableProvider
+*
+* @param TableDefinition $table
+*/
+   public function testCreateTableFailure( TableDefinition $table ) {
+   $connection = $this->getMock( 'DatabaseMysql' );
+   $extendedAbstraction = $this->getMockBuilder( 
'\Wikibase\Database\MWDB\ExtendedMySQLAbstraction' )
+   ->disableOriginalConstructor()->getMock();
+
+   $queryInterface = new MediaWikiQueryInterface(
+   new DirectConnectionProvider( $connection ),
+   $extendedAbstraction
+   );
+
+   $extendedAbstraction->expects( $this->once() )
+   ->method( 'createTable' )
+   ->will( $this->returnValue( false ) );
+
+   $this->setExpectedException( 
'Wikibase\Database\TableCreationFailedException' );
 
$queryInterface->createTable( $table );
}
diff --git a/QueryEngine/includes/SQLStore/Setup.php 
b/QueryEngine/includes/SQLStore/Setup.php
index c4ccd86..a48a39c 100644
--- a/QueryEngine/includes/SQLStore/Setup.php
+++ b/QueryEngine/includes/SQLStore/Setup.php
@@ -5,6 +5,7 @@
 use MessageReporter;
 use Wikibase\Database\FieldDefinition;
 use Wikibase\Database\QueryInterface;
+use Wikibase\Database\QueryInterfaceException;
 use Wikibase\Database\TableBuilder;
 use Wikibase\Database\TableDefinition;
 
@@ -104,36 +105,31 @@
 * Install the store.
 *
 * @since 0.1
-*
-* @return boolean Success indicator
 */
public function install() {
$this->report( 'Starting install of ' . 
$this->config->getStoreName() );
 
-   $success = $this->setupTables();
+   try {
+   $this->setupTables();
+   }
+   catch ( QueryInterfaceException $exception ) {
+   // TODO: throw exception of proper type
+   }
 
// TODO: initialize basic content
 

[MediaWiki-commits] [Gerrit] Added SelectFailedException - change (mediawiki...Wikibase)

2013-05-17 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Added SelectFailedException
..


Added SelectFailedException

Change-Id: Ied44503ca68e0156bb445787c64d958119149f8e
---
M Database/includes/MediaWikiQueryInterface.php
A Database/includes/SelectFailedException.php
M Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
A Database/tests/phpunit/SelectFailedExceptionTest.php
4 files changed, 137 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Database/includes/MediaWikiQueryInterface.php 
b/Database/includes/MediaWikiQueryInterface.php
index b404cd0..8aeffca 100644
--- a/Database/includes/MediaWikiQueryInterface.php
+++ b/Database/includes/MediaWikiQueryInterface.php
@@ -178,6 +178,7 @@
 * @param array $conditions
 *
 * @return ResultIterator
+* @throws SelectFailedException
 */
public function select( $tableName, array $fields, array $conditions ) {
$selectionResult = $this->getDB()->select(
@@ -191,7 +192,7 @@
return new ResultIterator( iterator_to_array( 
$selectionResult ) );
}
 
-   // TODO: throw
+   throw new SelectFailedException( $tableName, $fields, 
$conditions );
}
 
 }
diff --git a/Database/includes/SelectFailedException.php 
b/Database/includes/SelectFailedException.php
new file mode 100644
index 000..5ead691
--- /dev/null
+++ b/Database/includes/SelectFailedException.php
@@ -0,0 +1,64 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class SelectFailedException extends QueryInterfaceException {
+
+   protected $tableName;
+   protected $fields;
+   protected $conditions;
+
+   public function __construct( $tableName, array $fields, array 
$conditions, $message = '', \Exception $previous = null ) {
+   parent::__construct( $message, 0, $previous );
+
+   $this->tableName = $tableName;
+   $this->conditions = $conditions;
+   $this->fields = $fields;
+   }
+
+   /**
+* @return string
+*/
+   public function getTableName() {
+   return $this->tableName;
+   }
+
+   /**
+* @return array
+*/
+   public function getConditions() {
+   return $this->conditions;
+   }
+
+   /**
+* @return array
+*/
+   public function getFields() {
+   return $this->fields;
+   }
+
+}
\ No newline at end of file
diff --git a/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php 
b/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
index 08c9520..3e7aac4 100644
--- a/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
+++ b/Database/tests/phpunit/MediaWikiQueryInterfaceTest.php
@@ -339,13 +339,17 @@
$extendedAbstraction
);
 
+   $resultWrapper = $this->getMockBuilder( 'ResultWrapper' )
+   ->disableOriginalConstructor()->getMock();
+
$connection->expects( $this->once() )
->method( 'select' )
->with(
$this->equalTo( $tableName ),
$this->equalTo( $fields ),
$this->equalTo( $conditions )
-   );
+   )
+   ->will( $this->returnValue( $resultWrapper ) );
 
$queryInterface->select( $tableName, $fields, $conditions );
 
diff --git a/Database/tests/phpunit/SelectFailedExceptionTest.php 
b/Database/tests/phpunit/SelectFailedExceptionTest.php
new file mode 100644
index 000..52a1462
--- /dev/null
+++ b/Database/tests/phpunit/SelectFailedExceptionTest.php
@@ -0,0 +1,66 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseDatabaseTest
+ *
+ * @group Wikibase
+ * @group WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class SelectFailedExceptionTest extends \PHPUnit_Framework_TestCase {
+
+   public function testConstructorWithOnlyRequiredArguments() {
+   $tableName = 'nyancats';
+   $fields = array( 'bar', 'baz', 'bah' );
+   $conditions = array( 'foo' => 42, 'awesome > 9000' );
+
+   $exception = new SelectFailedException( $tableName, $fields, 
$conditions );
+
+   $this->assertEquals( $tableName, $exception->getTableName() );
+   $this->assertEquals( $fields, $exception->getFields() );
+   $this->assertEquals( $conditions, $exception->getConditions() );
+   }
+
+   public function testConstru

[MediaWiki-commits] [Gerrit] Work on DescriptionMatchFinder - change (mediawiki...Wikibase)

2013-05-17 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Work on DescriptionMatchFinder
..


Work on DescriptionMatchFinder

Change-Id: I0925c4e0df35481fc6e17546536453c32cd1388b
---
M QueryEngine/dependencies.txt
A QueryEngine/includes/QueryEngineException.php
A QueryEngine/includes/QueryNotSupportedException.php
M QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
M QueryEngine/includes/SQLStore/Engine/Engine.php
M QueryEngine/tests/bootstrap.php
A QueryEngine/tests/phpunit/SQLStore/Engine/DescriptionMatchFinderTest.php
7 files changed, 350 insertions(+), 24 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/dependencies.txt b/QueryEngine/dependencies.txt
index dea446b..1676559 100644
--- a/QueryEngine/dependencies.txt
+++ b/QueryEngine/dependencies.txt
@@ -1,8 +1,10 @@
 The Wikibase QueryEngine component is dependent on:
 
-* Wikibase DataModel
-* WikibaseLib
 * DataValues
 * Ask
+* Wikibase DataModel
+* Wikibase Database
 
-And nothing else.
\ No newline at end of file
+And nothing else.
+
+An always up to date list can be found at tests/bootstrap.php.
\ No newline at end of file
diff --git a/QueryEngine/includes/QueryEngineException.php 
b/QueryEngine/includes/QueryEngineException.php
new file mode 100644
index 000..0bd1e6f
--- /dev/null
+++ b/QueryEngine/includes/QueryEngineException.php
@@ -0,0 +1,33 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseQueryStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class QueryEngineException extends \Exception {
+
+}
\ No newline at end of file
diff --git a/QueryEngine/includes/QueryNotSupportedException.php 
b/QueryEngine/includes/QueryNotSupportedException.php
new file mode 100644
index 000..3ff2953
--- /dev/null
+++ b/QueryEngine/includes/QueryNotSupportedException.php
@@ -0,0 +1,48 @@
+http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseQueryStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class QueryNotSupportedException extends QueryEngineException {
+
+   protected $queryDescription;
+
+   public function __construct( Description $queryDescription, $message = 
'', \Exception $previous = null ) {
+   $this->queryDescription = $queryDescription;
+
+   parent::__construct( $message, 0, $previous );
+   }
+
+   /**
+* @return Description
+*/
+   public function getQueryDescription() {
+   return $this->queryDescription;
+   }
+
+}
diff --git a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php 
b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
index 0f0783e..33dd821 100644
--- a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
+++ b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
@@ -1,8 +1,141 @@
 http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup WikibaseSQLStore
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < jeroended...@gmail.com >
+ */
+class DescriptionMatchFinder {
+
+   protected $queryInterface;
+   protected $schema;
+   protected $propertyDataValueTypeLookup;
+   protected $idFinder;
+
+   public function __construct( QueryInterface $queryInterface,
+   Schema $schema,
+   PropertyDataValueTypeLookup 
$propertyDataValueTypeLookup,
+   InternalEntityIdFinder $idFinder ) {
+   $this->queryInterface = $queryInterface;
+   $this->schema = $schema;
+   $this->propertyDataValueTypeLookup = 
$propertyDataValueTypeLookup;
+   $this->idFinder = $idFinder;
+   }
+
+   /**
+* Finds all entities that match the selection criteria.
+* The matching entities are returned as an array of internal entity 
ids.
+*
+* @since 0.1
+*
+* @param Description $description
+* @param QueryOptions $options
+*
+* @return int[]
+*/
+   public function findMatchingEntities( Description $description, 
QueryOptions $options ) {
+   if ( $description instanceof SomeProperty ) {
+   return $this->findMatchingSomeProperty( $description, 
$options );
+   }
+
+   throw new QueryNotSupportedException( $description );
+
+   // SomeProperty[AnyValue]: SELECT entity_id FROM $table WHERE 
property_id = $id
+
+   // SomeProperty[ValueDescription]:
+   // SELECT SELECT entity_id FROM $table WHERE property_id = 
$property_id AND
+   }
+
+   protected function findMatchingSomeProperty( SomeProperty $description, 
QueryOptions $options ) {
+   $p

[MediaWiki-commits] [Gerrit] Have the SnakStores actually insert the subject_id field - change (mediawiki...Wikibase)

2013-05-17 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Have the SnakStores actually insert the subject_id field
..


Have the SnakStores actually insert the subject_id field

Change-Id: Icd922b2ee4958866011cfd704398fd4cf5ba
---
M QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
M QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
4 files changed, 25 insertions(+), 3 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
index 9f47fea..b61c18e 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php
@@ -80,10 +80,21 @@
 */
$dataValueHandler = $this->getDataValueHandler( 
$snakRow->getValue()->getType() );
 
-   $this->queryInterface->insert(
-   
$dataValueHandler->getDataValueTable()->getTableDefinition()->getName(),
+   $tableName = 
$dataValueHandler->getDataValueTable()->getTableDefinition()->getName();
+
+   $insertValues = array_merge(
+   array(
+   'claim_id' => $snakRow->getInternalClaimId(),
+   'property_id' => 
$snakRow->getInternalPropertyId(),
+   'subject_id' => 
$snakRow->getInternalSubjectId(),
+   ),
$dataValueHandler->getInsertValues( 
$snakRow->getValue() )
);
+
+   $this->queryInterface->insert(
+   $tableName,
+   $insertValues
+   );
}
 
 }
diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php 
b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
index d69a115..30f8166 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php
@@ -57,6 +57,7 @@
array(
'claim_id' => $snakRow->getInternalClaimId(),
'property_id' => 
$snakRow->getInternalPropertyId(),
+   'subject_id' => 
$snakRow->getInternalSubjectId(),
'snak_type' => $snakRow->getInternalSnakType(),
'snak_role' => $snakRow->getSnakRole(),
)
diff --git 
a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php 
b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
index b77c455..ae45c95 100644
--- a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
@@ -141,7 +141,16 @@
->method( 'insert' )
->with(
$this->equalTo( 'strings_of_doom' ),
-   $this->equalTo( 
$stringHandler->getInsertValues( $snakRow->getValue() ) )
+   $this->equalTo(
+   array_merge(
+   array(
+   'claim_id' => 
$snakRow->getInternalClaimId(),
+   'property_id' => 
$snakRow->getInternalPropertyId(),
+   'subject_id' => 
$snakRow->getInternalSubjectId(),
+   ),
+   
$stringHandler->getInsertValues( $snakRow->getValue() )
+   )
+   )
);
 
$store = new ValueSnakStore(
diff --git 
a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php 
b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
index 1725443..6a76c4f 100644
--- a/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
@@ -126,6 +126,7 @@
array(
'claim_id' => 
$snakRow->getInternalClaimId(),
'property_id' => 
$snakRow->getInternalPropertyId(),
+   'subject_id' => 
$snakRow->getInternalSubjectId(),
'snak_type' => 
$snakRow->getInternalSnakType(),
 

[MediaWiki-commits] [Gerrit] Insert subject id into snak rows - change (mediawiki...Wikibase)

2013-05-17 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Insert subject id into snak rows
..


Insert subject id into snak rows

Change-Id: If785bea11374eef2bc38d3794ea8f3cb1f910883
---
M QueryEngine/includes/SQLStore/ClaimStore/ClaimInserter.php
M QueryEngine/includes/SQLStore/SnakStore/SnakInserter.php
M QueryEngine/includes/SQLStore/SnakStore/SnakRow.php
M QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php
M QueryEngine/includes/SQLStore/SnakStore/ValueSnakRow.php
M QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakRow.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakInserterTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRowBuilderTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakStoreTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakRowTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValueSnakStoreTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakRowTest.php
M QueryEngine/tests/phpunit/SQLStore/SnakStore/ValuelessSnakStoreTest.php
13 files changed, 74 insertions(+), 41 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/ClaimStore/ClaimInserter.php 
b/QueryEngine/includes/SQLStore/ClaimStore/ClaimInserter.php
index bf2cb3d..b8924fa 100644
--- a/QueryEngine/includes/SQLStore/ClaimStore/ClaimInserter.php
+++ b/QueryEngine/includes/SQLStore/ClaimStore/ClaimInserter.php
@@ -52,7 +52,7 @@
 */
public function insertClaim( Claim $claim, $internalSubjectId ) {
$internalClaimId = $this->insertIntoClaimsTable( $claim, 
$internalSubjectId );
-   $this->insertSnaks( $claim, $internalClaimId );
+   $this->insertSnaks( $claim, $internalClaimId, 
$internalSubjectId );
}
 
protected function insertIntoClaimsTable( Claim $claim, 
$internalSubjectId ) {
@@ -60,16 +60,16 @@
return $this->claimsTable->insertClaimRow( $claimRow );
}
 
-   protected function insertSnaks( Claim $claim, $internalClaimId ) {
-   $this->insertSnak( $claim->getMainSnak(), SnakRole::MAIN_SNAK, 
$internalClaimId );
+   protected function insertSnaks( Claim $claim, $internalClaimId, 
$internalSubjectId ) {
+   $this->insertSnak( $claim->getMainSnak(), SnakRole::MAIN_SNAK, 
$internalClaimId, $internalSubjectId );
 
foreach ( $claim->getQualifiers() as $qualifier ) {
-   $this->insertSnak( $qualifier, SnakRole::QUALIFIER, 
$internalClaimId );
+   $this->insertSnak( $qualifier, SnakRole::QUALIFIER, 
$internalClaimId, $internalSubjectId );
}
}
 
-   protected function insertSnak( Snak $snak, $snakRole, $internalClaimId 
) {
-   $this->snakInserter->insertSnak( $snak, $snakRole, 
$internalClaimId );
+   protected function insertSnak( Snak $snak, $snakRole, $internalClaimId, 
$internalSubjectId ) {
+   $this->snakInserter->insertSnak( $snak, $snakRole, 
$internalClaimId, $internalSubjectId );
}
 
 }
diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakInserter.php 
b/QueryEngine/includes/SQLStore/SnakStore/SnakInserter.php
index 9c6c92b..ff01ed4 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/SnakInserter.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/SnakInserter.php
@@ -54,9 +54,10 @@
 * @param Snak $snak
 * @param int $snakRole
 * @param int $internalClaimId
+* @param int $internalSubjectId
 */
-   public function insertSnak( Snak $snak, $snakRole, $internalClaimId ) {
-   $snakRow = $this->snakRowBuilder->newSnakRow( $snak, $snakRole, 
$internalClaimId );
+   public function insertSnak( Snak $snak, $snakRole, $internalClaimId, 
$internalSubjectId ) {
+   $snakRow = $this->snakRowBuilder->newSnakRow( $snak, $snakRole, 
$internalClaimId, $internalSubjectId );
$this->insertSnakRow( $snakRow );
}
 
diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakRow.php 
b/QueryEngine/includes/SQLStore/SnakStore/SnakRow.php
index 6f3ca26..6ffafde 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/SnakRow.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/SnakRow.php
@@ -33,16 +33,19 @@
protected $internalPropertyId;
protected $internalClaimId;
protected $snakRole;
+   protected $internalSubjectId;
 
/**
 * @param int $internalPropertyId
 * @param int $internalClaimId
 * @param int $snakRole
+* @param int $internalSubjectId
 */
-   public function __construct( $internalPropertyId, $internalClaimId, 
$snakRole ) {
+   public function __construct( $internalPropertyId, $internalClaimId, 
$snakRole, $internalSubjectId ) {
$this->internalPropertyId = $internalProper

[MediaWiki-commits] [Gerrit] move ob_start in special entity data - change (mediawiki...Wikibase)

2013-05-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: move ob_start in special entity data
..


move ob_start in special entity data

Change-Id: Id7fad01b59ec0c3a8d2cc945911ca388b1358032
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Verified; Looks good to me, approved



diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index d5c4563..0a80327 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -84,8 +84,6 @@
 * @param string|null $subPage
 */
public function execute( $subPage ) {
-   ob_start();
-
$revision = 0;
$format = 'json';
 
@@ -121,6 +119,8 @@
$this->dataTypeFactory = $repo->getDataTypeFactory();
$this->idFormatter = $repo->getIdFormatter();
 
+   ob_start();
+
$this->showData( $format, $id, $revision );
 
ob_end_flush();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id7fad01b59ec0c3a8d2cc945911ca388b1358032
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf4
Gerrit-Owner: Aude 
Gerrit-Reviewer: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] add ob start and end flush to SpecialEntityData - change (mediawiki...Wikibase)

2013-05-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: add ob start and end flush to SpecialEntityData
..


add ob start and end flush to SpecialEntityData

Change-Id: Ie9df597841f49f06322d13606af853def56ca68b
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 5 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Verified; Looks good to me, approved



diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index fa0a084..d5c4563 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -21,7 +21,7 @@
  *
  * @since 0.4
  *
- * @file 
+ * @file
  * @ingroup WikibaseRepo
  *
  * @licence GNU GPL v2+
@@ -84,6 +84,8 @@
 * @param string|null $subPage
 */
public function execute( $subPage ) {
+   ob_start();
+
$revision = 0;
$format = 'json';
 
@@ -120,6 +122,8 @@
$this->idFormatter = $repo->getIdFormatter();
 
$this->showData( $format, $id, $revision );
+
+   ob_end_flush();
}
 
/**
@@ -448,7 +452,6 @@
ob_clean();
 
print $data;
-   flush();
 
//die(); //FIXME: figure out how to best shut down here.
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie9df597841f49f06322d13606af853def56ca68b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf4
Gerrit-Owner: Aude 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] black magic around flushes and output buffers - change (mediawiki...Wikibase)

2013-05-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: black magic around flushes and output buffers
..

black magic around flushes and output buffers

Change-Id: I6891da8fb62ed9fcf54f0867806e227131f3a7a3
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 4 insertions(+), 3 deletions(-)


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

diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index fa0a084..cb08a59 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -420,6 +420,9 @@
$request = $this->getRequest();
$response = $request->response();
 
+   $this->getOutput()->disable(); // don't generate HTML
+   ob_start();
+
$maxage = $request->getInt( 'maxage', $wgSquidMaxage );
$smaxage = $request->getInt( 'smaxage', $wgSquidMaxage );
 
@@ -444,10 +447,8 @@
$mode = 'public';
$response->header( 'Cache-Control: ' . $mode . ', s-maxage=' . 
$smaxage . ', max-age=' . $maxage );
 
-   $this->getOutput()->disable(); // don't generate HTML
-   ob_clean();
-
print $data;
+   ob_flush();
flush();
 
//die(); //FIXME: figure out how to best shut down here.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6891da8fb62ed9fcf54f0867806e227131f3a7a3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic 

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


[MediaWiki-commits] [Gerrit] first draft of the RDF dump creating script (DO NOT MERGE) - change (mediawiki...Wikibase)

2013-05-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has uploaded a new change for review.

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


Change subject: first draft of the RDF dump creating script (DO NOT MERGE)
..

first draft of the RDF dump creating script (DO NOT MERGE)

Change-Id: I0a5122078772171c8f0b786953d11fbd458daef7
---
A repo/maintenance/transformXMLtoRDF.php
1 file changed, 200 insertions(+), 0 deletions(-)


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

diff --git a/repo/maintenance/transformXMLtoRDF.php 
b/repo/maintenance/transformXMLtoRDF.php
new file mode 100644
index 000..7fd0947
--- /dev/null
+++ b/repo/maintenance/transformXMLtoRDF.php
@@ -0,0 +1,200 @@
+
+ * http://www.mediawiki.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.4
+ *
+ * @file
+ * @ingroup WikibaseRepo
+ *
+ * @licence GNU GPL v2+
+ * @author Denny Vrandecic < vrande...@gmail.com >
+ */
+
+$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' 
) : __DIR__ . '/../../../..';
+
+require_once $basePath . '/maintenance/Maintenance.php';
+require_once $basePath . '/includes/Exception.php';
+
+/**
+ * Maintenance script that transforms the XML dump into an RDF dump.
+ *
+ * @ingroup WikibaseRepo
+ */
+class transformXMLtoRDF extends Maintenance {
+   public $reportingInterval = 1000;
+   public $pageCount = 0;
+   public $revCount = 0;
+   public $propertyTypes = array();
+
+   function __construct() {
+   parent::__construct();
+   $gz = in_array( 'compress.zlib', stream_get_wrappers() ) ? 'ok' 
: '(disabled; requires PHP zlib module)';
+   $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() ) ? 
'ok' : '(disabled; requires PHP bzip2 module)';
+
+   $this->mDescription = <addOption( 'report',
+   'Report position and speed after every n entities 
processed', false, true );
+   $this->addOption( 'types',
+   'file containing lines each with a space-separated 
tuple of property ID and type',
+   true, true );
+   $this->addOption( 'output', 'name of the output RDF/XML file', 
false, true );
+   $this->addOption( 'debug', 'Output extra verbose debug 
information' );
+   $this->addArg( 'file', 'Dump file to transform [else use 
stdin]', false );
+   }
+
+   public function execute() {
+   $this->reportingInterval = intval( $this->getOption( 'report', 
1000 ) );
+   if ( !$this->reportingInterval ) {
+   $this->reportingInterval = 1000; // avoid division by 
zero
+   }
+
+   if ( $this->hasArg() ) {
+   $this->importFromFile( $this->getArg() );
+   } else {
+   $this->importFromStdin();
+   }
+
+   $this->output( "Done!\n" );
+   }
+
+   function reportPage( $page ) {
+   $this->pageCount++;
+   }
+
+   /**
+* @param $rev Revision
+* @return mixed
+*/
+   function handleRevision( WikiRevision $rev ) {
+   $title = $rev->getTitle();
+   if ( !$title ) {
+   $this->progress( "Got bogus revision with null title!" 
);
+   return;
+   }
+   $item = ( $rev->getModel() === CONTENT_MODEL_WIKIBASE_ITEM );
+   $property = ( $rev->getModel() === 
CONTENT_MODEL_WIKIBASE_PROPERTY );
+   $entity = $item OR $property;
+
+   if ( $rev->getModel() !== 'wikibase-item' ) {
+   if ( $rev->getModel() !== 'wikitext' ) {
+   if ( $rev->getModel() !== 'javascript' ) {
+   if ( $rev->getModel() !== 'css' ) {
+   $this->progress( 
$rev->getModel() );
+   }
+   }
+   }
+   }
+
+   if ( $entity ) {
+

[MediaWiki-commits] [Gerrit] Add subject_id field to all property snak tables - change (mediawiki...Wikibase)

2013-05-16 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Add subject_id field to all property snak tables
..


Add subject_id field to all property snak tables

Change-Id: I1fcd89ad6430cbe43a9069f4ffbecbbeb7a15587
---
M QueryEngine/includes/SQLStore/Schema.php
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/QueryEngine/includes/SQLStore/Schema.php 
b/QueryEngine/includes/SQLStore/Schema.php
index 9364b7f..52376d8 100644
--- a/QueryEngine/includes/SQLStore/Schema.php
+++ b/QueryEngine/includes/SQLStore/Schema.php
@@ -204,7 +204,17 @@
FieldDefinition::NOT_NULL,
FieldDefinition::NO_DEFAULT,
FieldDefinition::ATTRIB_UNSIGNED,
-   FieldDefinition::INDEX
+   FieldDefinition::NO_INDEX
+   ),
+
+   // Internal subject id
+   new FieldDefinition(
+   'subject_id',
+   FieldDefinition::TYPE_INTEGER,
+   FieldDefinition::NOT_NULL,
+   FieldDefinition::NO_DEFAULT,
+   FieldDefinition::ATTRIB_UNSIGNED,
+   FieldDefinition::NO_INDEX
),
 
// Internal property id

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1fcd89ad6430cbe43a9069f4ffbecbbeb7a15587
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw 
Gerrit-Reviewer: Denny Vrandecic 
Gerrit-Reviewer: jenkins-bot

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


  1   2   >