WikidataBuilder has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/386596 )
Change subject: New Wikidata Build - 2017-10-26T10:00:01+0000 ...................................................................... New Wikidata Build - 2017-10-26T10:00:01+0000 Change-Id: I74c3f354260d86624f2120f3d1ae8ed3dca67989 --- M composer.lock M extensions/Constraints/i18n/he.json M extensions/Wikibase/client/i18n/tg-cyrl.json M extensions/Wikibase/docs/options.wiki M extensions/Wikibase/repo/Wikibase.hooks.php M extensions/Wikibase/repo/Wikibase.php M extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php M extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php M extensions/Wikibase/repo/config/Wikibase.default.php M extensions/Wikibase/repo/i18n/ja.json M extensions/Wikibase/repo/i18n/tr.json M extensions/Wikibase/repo/includes/Search/Elastic/ElasticTermResult.php M extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php A extensions/Wikibase/repo/includes/Search/Elastic/StatementBoostScoreBuilder.php M extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php M extensions/Wikibase/repo/includes/WikibaseRepo.php M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected M extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected A extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.expected A extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.query M extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/ElasticTermResultTest.php A extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/StatementBoostScoreBuilderTest.php A extensions/Wikidata.org/i18n/tr.json M vendor/composer/autoload_classmap.php M vendor/composer/autoload_static.php M vendor/composer/installed.json D vendor/data-values/serialization/.gitignore D vendor/data-values/serialization/.scrutinizer.yml D vendor/data-values/serialization/.travis.yml M vendor/data-values/serialization/README.md D vendor/data-values/serialization/composer.json D vendor/data-values/serialization/phpcs.xml D vendor/data-values/serialization/phpunit.xml.dist M vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php D vendor/data-values/serialization/tests/Deserializers/DataValueDeserializerTest.php D vendor/data-values/serialization/tests/Serializers/DataValueSerializerTest.php D vendor/data-values/serialization/tests/bootstrap.php 40 files changed, 468 insertions(+), 552 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata refs/changes/96/386596/1 diff --git a/composer.lock b/composer.lock index 84117d4..c03e2d9 100644 --- a/composer.lock +++ b/composer.lock @@ -534,26 +534,26 @@ }, { "name": "data-values/serialization", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/DataValues/Serialization.git", - "reference": "2e81e60e413f1578fbaddb9dd2fbcc8236825806" + "reference": "d849fc1a2f00f22027d504c4e70fd00a0c6a7579" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DataValues/Serialization/zipball/2e81e60e413f1578fbaddb9dd2fbcc8236825806", - "reference": "2e81e60e413f1578fbaddb9dd2fbcc8236825806", + "url": "https://api.github.com/repos/DataValues/Serialization/zipball/d849fc1a2f00f22027d504c4e70fd00a0c6a7579", + "reference": "d849fc1a2f00f22027d504c4e70fd00a0c6a7579", "shasum": "" }, "require": { "data-values/data-values": "~1.0|~0.1", "php": ">=5.5.9", - "serialization/serialization": "~3.0" + "serialization/serialization": "~4.0|~3.0" }, "require-dev": { - "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8", - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "~4.8", + "wikibase/wikibase-codesniffer": "^0.2.0" }, "type": "library", "extra": { @@ -588,7 +588,7 @@ "serializers", "wikidata" ], - "time": "2017-06-26 07:24:35" + "time": "2017-10-25 13:47:05" }, { "name": "data-values/time", @@ -918,7 +918,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikidata.org", - "reference": "764890c0924f0a011b585f70d6e72200212af543" + "reference": "f2def2a8a4ead8b7e44bce63a9af883cb89f99ff" }, "require": { "php": ">=5.5.9" @@ -963,7 +963,7 @@ "support": { "irc": "irc://irc.freenode.net/wikidata" }, - "time": "2017-10-15 18:02:13" + "time": "2017-10-25 21:08:35" }, { "name": "wikibase/constraints", @@ -971,7 +971,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", - "reference": "2dd73c81b063b40981eee40d6aa5ba47bae6cc42" + "reference": "598671433d7c5d8cef818c6eff957a5eb00e0040" }, "require": { "php": ">=5.5.9", @@ -1031,7 +1031,7 @@ "support": { "issues": "https://phabricator.wikimedia.org/project/profile/1202/" }, - "time": "2017-10-25 06:24:26" + "time": "2017-10-25 21:08:09" }, { "name": "wikibase/data-model", @@ -1542,12 +1542,12 @@ "source": { "type": "git", "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", - "reference": "932e03cf5d1b63a76373a8daf9795bf066af08bd" + "reference": "84f5795908c00f3c37072b02aa025c782083bda3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/932e03cf5d1b63a76373a8daf9795bf066af08bd", - "reference": "932e03cf5d1b63a76373a8daf9795bf066af08bd", + "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/84f5795908c00f3c37072b02aa025c782083bda3", + "reference": "84f5795908c00f3c37072b02aa025c782083bda3", "shasum": "" }, "require": { @@ -1626,7 +1626,7 @@ "wikibaserepo", "wikidata" ], - "time": "2017-10-24 15:12:58" + "time": "2017-10-26 07:53:28" }, { "name": "wikibase/wikimedia-badges", diff --git a/extensions/Constraints/i18n/he.json b/extensions/Constraints/i18n/he.json index 420ea16..c5fb0c7 100644 --- a/extensions/Constraints/i18n/he.json +++ b/extensions/Constraints/i18n/he.json @@ -93,6 +93,7 @@ "wbqc-violation-message-no-qualifiers": "לקביעות $1 לא אמורים להיות מבחינים.", "wbqc-violation-message-qualifiers": "$2 אינו מבחין תקין עבור $1 – {{PLURAL:$3|1=המבחין התקין היחיד. הוא $5|2=המבחינים התקינים היחידים הם $5 ו{{GRAMMAR:תחילית|$6}}|המבחינים התקינים היחידים הם:$4}}", "wbqc-violation-message-range-parameters-needed": "למאפיינים עם ערכים מסוג \"$1\" עם האילוץ \"$4\" צריכים להיות הפרמטרים \"$2\" ו־\"$3\".", + "wbqc-violation-message-range-parameters-one-year": "שתי נקודות קצה של טווח יחידת־זמן צריכות להיות עם היחידה \"year\" או לא להיות עם היחידה הזאת, כי לא ניתן להמיר שנים לשניות ללא אובדן מידע.", "wbqc-violation-message-range-quantity-closed": "הערך עבור $1 (כעת: $2) אמור להיות בין $3 לבין $4 ([$3; $4]).", "wbqc-violation-message-range-quantity-leftopen": "הערך עבור $1 (כעת: $2) אמור להיות לא פחות מ־$3 ((−∞; $3]).", "wbqc-violation-message-range-quantity-rightopen": "הערך עבור $1 (כעת: $2) אמור להיות לא יותר מ־$3 ([$3; ∞)).", @@ -109,5 +110,6 @@ "wbqc-violation-message-target-required-claim": "ל{{GRAMMAR:תחילית|$1}} אמורה להיות {{PLURAL:$3|0=קביעה $2.|1=קביעה $2 $5.הקביעה עבור $2 עם אחד מהערכים הבאים: $4}}", "wbqc-violation-message-unique-value": "ערך המאפיין הזה צריך לא להיות נוכח בשום פריט אחר, אבל הוא נוכח{{PLURAL:$1|1=ב{{GRAMMAR:תחילית|$3}}.|2=ב{{GRAMMAR:תחילית|$3}} וב{{GRAMMAR:תחילית|$4}}|בפריטים הבאים: $2}}", "wbqc-violation-message-valueOnly": "המאפיין הזה צריך לשמש רק הערך הראשי של הקביעה, ולא עבור מבחינים או מקורות.", + "wbqc-violation-message-reference": "המאפיין אמור לשמש רק במקורות, לא עבור הערך הראשי של הקביעה או עבור מבחין.", "wbqc-exception-message": "הישות הזאת היא חריגה ידועה עבור האילוץ הזה והיא סומנה בתור כזאת." } diff --git a/extensions/Wikibase/client/i18n/tg-cyrl.json b/extensions/Wikibase/client/i18n/tg-cyrl.json index bcc25d6..64a3415 100644 --- a/extensions/Wikibase/client/i18n/tg-cyrl.json +++ b/extensions/Wikibase/client/i18n/tg-cyrl.json @@ -2,7 +2,8 @@ "@metadata": { "authors": [ "Ibrahim", - "ToJack" + "ToJack", + "Vashgird" ] }, "wikibase-comment-update": "Элементи {{WBREPONAME}} тағийр ёфт", @@ -16,7 +17,7 @@ "wikibase-rc-hide-wikidata": "$1 {{WBREPONAME}}", "wikibase-rc-hide-wikidata-hide": "Пинҳон кардани", "wikibase-rc-hide-wikidata-show": "Намоиш", - "wikibase-rc-wikibase-edit-title": "{{WBREPONAME}} вироиш", + "wikibase-rc-wikibase-edit-title": "вироиши {{WBREPONAME}}", "wikibase-pageinfo-entity-usage-C": "Тасдиқ: $1", "wikibase-otherprojects": "Дигар лоиҳаҳо" } diff --git a/extensions/Wikibase/docs/options.wiki b/extensions/Wikibase/docs/options.wiki index 47dc767..0f18e7b 100644 --- a/extensions/Wikibase/docs/options.wiki +++ b/extensions/Wikibase/docs/options.wiki @@ -68,6 +68,7 @@ :;prefixSearchProfiles: Loaded from <code>config/EntityPrefixSearchProfiles.php</code>, does not need to be defined manually. (Cirrus) :;defaultPrefixRescoreProfile: name of the rescoring profile to use for prefix search. The profile should be defined in <code>config/ElasticSearchRescoreProfiles.php</code>. (Cirrus) :;rescoreProfiles: Loaded from <code>config/ElasticSearchRescoreProfiles.php</code>, does not have to be defined manually. (Cirrus). +:;statementBoost: Configuration to boost or deboost certain statement values (Cirrus). ;searchIndexProperties: Array of properties (by ID string) that should be included in the "statement_keywords" field of the search index. For now, only relevant when Cirrus search is enabled. == Client Settings == diff --git a/extensions/Wikibase/repo/Wikibase.hooks.php b/extensions/Wikibase/repo/Wikibase.hooks.php index 253486e..dd41057 100644 --- a/extensions/Wikibase/repo/Wikibase.hooks.php +++ b/extensions/Wikibase/repo/Wikibase.hooks.php @@ -6,6 +6,8 @@ use ApiEditPage; use ApiQuerySiteinfo; use BaseTemplate; +use CirrusSearch\Search\FunctionScoreBuilder; +use CirrusSearch\Search\SearchContext; use Content; use ContentHandler; use ExtensionRegistry; @@ -36,6 +38,7 @@ use Wikibase\Repo\Hooks\InfoActionHookHandler; use Wikibase\Repo\Hooks\OutputPageEntityIdReader; use Wikibase\Repo\Search\Elastic\Fields\StatementsField; +use Wikibase\Repo\Search\Elastic\StatementBoostScoreBuilder; use Wikibase\Repo\WikibaseRepo; use Wikibase\Store\Sql\SqlSubscriptionLookup; use WikiPage; @@ -1016,4 +1019,26 @@ ]; } + /** + * Wikibase-specific rescore builders for CirrusSearch. + * + * @param array $func Builder parameters + * @param SearchContext $context + * @param FunctionScoreBuilder|null &$builder Output parameter for score builder. + */ + public static function onCirrusSearchScoreBuilder( + array $func, + SearchContext $context, + FunctionScoreBuilder &$builder = null + ) { + if ( $func['type'] === 'statement_boost' ) { + $searchSettings = WikibaseRepo::getDefaultInstance()->getSettings()->getSetting( 'entitySearch' ); + $builder = new StatementBoostScoreBuilder( + $context, + $func['weight'], + $searchSettings['statementBoost'] + ); + } + } + } diff --git a/extensions/Wikibase/repo/Wikibase.php b/extensions/Wikibase/repo/Wikibase.php index 82fa168..a5db1cc 100644 --- a/extensions/Wikibase/repo/Wikibase.php +++ b/extensions/Wikibase/repo/Wikibase.php @@ -1004,6 +1004,7 @@ $wgHooks['InfoAction'][] = '\Wikibase\RepoHooks::onInfoAction'; $wgHooks['BeforePageDisplayMobile'][] = '\Wikibase\RepoHooks::onBeforePageDisplayMobile'; $wgHooks['CirrusSearchAnalysisConfig'][] = '\Wikibase\RepoHooks::onCirrusSearchAnalysisConfig'; + $wgHooks['CirrusSearchScoreBuilder'][] = '\Wikibase\RepoHooks::onCirrusSearchScoreBuilder'; // update hooks $wgHooks['LoadExtensionSchemaUpdates'][] = '\Wikibase\Repo\Store\Sql\ChangesSubscriptionSchemaUpdater::onSchemaUpdate'; diff --git a/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php b/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php index 895d02f..f6f4ee0 100644 --- a/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php +++ b/extensions/Wikibase/repo/config/ElasticSearchRescoreFunctions.php @@ -22,4 +22,26 @@ ], ], ], + 'entity_weight_boost' => [ + 'score_mode' => 'sum', + 'functions' => [ + [ + // Incoming links: k = 50 + 'type' => 'satu', + 'weight' => '0.6', + 'params' => [ 'field' => 'incoming_links', 'missing' => 0, 'a' => 2 , 'k' => 50 ] + ], + [ + // Site links: k = 20 + 'type' => 'satu', + 'weight' => '0.4', + 'params' => [ 'field' => 'sitelink_count', 'missing' => 0, 'a' => 2, 'k' => 20 ] + ], + [ + // (De)boosting by statement values + 'type' => 'statement_boost', + 'weight' => '0.1', + ] + ], + ], ]; diff --git a/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php b/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php index e863b4a..07a62cf 100644 --- a/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php +++ b/extensions/Wikibase/repo/config/ElasticSearchRescoreProfiles.php @@ -20,4 +20,20 @@ ], ] ], + // Profile that uses both entity weight end statement-based boosts + 'wikibase_prefix_boost' => [ + 'i18n_msg' => 'wikibase-rescore-profile-prefix', + 'supported_namespaces' => 'all', + 'rescore' => [ + [ + 'window' => 8192, + 'window_size_override' => 'EntitySearchRescoreWindowSize', + 'query_weight' => 1.0, + 'rescore_query_weight' => 1.0, + 'score_mode' => 'total', + 'type' => 'function_score', + 'function_chain' => 'entity_weight_boost' + ], + ] + ], ]; diff --git a/extensions/Wikibase/repo/config/Wikibase.default.php b/extensions/Wikibase/repo/config/Wikibase.default.php index d2a15f6..a009366 100644 --- a/extensions/Wikibase/repo/config/Wikibase.default.php +++ b/extensions/Wikibase/repo/config/Wikibase.default.php @@ -255,6 +255,8 @@ 'defaultPrefixRescoreProfile' => 'wikibase_prefix', // Rescore profiles, loaded by Wikibase.php 'rescoreProfiles' => [], + // Type (de)boosts for rescoring functions + 'statementBoost' => [], ], // List of properties to be indexed diff --git a/extensions/Wikibase/repo/i18n/ja.json b/extensions/Wikibase/repo/i18n/ja.json index 86e4694..64cd505 100644 --- a/extensions/Wikibase/repo/i18n/ja.json +++ b/extensions/Wikibase/repo/i18n/ja.json @@ -41,7 +41,7 @@ "wikibase-statementlistview-add-tooltip": "新しい値を追加", "wikibase-statementgrouplistview-add": "追加", "wikibase-statementgrouplistview-add-tooltip": "新しい文を追加", - "wikibase-entitytermsview-entitytermsforlanguagelistview-toggler": "その他の言語", + "wikibase-entitytermsview-entitytermsforlanguagelistview-toggler": "他言語の表示", "wikibase-entitytermsview-entitytermsforlanguagelistview-configure-link-label": "設定", "wikibase-setting-entitytermsview-showEntitytermslistview": "ページ読み込み時に自分のすべての言語でラベル、別名、説明を表示する", "wikibase-setting-entitytermsview-showEntitytermslistview-help": "利用者のインターフェイス言語以外の言語も、利用者ページの[[mw:Extension:Babel|Babel 拡張機能]]構文を使って設定することができます。", @@ -50,7 +50,7 @@ "wikibase-entitytermsforlanguagelistview-label": "ラベル", "wikibase-entitytermsforlanguagelistview-language": "言語", "wikibase-entitytermsforlanguagelistview-more": "入力済みの全言語", - "wikibase-entitytermsforlanguagelistview-less": "他数種の言語", + "wikibase-entitytermsforlanguagelistview-less": "表示を減らす", "wikibase-label-empty": "ラベルは設定されていません", "wikibase-label-edit-placeholder": "ラベルを入力", "wikibase-label-edit-placeholder-language-aware": "$1でのラベル名を設定してください", @@ -59,7 +59,7 @@ "wikibase-description-edit-placeholder-language-aware": "説明を$1で入力してください", "wikibase-aliases-edit-placeholder": "いくつかの別名を入力", "wikibase-aliases-edit-placeholder-language-aware": "別名をいくつか$1で入力してください", - "wikibase-aliases-edit-label": "別名(複数ある場合、縦線|で区切り):", + "wikibase-aliases-edit-label": "別名(複数ある場合、縦線<code>|</code>で区切り):", "wikibase-content-language-edit-label": "言語:", "wikibase-content-language-edit-not-recognized-language": "入力された言語コードが認識できません。", "wikibase-diffview-reference": "情報源", @@ -200,6 +200,7 @@ "wikibase-setaliases-label": "別名:", "wikibase-setaliases-submit": "別名を設定", "special-setlabeldescriptionaliases": "ラベル、説明、別名の設定", + "wikibase-setlabeldescriptionaliases-introfull": "$2で[[$1]]にラベル、説明、別名を設定しようとしています。別名が複数ある場合は縦線<code>|</code>で区切ってください。", "wikibase-setlabeldescriptionaliases-label-label": "ラベル:", "wikibase-setlabeldescriptionaliases-description-label": "説明:", "wikibase-setlabeldescriptionaliases-aliases-label": "別名:", diff --git a/extensions/Wikibase/repo/i18n/tr.json b/extensions/Wikibase/repo/i18n/tr.json index c6e8c5e..0abdfe5 100644 --- a/extensions/Wikibase/repo/i18n/tr.json +++ b/extensions/Wikibase/repo/i18n/tr.json @@ -197,6 +197,7 @@ "wikibase-listdatatypes-string-head": "Dize", "wikibase-listdatatypes-time-head": "Zaman", "wikibase-listdatatypes-url-head": "URL", + "wikibase-listdatatypes-external-id-head": "Dış tanımlayıcı", "datatypes-type-url": "URL", "content-model-wikibase-property": "Wikibase özelliği", "content-model-wikibase-query": "Wikibase sorgu", diff --git a/extensions/Wikibase/repo/includes/Search/Elastic/ElasticTermResult.php b/extensions/Wikibase/repo/includes/Search/Elastic/ElasticTermResult.php index c0c379c..1f40d84 100644 --- a/extensions/Wikibase/repo/includes/Search/Elastic/ElasticTermResult.php +++ b/extensions/Wikibase/repo/includes/Search/Elastic/ElasticTermResult.php @@ -13,6 +13,9 @@ /** * This result type implements the result for searching * a Wikibase entity by its label or alias. + * + * @license GPL-2.0+ + * @author Stas Malyshev */ class ElasticTermResult implements ResultsType { diff --git a/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php b/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php index 5e94101..9dd9755 100644 --- a/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php +++ b/extensions/Wikibase/repo/includes/Search/Elastic/EntitySearchElastic.php @@ -19,6 +19,9 @@ /** * Entity search implementation using ElasticSearch. * Requires CirrusSearch extension and $wgEntitySearchUseCirrus to be on. + * + * @license GPL-2.0+ + * @author Stas Malyshev */ class EntitySearchElastic implements EntitySearchHelper { @@ -187,7 +190,9 @@ $labelsQuery = new BoolQuery(); $labelsQuery->addFilter( $labelsFilter ); $labelsQuery->addMust( $dismax ); - $titleMatch = new Term( [ 'title.keyword' => $text ] ); + // TODO: this is a bit hacky, better way would be to make the field case-insensitive + // or add new subfiled which is case-insensitive + $titleMatch = new Term( [ 'title.keyword' => strtoupper( $text ) ] ); // Match either labels or exact match to title $query->addShould( $labelsQuery ); diff --git a/extensions/Wikibase/repo/includes/Search/Elastic/StatementBoostScoreBuilder.php b/extensions/Wikibase/repo/includes/Search/Elastic/StatementBoostScoreBuilder.php new file mode 100644 index 0000000..965a08d --- /dev/null +++ b/extensions/Wikibase/repo/includes/Search/Elastic/StatementBoostScoreBuilder.php @@ -0,0 +1,47 @@ +<?php + +namespace Wikibase\Repo\Search\Elastic; + +use CirrusSearch\Search\FunctionScoreBuilder; +use CirrusSearch\Search\SearchContext; +use CirrusSearch\Search\TermBoostScoreBuilder; +use Elastica\Query\FunctionScore; + +/** + * Boost function implementation for statement values. + * + * @license GPL-2.0+ + * @author Stas Malyshev + */ +class StatementBoostScoreBuilder extends FunctionScoreBuilder { + + /** + * @var TermBoostScoreBuilder + */ + private $termBuilder; + + /** + * @param SearchContext $context + * @param float $weight + * @param array $settings Boost settings: [ 'P31=Q123' => SCORE, ... ] + */ + public function __construct( SearchContext $context, $weight, array $settings ) { + parent::__construct( $context, $weight ); + + $this->termBuilder = new TermBoostScoreBuilder( + $context, + $weight, + [ 'statement_keywords' => $settings ] + ); + } + + /** + * Append functions to the function score $container + * + * @param FunctionScore $container + */ + public function append( FunctionScore $container ) { + $this->termBuilder->append( $container ); + } + +} diff --git a/extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php b/extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php index fdfde3c..bb1b685 100644 --- a/extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php +++ b/extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php @@ -3,7 +3,6 @@ namespace Wikibase\Repo\Search\Elastic; use CirrusSearch\Connection; -use CirrusSearch\Search\RescoreBuilder; use CirrusSearch\Searcher; use Elastica\Query; use Elastica\Query\AbstractQuery; @@ -13,6 +12,9 @@ /** * Searcher class for performing Wikibase prefix search. * @see \CirrusSearch\Searcher + * + * @license GPL-2.0+ + * @author Stas Malyshev */ class WikibasePrefixSearcher extends Searcher { /** @@ -76,8 +78,7 @@ * @param array|string $profile */ public function setRescoreProfile( $profile ) { - $rescore = new RescoreBuilder( $this->getSearchContext(), $profile ); - $this->getSearchContext()->mergeRescore( $rescore->build() ); + $this->getSearchContext()->setRescoreProfile( $profile ); } /** diff --git a/extensions/Wikibase/repo/includes/WikibaseRepo.php b/extensions/Wikibase/repo/includes/WikibaseRepo.php index 326f65c..2b3b881 100644 --- a/extensions/Wikibase/repo/includes/WikibaseRepo.php +++ b/extensions/Wikibase/repo/includes/WikibaseRepo.php @@ -289,11 +289,6 @@ private $entityRdfBuilderFactory = null; /** - * @var EntityDiffVisualizerFactory|null - */ - private $entityDiffVisualizerFactory; - - /** * IMPORTANT: Use only when it is not feasible to inject an instance properly. * * @throws MWException diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected index 48d79ef..4a28724 100644 --- a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch-en.expected @@ -129,7 +129,7 @@ }, { "term": { - "title.keyword": "Wien" + "title.keyword": "WIEN" } } ], diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected index 48ef5ea..81b6ba1 100644 --- a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch.expected @@ -129,7 +129,7 @@ }, { "term": { - "title.keyword": "Wien" + "title.keyword": "WIEN" } } ], diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected index bc3b388..2163aca 100644 --- a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_de-ch_strict.expected @@ -59,7 +59,7 @@ }, { "term": { - "title.keyword": "Wien" + "title.keyword": "WIEN" } } ], diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected index 857c6bf..e745659 100644 --- a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en.expected @@ -69,7 +69,7 @@ }, { "term": { - "title.keyword": "Duck" + "title.keyword": "DUCK" } } ], diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected index c6a9848..939a7d7 100644 --- a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_en_strict.expected @@ -59,7 +59,7 @@ }, { "term": { - "title.keyword": "Duck" + "title.keyword": "DUCK" } } ], diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.expected b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.expected new file mode 100644 index 0000000..5cab8fb --- /dev/null +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.expected @@ -0,0 +1,172 @@ +{ + "description": "wikibase_prefix search for 'q42'", + "params": { + "timeout": "20s" + }, + "query": { + "query": { + "bool": { + "should": [ + { + "bool": { + "filter": [ + { + "match": { + "labels_all.prefix": "q42" + } + } + ], + "must": [ + { + "dis_max": { + "tie_breaker": 0, + "queries": [ + { + "constant_score": { + "filter": { + "match": { + "labels.en.near_match": "q42" + } + }, + "boost": 2 + } + }, + { + "constant_score": { + "filter": { + "match": { + "labels.en.near_match_folded": "q42" + } + }, + "boost": 1.8 + } + }, + { + "constant_score": { + "filter": { + "match": { + "labels.en.prefix": "q42" + } + }, + "boost": 1.1 + } + }, + { + "constant_score": { + "filter": { + "match": { + "labels_all.near_match_folded": "q42" + } + }, + "boost": 0.001 + } + } + ] + } + } + ] + } + }, + { + "term": { + "title.keyword": "Q42" + } + } + ], + "minimum_should_match": 1, + "filter": [ + { + "term": { + "content_model": "wikibase-item" + } + } + ] + } + }, + "_source": [ + "namespace", + "title", + "labels.en", + "descriptions.en" + ], + "stored_fields": [], + "highlight": { + "pre_tags": [ + "" + ], + "post_tags": [ + "" + ], + "fields": { + "title": { + "type": "experimental", + "fragmenter": "none", + "number_of_fragments": 0, + "matched_fields": [ + "title.keyword" + ] + }, + "labels.en.prefix": { + "type": "experimental", + "fragmenter": "none", + "number_of_fragments": 0, + "options": { + "skip_if_last_matched": true, + "return_snippets_and_offsets": true + } + }, + "labels.*.prefix": { + "type": "experimental", + "fragmenter": "none", + "number_of_fragments": 0, + "options": { + "skip_if_last_matched": true, + "return_snippets_and_offsets": true + } + } + } + }, + "size": 10, + "rescore": [ + { + "window_size": 8192, + "query": { + "query_weight": 1, + "rescore_query_weight": 1, + "score_mode": "total", + "rescore_query": { + "function_score": { + "score_mode": "sum", + "functions": [ + { + "script_score": { + "script": { + "inline": "pow(doc['incoming_links'].value , 2) \/ ( pow(doc['incoming_links'].value, 2) + pow(50,2))", + "lang": "expression" + } + }, + "weight": 0.6 + }, + { + "script_score": { + "script": { + "inline": "pow(doc['sitelink_count'].value , 2) \/ ( pow(doc['sitelink_count'].value, 2) + pow(20,2))", + "lang": "expression" + } + }, + "weight": 0.4 + } + ] + } + } + } + } + ], + "stats": [ + "wikibase-prefix" + ] + }, + "options": { + "timeout": "20s" + } +} \ No newline at end of file diff --git a/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.query b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.query new file mode 100644 index 0000000..b9dac8b --- /dev/null +++ b/extensions/Wikibase/repo/tests/phpunit/data/entitySearch/search_id.query @@ -0,0 +1,7 @@ +{ + "search": "q42", + "language": "en", + "userLang": "en", + "type": "item", + "strictlanguage": false +} diff --git a/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/ElasticTermResultTest.php b/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/ElasticTermResultTest.php index 0f49413..ef0aa2c 100644 --- a/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/ElasticTermResultTest.php +++ b/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/ElasticTermResultTest.php @@ -12,7 +12,8 @@ use Wikibase\Repo\Search\Elastic\ElasticTermResult; /** - * @covers ElasticTermResult + * @covers \Wikibase\Repo\Search\Elastic\ElasticTermResult + * * @group Wikibase */ class ElasticTermResultTest extends MediaWikiTestCase { @@ -326,7 +327,7 @@ ]; } - private function getMockFallbackChain( $languages ) { + private function getMockFallbackChain( array $languages ) { $mock = $this->getMockBuilder( LanguageFallbackChain::class ) ->disableOriginalConstructor() ->getMock(); @@ -348,12 +349,8 @@ /** * @dataProvider termResultsProvider - * @param $languages - * @param $displayLanguages - * @param $resultData - * @param $expected */ - public function testTransformResult( $languages, $displayLanguages, $resultData, $expected ) { + public function testTransformResult( array $languages, array $displayLanguages, array $resultData, array $expected ) { $res = new ElasticTermResult( new BasicEntityIdParser(), $languages, diff --git a/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/StatementBoostScoreBuilderTest.php b/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/StatementBoostScoreBuilderTest.php new file mode 100644 index 0000000..c39bcc0 --- /dev/null +++ b/extensions/Wikibase/repo/tests/phpunit/includes/Search/Elastic/StatementBoostScoreBuilderTest.php @@ -0,0 +1,76 @@ +<?php + +namespace Wikibase\Repo\Search\Elastic\Tests; + +use CirrusSearch; +use CirrusSearch\HashSearchConfig; +use CirrusSearch\Search\FunctionScoreDecorator; +use CirrusSearch\Search\SearchContext; +use MediaWikiTestCase; +use Wikibase\Repo\Search\Elastic\StatementBoostScoreBuilder; + +/** + * @covers \Wikibase\Repo\Search\Elastic\StatementBoostScoreBuilder + * + * @group Wikibase + */ +class StatementBoostScoreBuilderTest extends MediaWikiTestCase { + + public function statementBoostProvider() { + return [ + "one statement" => [ + 1.5, + [ 'P31=Q123' => 2 ], + [ + [ + 'weight' => 3.0, + 'filter' => [ 'term' => [ 'statement_keywords' => 'P31=Q123' ] ] + ] + ] + ], + "nothing" => [ + 2, + [], + [] + ], + "multiple statements" => [ + 0.1, + [ 'P31=Q1234' => -2, 'P279=Q345' => -7 ], + [ + [ + 'weight' => -0.2, + 'filter' => [ 'term' => [ 'statement_keywords' => 'P31=Q1234' ] ] + ], + [ + 'weight' => -0.7, + 'filter' => [ 'term' => [ 'statement_keywords' => 'P279=Q345' ] ] + ], + ] + + ], + ]; + } + + /** + * @dataProvider statementBoostProvider + */ + public function testStatementBoosts( $weight, array $settings, array $functions ) { + if ( !class_exists( CirrusSearch::class ) ) { + $this->markTestSkipped( 'CirrusSearch needed.' ); + } + + $config = new HashSearchConfig( [] ); + $context = new SearchContext( $config, null ); + $builder = new StatementBoostScoreBuilder( $context, $weight, $settings ); + $fScore = new FunctionScoreDecorator(); + $builder->append( $fScore ); + $array = $fScore->toArray(); + if ( empty( $functions ) ) { + $this->assertTrue( $fScore->isEmptyFunction() ); + } else { + $this->assertFalse( $fScore->isEmptyFunction() ); + $this->assertEquals( $functions, $array['function_score']['functions'] ); + } + } + +} diff --git a/extensions/Wikidata.org/i18n/tr.json b/extensions/Wikidata.org/i18n/tr.json new file mode 100644 index 0000000..731b9c2 --- /dev/null +++ b/extensions/Wikidata.org/i18n/tr.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Incelemeelemani" + ] + }, + "wikidata-org-desc": "wikidata.org için Wikibase yapılandırma ve özelleştirmesi", + "data-access": "Veri erişimi" +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index b7d105d..4005f63 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1317,6 +1317,7 @@ 'Wikibase\\Repo\\Search\\Elastic\\Fields\\TermIndexField' => $baseDir . '/extensions/Wikibase/repo/includes/Search/Elastic/Fields/TermIndexField.php', 'Wikibase\\Repo\\Search\\Elastic\\Fields\\WikibaseIndexField' => $baseDir . '/extensions/Wikibase/repo/includes/Search/Elastic/Fields/WikibaseIndexField.php', 'Wikibase\\Repo\\Search\\Elastic\\Fields\\WikibaseNumericField' => $baseDir . '/extensions/Wikibase/repo/includes/Search/Elastic/Fields/WikibaseNumericField.php', + 'Wikibase\\Repo\\Search\\Elastic\\StatementBoostScoreBuilder' => $baseDir . '/extensions/Wikibase/repo/includes/Search/Elastic/StatementBoostScoreBuilder.php', 'Wikibase\\Repo\\Search\\Elastic\\WikibasePrefixSearcher' => $baseDir . '/extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php', 'Wikibase\\Repo\\SiteLinkTargetProvider' => $baseDir . '/extensions/Wikibase/repo/includes/SiteLinkTargetProvider.php', 'Wikibase\\Repo\\SnakFactory' => $baseDir . '/extensions/Wikibase/repo/includes/SnakFactory.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e7d2636..fb0c032 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -1621,6 +1621,7 @@ 'Wikibase\\Repo\\Search\\Elastic\\Fields\\TermIndexField' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/Search/Elastic/Fields/TermIndexField.php', 'Wikibase\\Repo\\Search\\Elastic\\Fields\\WikibaseIndexField' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/Search/Elastic/Fields/WikibaseIndexField.php', 'Wikibase\\Repo\\Search\\Elastic\\Fields\\WikibaseNumericField' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/Search/Elastic/Fields/WikibaseNumericField.php', + 'Wikibase\\Repo\\Search\\Elastic\\StatementBoostScoreBuilder' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/Search/Elastic/StatementBoostScoreBuilder.php', 'Wikibase\\Repo\\Search\\Elastic\\WikibasePrefixSearcher' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/Search/Elastic/WikibasePrefixSearcher.php', 'Wikibase\\Repo\\SiteLinkTargetProvider' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/SiteLinkTargetProvider.php', 'Wikibase\\Repo\\SnakFactory' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/includes/SnakFactory.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index a712c07..f4ee55d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -533,29 +533,29 @@ }, { "name": "data-values/serialization", - "version": "1.2.1", - "version_normalized": "1.2.1.0", + "version": "1.2.2", + "version_normalized": "1.2.2.0", "source": { "type": "git", "url": "https://github.com/DataValues/Serialization.git", - "reference": "2e81e60e413f1578fbaddb9dd2fbcc8236825806" + "reference": "d849fc1a2f00f22027d504c4e70fd00a0c6a7579" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DataValues/Serialization/zipball/2e81e60e413f1578fbaddb9dd2fbcc8236825806", - "reference": "2e81e60e413f1578fbaddb9dd2fbcc8236825806", + "url": "https://api.github.com/repos/DataValues/Serialization/zipball/d849fc1a2f00f22027d504c4e70fd00a0c6a7579", + "reference": "d849fc1a2f00f22027d504c4e70fd00a0c6a7579", "shasum": "" }, "require": { "data-values/data-values": "~1.0|~0.1", "php": ">=5.5.9", - "serialization/serialization": "~3.0" + "serialization/serialization": "~4.0|~3.0" }, "require-dev": { - "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8", - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "~4.8", + "wikibase/wikibase-codesniffer": "^0.2.0" }, - "time": "2017-06-26 07:24:35", + "time": "2017-10-25 13:47:05", "type": "library", "extra": { "branch-alias": { @@ -1389,12 +1389,12 @@ "source": { "type": "git", "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", - "reference": "932e03cf5d1b63a76373a8daf9795bf066af08bd" + "reference": "84f5795908c00f3c37072b02aa025c782083bda3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/932e03cf5d1b63a76373a8daf9795bf066af08bd", - "reference": "932e03cf5d1b63a76373a8daf9795bf066af08bd", + "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/84f5795908c00f3c37072b02aa025c782083bda3", + "reference": "84f5795908c00f3c37072b02aa025c782083bda3", "shasum": "" }, "require": { @@ -1429,7 +1429,7 @@ "mediawiki/minus-x": "0.1.0", "wikibase/wikibase-codesniffer": "^0.2.0" }, - "time": "2017-10-24 15:12:58", + "time": "2017-10-26 07:53:28", "type": "mediawiki-extension", "installation-source": "dist", "autoload": { @@ -1539,7 +1539,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikidata.org", - "reference": "764890c0924f0a011b585f70d6e72200212af543" + "reference": "f2def2a8a4ead8b7e44bce63a9af883cb89f99ff" }, "require": { "php": ">=5.5.9" @@ -1549,7 +1549,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "wikibase/wikibase-codesniffer": "^0.2.0" }, - "time": "2017-10-15 18:02:13", + "time": "2017-10-25 21:08:35", "type": "mediawiki-extension", "installation-source": "source", "autoload": { @@ -1775,7 +1775,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", - "reference": "2dd73c81b063b40981eee40d6aa5ba47bae6cc42" + "reference": "598671433d7c5d8cef818c6eff957a5eb00e0040" }, "require": { "php": ">=5.5.9", @@ -1791,7 +1791,7 @@ "satooshi/php-coveralls": "master-dev", "wikibase/wikibase-codesniffer": "^0.2.0" }, - "time": "2017-10-25 06:24:26", + "time": "2017-10-25 21:08:09", "type": "mediawiki-extension", "installation-source": "source", "autoload": { diff --git a/vendor/data-values/serialization/.gitignore b/vendor/data-values/serialization/.gitignore deleted file mode 100644 index 577795c..0000000 --- a/vendor/data-values/serialization/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -*~ -*.kate-swp -*.swp - -!.* - -.idea/ -build/ -vendor/ - -composer.phar -composer.lock \ No newline at end of file diff --git a/vendor/data-values/serialization/.scrutinizer.yml b/vendor/data-values/serialization/.scrutinizer.yml deleted file mode 100644 index d6c0c6b..0000000 --- a/vendor/data-values/serialization/.scrutinizer.yml +++ /dev/null @@ -1,13 +0,0 @@ -build: true -inherit: true - -tools: - php_code_coverage: true - php_code_sniffer: true - php_cpd: true - php_cs_fixer: true - php_loc: true - php_mess_detector: true - php_pdepend: true - php_analyzer: true - sensiolabs_security_checker: true diff --git a/vendor/data-values/serialization/.travis.yml b/vendor/data-values/serialization/.travis.yml deleted file mode 100644 index 387600d..0000000 --- a/vendor/data-values/serialization/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php - -dist: trusty - -php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - hhvm - -before_script: - - composer install --prefer-source - -script: composer test - -cache: - directories: - - $HOME/.composer/cache diff --git a/vendor/data-values/serialization/README.md b/vendor/data-values/serialization/README.md index 03a2a58..89bfa50 100644 --- a/vendor/data-values/serialization/README.md +++ b/vendor/data-values/serialization/README.md @@ -49,6 +49,10 @@ ## Release notes +### 1.2.2 (2017-10-25) + +* Made component installable together Serialization 4.x + ### 1.2.1 (2017-06-26) * Fixed `DataValueDeserializer` not always turning internal `InvalidArgumentException` into diff --git a/vendor/data-values/serialization/composer.json b/vendor/data-values/serialization/composer.json deleted file mode 100644 index c37c270..0000000 --- a/vendor/data-values/serialization/composer.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "data-values/serialization", - "type": "library", - "description": "Serializers and deserializers for DataValue implementations", - "keywords": [ - "datavalues", - "wikidata", - "serialization", - "serializers", - "deserializers" - ], - "homepage": "https://github.com/DataValues/Serialization", - "license": "GPL-2.0+", - "authors": [ - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com", - "role": "Developer" - } - ], - "support": { - "irc": "irc://irc.freenode.net/wikidata" - }, - "require": { - "php": ">=5.5.9", - "data-values/data-values": "~1.0|~0.1", - "serialization/serialization": "~3.0" - }, - "require-dev": { - "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8", - "phpunit/phpunit": "~4.8" - }, - "autoload": { - "psr-4": { - "DataValues\\Serializers\\": "src/Serializers", - "DataValues\\Deserializers\\": "src/Deserializers" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "scripts": { - "test": [ - "@validate --no-interaction", - "@phpcs", - "phpunit" - ], - "phpcs": [ - "phpcs src/* tests/* --standard=phpcs.xml -sp" - ] - } -} diff --git a/vendor/data-values/serialization/phpcs.xml b/vendor/data-values/serialization/phpcs.xml deleted file mode 100644 index a01fdf1..0000000 --- a/vendor/data-values/serialization/phpcs.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0"?> -<ruleset name="DataValuesSerialization"> - <!-- See https://github.com/wikimedia/mediawiki-tools-codesniffer/blob/master/MediaWiki/ruleset.xml --> - <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> - <exclude name="Generic.Arrays.DisallowLongArraySyntax" /> - </rule> - - <rule ref="Generic.ControlStructures" /> - <rule ref="Generic.Files.LineLength"> - <properties> - <property name="lineLimit" value="113" /> - </properties> - </rule> - <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" /> - - <rule ref="PSR1" /> - <rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"> - <!-- Exclude test methods like "testGivenInvalidInput_methodThrowsException". --> - <exclude-pattern>tests*Test*\.php</exclude-pattern> - </rule> - - <rule ref="PSR2.Files" /> - - <rule ref="Squiz.Classes.DuplicateProperty" /> - <rule ref="Squiz.Classes.SelfMemberReference" /> - <rule ref="Squiz.ControlStructures.ControlSignature" /> - <rule ref="Squiz.Functions.FunctionDuplicateArgument" /> - <rule ref="Squiz.Functions.GlobalFunction" /> - <rule ref="Squiz.Scope" /> - <rule ref="Squiz.WhiteSpace.FunctionSpacing"> - <properties> - <property name="spacing" value="1" /> - </properties> - </rule> - <rule ref="Squiz.WhiteSpace.OperatorSpacing"> - <properties> - <property name="ignoreNewlines" value="true" /> - </properties> - </rule> - - <arg name="extensions" value="php" /> - <arg name="encoding" value="utf8" /> -</ruleset> diff --git a/vendor/data-values/serialization/phpunit.xml.dist b/vendor/data-values/serialization/phpunit.xml.dist deleted file mode 100644 index 2eaf91d..0000000 --- a/vendor/data-values/serialization/phpunit.xml.dist +++ /dev/null @@ -1,24 +0,0 @@ -<phpunit backupGlobals="false" - backupStaticAttributes="false" - bootstrap="tests/bootstrap.php" - cacheTokens="false" - colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - stopOnError="false" - stopOnFailure="false" - stopOnIncomplete="false" - stopOnSkipped="false" - verbose="true"> - <testsuites> - <testsuite name="DataValuesSerialization"> - <directory>tests</directory> - </testsuite> - </testsuites> - <filter> - <whitelist addUncoveredFilesFromWhitelist="true"> - <directory suffix=".php">src</directory> - </whitelist> - </filter> -</phpunit> diff --git a/vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php b/vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php index bc104cd..a311eb3 100644 --- a/vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php +++ b/vendor/data-values/serialization/src/Deserializers/DataValueDeserializer.php @@ -29,8 +29,6 @@ */ private $builders; - private $serialization; - /** * @since 0.1, callables are supported since 1.1 * @@ -39,7 +37,7 @@ * corresponding DataValue::getArrayValue, and return a new DataValue object. DataValue classes * given via class name must implement a static newFromArray method doing the same. */ - public function __construct( array $builders = array() ) { + public function __construct( array $builders = [] ) { $this->assertAreDataValueClasses( $builders ); $this->builders = $builders; } @@ -72,10 +70,8 @@ * @return bool */ public function isDeserializerFor( $serialization ) { - $this->serialization = $serialization; - try { - $this->assertCanDeserialize(); + $this->assertCanDeserialize( $serialization ); return true; } catch ( RuntimeException $ex ) { return false; @@ -91,62 +87,46 @@ * @return DataValue */ public function deserialize( $serialization ) { - $this->serialization = $serialization; - - $this->assertCanDeserialize(); - return $this->getDeserialization(); + $this->assertCanDeserialize( $serialization ); + return $this->getDeserialization( $serialization ); } - private function assertCanDeserialize() { - $this->assertHasSupportedType(); - $this->assertHasValue(); - } - - private function assertHasSupportedType() { - if ( !is_array( $this->serialization ) || !array_key_exists( self::TYPE_KEY, $this->serialization ) ) { + private function assertCanDeserialize( $serialization ) { + if ( !is_array( $serialization ) || !array_key_exists( self::TYPE_KEY, $serialization ) ) { throw new MissingTypeException(); } - if ( !$this->hasSupportedType() ) { - throw new UnsupportedTypeException( $this->getType() ); - } - } - - private function assertHasValue() { - if ( !array_key_exists( self::VALUE_KEY, $this->serialization ) ) { + if ( !array_key_exists( self::VALUE_KEY, $serialization ) ) { throw new MissingAttributeException( self::VALUE_KEY ); } - } - private function hasSupportedType() { - return array_key_exists( $this->getType(), $this->builders ); - } - - private function getType() { - return $this->serialization[self::TYPE_KEY]; + $type = $serialization[self::TYPE_KEY]; + if ( !array_key_exists( $type, $this->builders ) ) { + throw new UnsupportedTypeException( $type ); + } } /** + * @param array $serialization + * * @throws DeserializationException * @return DataValue */ - private function getDeserialization() { - $builder = $this->builders[$this->getType()]; + private function getDeserialization( array $serialization ) { + $type = $serialization[self::TYPE_KEY]; + $value = $serialization[self::VALUE_KEY]; + $builder = $this->builders[$type]; try { if ( is_callable( $builder ) ) { - return $builder( $this->getValue() ); + return $builder( $value ); } /** @var DataValue $builder */ - return $builder::newFromArray( $this->getValue() ); + return $builder::newFromArray( $value ); } catch ( InvalidArgumentException $ex ) { throw new DeserializationException( $ex->getMessage(), $ex ); } - } - - private function getValue() { - return $this->serialization[self::VALUE_KEY]; } } diff --git a/vendor/data-values/serialization/tests/Deserializers/DataValueDeserializerTest.php b/vendor/data-values/serialization/tests/Deserializers/DataValueDeserializerTest.php deleted file mode 100644 index 1fd4528..0000000 --- a/vendor/data-values/serialization/tests/Deserializers/DataValueDeserializerTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace Tests\DataValues\Deserializers; - -use DataValues\BooleanValue; -use DataValues\DataValue; -use DataValues\Deserializers\DataValueDeserializer; -use DataValues\NumberValue; -use DataValues\StringValue; -use Deserializers\Exceptions\DeserializationException; -use Deserializers\Exceptions\MissingAttributeException; -use Deserializers\Exceptions\MissingTypeException; -use Deserializers\Exceptions\UnsupportedTypeException; -use InvalidArgumentException; -use PHPUnit_Framework_TestCase; - -/** - * @covers DataValues\Deserializers\DataValueDeserializer - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class DataValueDeserializerTest extends PHPUnit_Framework_TestCase { - - public function testGivenEmptyArray_isDeserializerForReturnsFalse() { - $deserializer = $this->newDeserializer(); - $this->assertFalse( $deserializer->isDeserializerFor( array() ) ); - } - - private function newDeserializer() { - return new DataValueDeserializer( array( - 'boolean' => function( $bool ) { - return new BooleanValue( $bool ); - }, - 'number' => NumberValue::class, - 'string' => StringValue::class, - ) ); - } - - /** - * @dataProvider notAnArrayProvider - */ - public function testGivenNonArray_isDeserializerForReturnsFalse( $notAnArray ) { - $deserializer = $this->newDeserializer(); - $this->assertFalse( $deserializer->isDeserializerFor( $notAnArray ) ); - } - - public function notAnArrayProvider() { - return array( - array( null ), - array( 0 ), - array( true ), - array( (object)array() ), - array( 'foo' ), - ); - } - - /** - * @dataProvider notADataValuesListProvider - */ - public function testGivenNonDataValues_constructorThrowsException( array $invalidDVList ) { - $this->setExpectedException( InvalidArgumentException::class ); - - new DataValueDeserializer( $invalidDVList ); - } - - public function notADataValuesListProvider() { - return array( - array( - array( - 'foo', - null, - array(), - true, - 42, - ) - ), - array( - array( - 'string' => 'foo', - ) - ), - array( - array( - 'string' => StringValue::class, - 'number' => 42, - ) - ), - array( - array( - 'string' => StringValue::class, - 'object' => 'stdClass', - ) - ) - ); - } - - public function testGivenSerializationNoType_deserializeThrowsException() { - $deserializer = $this->newDeserializer(); - - $this->setExpectedException( MissingTypeException::class ); - $deserializer->deserialize( array() ); - } - - public function testGivenSerializationWithUnknownType_deserializeThrowsException() { - $deserializer = $this->newDeserializer(); - - $this->setExpectedException( UnsupportedTypeException::class ); - $deserializer->deserialize( - array( - 'type' => 'ohi' - ) - ); - } - - public function testGivenSerializationWithNoValue_deserializeThrowsException() { - $deserializer = $this->newDeserializer(); - - $this->setExpectedException( MissingAttributeException::class ); - $deserializer->deserialize( - array( - 'type' => 'number' - ) - ); - } - - /** - * @dataProvider invalidDataValueSerializationProvider - */ - public function testGivenInvalidDataValue_deserializeThrowsException( $invalidSerialization ) { - $deserializer = $this->newDeserializer(); - - $this->setExpectedException( DeserializationException::class ); - $deserializer->deserialize( $invalidSerialization ); - } - - public function invalidDataValueSerializationProvider() { - return [ - [ 'foo' ], - [ null ], - [ [] ], - [ [ 'hax' ] ], - [ [ 'type' => 'hax' ] ], - [ [ 'type' => 'number', 'value' => [] ] ], - [ [ 'type' => 'boolean', 'value' => 'not a boolean' ] ], - ]; - } - - public function testInvalidValueSerialization_throwsDeserializationException() { - $serialization = array( - 'value' => array( 0, 0 ), - 'type' => 'string', - 'error' => 'omg an error!' - ); - - $deserializer = $this->newDeserializer(); - $this->setExpectedException( DeserializationException::class ); - $deserializer->deserialize( $serialization ); - } - - /** - * @dataProvider dataValueSerializationProvider - */ - public function testGivenDataValueSerialization_isDeserializerForReturnsTrue( $dvSerialization ) { - $deserializer = $this->newDeserializer(); - $this->assertTrue( $deserializer->isDeserializerFor( $dvSerialization ) ); - } - - public function dataValueSerializationProvider() { - $boolean = new BooleanValue( false ); - $string = new StringValue( 'foo bar baz' ); - $number = new NumberValue( 42 ); - - return array( - array( $boolean->toArray(), 'boolean' ), - array( $string->toArray(), 'string' ), - array( $number->toArray(), 'number' ), - ); - } - - /** - * @dataProvider dataValueSerializationProvider - */ - public function testGivenDataValueSerialization_deserializeReturnsDataValue( $dvSerialization, $expectedType ) { - $deserializer = $this->newDeserializer(); - - $dataValue = $deserializer->deserialize( $dvSerialization ); - - $this->assertInstanceOf( DataValue::class, $dataValue ); - $this->assertEquals( $expectedType, $dataValue->getType() ); - } - -} diff --git a/vendor/data-values/serialization/tests/Serializers/DataValueSerializerTest.php b/vendor/data-values/serialization/tests/Serializers/DataValueSerializerTest.php deleted file mode 100644 index fe3acfa..0000000 --- a/vendor/data-values/serialization/tests/Serializers/DataValueSerializerTest.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -namespace Tests\DataValues\Serializers; - -use DataValues\DataValue; -use DataValues\NumberValue; -use DataValues\Serializers\DataValueSerializer; -use DataValues\StringValue; -use PHPUnit_Framework_TestCase; -use Serializers\Exceptions\SerializationException; - -/** - * @covers DataValues\Serializers\DataValueSerializer - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class DataValueSerializerTest extends PHPUnit_Framework_TestCase { - - /** - * @dataProvider notADataValueProvider - */ - public function testGivenNonDataValue_IsSerializerForReturnsFalse( $notAnObject ) { - $serializer = new DataValueSerializer(); - - $this->assertFalse( $serializer->isSerializerFor( $notAnObject ) ); - } - - public function notADataValueProvider() { - return array( - array( 0 ), - array( null ), - array( '' ), - array( array() ), - array( true ), - array( 4.2 ), - array( (object)array() ), - array( new \Exception() ), - ); - } - - /** - * @dataProvider dataValueProvider - */ - public function testGivenDataValue_IsSerializerForReturnsTrue( DataValue $dataValue ) { - $serializer = new DataValueSerializer(); - - $this->assertTrue( $serializer->isSerializerFor( $dataValue ) ); - } - - public function dataValueProvider() { - return array( - array( new StringValue( 'foo' ) ), - array( new NumberValue( 42 ) ), - ); - } - - /** - * @dataProvider notADataValueProvider - */ - public function testWhenGivenNonDataValue_SerializeThrowsException( $notAnObject ) { - $serializer = new DataValueSerializer(); - - $this->setExpectedException( SerializationException::class ); - $serializer->serialize( $notAnObject ); - } - - public function testWhenGivenDataValue_SerializeCallsToArray() { - $returnValue = 'expected return value'; - - $serializer = new DataValueSerializer(); - - $dataValue = $this->getMock( DataValue::class ); - $dataValue->expects( $this->once() ) - ->method( 'toArray' ) - ->will( $this->returnValue( $returnValue ) ); - - $this->assertEquals( $returnValue, $serializer->serialize( $dataValue ) ); - } - -} diff --git a/vendor/data-values/serialization/tests/bootstrap.php b/vendor/data-values/serialization/tests/bootstrap.php deleted file mode 100644 index ac82d46..0000000 --- a/vendor/data-values/serialization/tests/bootstrap.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -if ( PHP_SAPI !== 'cli' ) { - die( 'Not an entry point' ); -} - -error_reporting( E_ALL | E_STRICT ); -ini_set( 'display_errors', 1 ); - -if ( !is_readable( __DIR__ . '/../vendor/autoload.php' ) ) { - die( 'You need to install this package with Composer before you can run the tests' ); -} - -require_once __DIR__ . '/../vendor/autoload.php'; -- To view, visit https://gerrit.wikimedia.org/r/386596 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74c3f354260d86624f2120f3d1ae8ed3dca67989 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikidata Gerrit-Branch: master Gerrit-Owner: WikidataBuilder <wikidata-servi...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits