Daniel Kinzler has uploaded a new change for review. https://gerrit.wikimedia.org/r/62815
Change subject: (bug 47610) Keep default settings out of globals. ...................................................................... (bug 47610) Keep default settings out of globals. This change allows for using $wgWBClientSettings resp $wgWBRepoSettings for all settings, while staying compatible with sites using $wgWBSettings for everything. Special care has been taken to make sure default values never override explicit configuration, and repo/client settings override "generic" settings. Change-Id: I14422cd85a3cf0200ea89953251b78b6b8d813cb --- M client/WikibaseClient.php M client/config/WikibaseClient.default.php M lib/WikibaseLib.php M lib/config/WikibaseLib.default.php M lib/includes/Settings.php M repo/Wikibase.php M repo/config/Wikibase.default.php 7 files changed, 272 insertions(+), 237 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/15/62815/1 diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index ba013d1..9dff8f7 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -39,6 +39,8 @@ define( 'WBC_VERSION', '0.4 alpha' . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); +define( 'WBC_DIR', __DIR__ ); + $wgExtensionCredits['wikibase'][] = array( 'path' => __DIR__, 'name' => 'Wikibase Client', @@ -144,7 +146,7 @@ $wgWBClientStores['DirectSqlStore'] = 'Wikibase\DirectSqlStore'; -include_once( $dir . 'config/WikibaseClient.default.php' ); +$wgWBClientSettings = array(); if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { include_once( $dir . 'config/WikibaseClient.experimental.php' ); diff --git a/client/config/WikibaseClient.default.php b/client/config/WikibaseClient.default.php index 617979e..5494f38 100644 --- a/client/config/WikibaseClient.default.php +++ b/client/config/WikibaseClient.default.php @@ -29,156 +29,157 @@ * @licence GNU GPL v2+ */ -if ( !defined( 'WBC_VERSION' ) ) { - die( 'Not an entry point.' ); -} -global $wgScriptPath, $wgArticlePath, $wgLanguageCode, $wgDBname; +return call_user_func( function() { + global $wgScriptPath, $wgArticlePath, $wgLanguageCode, $wgDBname; -$wgWBClientSettings = array( - 'namespaces' => array(), // by default, include all namespaces; deprecated as of 0.4 - 'excludeNamespaces' => array(), - 'repoUrl' => '//www.wikidata.org', - 'repoScriptPath' => $wgScriptPath, - 'repoArticlePath' => $wgArticlePath, - 'sort' => 'code', - 'sortPrepend' => array(), - 'alwaysSort' => false, - 'siteGlobalID' => $wgDBname, - // @todo would be great to just get this from the sites stuff - // but we will need to make sure the caching works good enough - 'siteLocalID' => $wgLanguageCode, - 'siteGroup' => 'wikipedia', - 'injectRecentChanges' => true, - 'showExternalRecentChanges' => true, - 'defaultClientStore' => null, - 'repoDatabase' => null, // note: "false" means "local"! - // default for repo items in main namespace - 'repoNamespaces' => array( - 'wikibase-item' => '', - 'wikibase-property' => 'Property' - ), - 'allowDataTransclusion' => true, - 'enableSiteLinkWidget' => false, -); + $defaults = array( + 'namespaces' => array(), // by default, include all namespaces; deprecated as of 0.4 + 'excludeNamespaces' => array(), + 'repoUrl' => '//www.wikidata.org', + 'repoScriptPath' => $wgScriptPath, + 'repoArticlePath' => $wgArticlePath, + 'sort' => 'code', + 'sortPrepend' => array(), + 'alwaysSort' => false, + 'siteGlobalID' => $wgDBname, + // @todo would be great to just get this from the sites stuff + // but we will need to make sure the caching works good enough + 'siteLocalID' => $wgLanguageCode, + 'siteGroup' => 'wikipedia', + 'injectRecentChanges' => true, + 'showExternalRecentChanges' => true, + 'defaultClientStore' => null, + 'repoDatabase' => null, // note: "false" means "local"! + // default for repo items in main namespace + 'repoNamespaces' => array( + 'wikibase-item' => '', + 'wikibase-property' => 'Property' + ), + 'allowDataTransclusion' => true, + 'enableSiteLinkWidget' => false, -/** - * @todo this is a bit wikimedia-specific and need to find a better place for this stuff, - * such as mediawiki-config, mediawiki messages for custom orders, or somewhere. - * - * alphabetic and alphabetic revised come from: - * http://meta.wikimedia.org/w/index.php?title=MediaWiki:Interwiki_config-sorting_order-native-languagename - * http://meta.wikimedia.org/w/index.php?title=MediaWiki:Interwiki_config-sorting_order-native-languagename-firstword (revised) - * and from pywikipedia for alphabetic_sr - */ -$wgWBClientSettings['interwikiSortOrders'] = array( - 'alphabetic' => array( - 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an', 'arc', - 'roa-rup', 'frp', 'as', 'ast', 'gn', 'av', 'ay', 'az', 'bm', 'bn', 'bjn', - 'zh-min-nan', 'nan', 'map-bms', 'ba', 'be', 'be-x-old', 'bh', 'bcl', 'bi', - 'bg', 'bar', 'bo', 'bs', 'br', 'bxr', 'ca', 'cv', 'ceb', 'cs', 'ch', - 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'co', 'cy', 'da', 'dk', 'pdc', 'de', - 'dv', 'nv', 'dsb', 'dz', 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', - 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', - 'gag', 'gd', 'gl', 'gan', 'ki', 'glk', 'gu', 'got', 'hak', 'xal', 'ko', 'ha', - 'haw', 'hy', 'hi', 'ho', 'hsb', 'hr', 'io', 'ig', 'ilo', 'bpy', 'id', 'ia', - 'ie', 'iu', 'ik', 'os', 'xh', 'zu', 'is', 'it', 'he', 'jv', 'kl', 'kn', 'kr', - 'pam', 'krc', 'ka', 'ks', 'csb', 'kk', 'kw', 'rw', 'rn', 'sw', 'kv', 'kg', - 'ht', 'ku', 'kj', 'ky', 'mrj', 'lad', 'lbe', 'lez', 'lo', 'ltg', 'la', 'lv', - 'lb', 'lt', 'lij', 'li', 'ln', 'jbo', 'lg', 'lmo', 'hu', 'mk', 'mg', 'ml', - 'mt', 'mi', 'mr', 'xmf', 'arz', 'mzn', 'ms', 'min', 'cdo', 'mwl', 'mdf', 'mo', - 'mn', 'mus', 'my', 'nah', 'na', 'fj', 'nl', 'nds-nl', 'cr', 'ne', 'new', 'ja', - 'nap', 'ce', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov', 'ii', 'oc', 'mhr', - 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pi', 'pfl', 'pag', 'pnb', 'pap', 'ps', - 'koi', 'km', 'pcd', 'pms', 'tpi', 'nds', 'pl', 'tokipona', 'tp', 'pnt', 'pt', - 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy', 'rm', 'qu', 'rue', 'ru', 'sah', - 'se', 'sm', 'sa', 'sg', 'sc', 'sco', 'stq', 'st', 'nso', 'tn', 'sq', 'scn', - 'si', 'simple', 'sd', 'ss', 'sk', 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', - 'sh', 'su', 'fi', 'sv', 'tl', 'ta', 'shi', 'kab', 'roa-tara', 'tt', 'te', 'tet', - 'th', 'ti', 'tg', 'to', 'chr', 'chy', 've', 'tr', 'tk', 'tw', 'udm', 'bug', - 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vi', 'vo', 'fiu-vro', 'wa', 'zh-classical', - 'vls', 'war', 'wo', 'wuu', 'ts', 'yi', 'yo', 'zh-yue', 'diq', 'zea', 'bat-smg', - 'zh', 'zh-tw', 'zh-cn' - ), - 'alphabetic_revised' => array( - 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an', 'arc', 'roa-rup', - 'frp', 'as', 'ast', 'gn', 'av', 'ay', 'az', 'bjn', 'id', 'ms', 'bm', 'bn', - 'zh-min-nan', 'nan', 'map-bms', 'jv', 'su', 'ba', 'min', 'be', 'be-x-old', 'bh', - 'bcl', 'bi', 'bar', 'bo', 'bs', 'br', 'bug', 'bg', 'bxr', 'ca', 'ceb', 'cv', 'cs', - 'ch', 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'co', 'cy', 'da', 'dk', 'pdc', 'de', - 'dv', 'nv', 'dsb', 'na', 'dz', 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', - 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', 'sm', - 'gag', 'gd', 'gl', 'gan', 'ki', 'glk', 'gu', 'got', 'hak', 'xal', 'ko', 'ha', 'haw', - 'hy', 'hi', 'ho', 'hsb', 'hr', 'io', 'ig', 'ilo', 'bpy', 'ia', 'ie', 'iu', 'ik', - 'os', 'xh', 'zu', 'is', 'it', 'he', 'kl', 'kn', 'kr', 'pam', 'ka', 'ks', 'csb', - 'kk', 'kw', 'rw', 'ky', 'rn', 'mrj', 'sw', 'kv', 'kg', 'ht', 'ku', 'kj', 'lad', - 'lbe', 'lez', 'lo', 'la', 'ltg', 'lv', 'to', 'lb', 'lt', 'lij', 'li', 'ln', 'jbo', - 'lg', 'lmo', 'hu', 'mk', 'mg', 'ml', 'krc', 'mt', 'mi', 'mr', 'xmf', 'arz', 'mzn', - 'cdo', 'mwl', 'koi', 'mdf', 'mo', 'mn', 'mus', 'my', 'nah', 'fj', 'nl', 'nds-nl', - 'cr', 'ne', 'new', 'ja', 'nap', 'ce', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov', - 'ii', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pi', 'pfl', 'pag', 'pnb', - 'pap', 'ps', 'km', 'pcd', 'pms', 'nds', 'pl', 'pnt', 'pt', 'aa', 'kaa', 'crh', 'ty', - 'ksh', 'ro', 'rmy', 'rm', 'qu', 'ru', 'rue', 'sah', 'se', 'sa', 'sg', 'sc', 'sco', - 'stq', 'st', 'nso', 'tn', 'sq', 'scn', 'si', 'simple', 'sd', 'ss', 'sk', 'sl', - 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', 'sh', 'fi', 'sv', 'tl', 'ta', 'shi', - 'kab', 'roa-tara', 'tt', 'te', 'tet', 'th', 'vi', 'ti', 'tg', 'tpi', 'tokipona', - 'tp', 'chr', 'chy', 've', 'tr', 'tk', 'tw', 'udm', 'uk', 'ur', 'ug', 'za', - 'vec', 'vep', 'vo', 'fiu-vro', 'wa', 'zh-classical', 'vls', 'war', 'wo', 'wuu', - 'ts', 'yi', 'yo', 'zh-yue', 'diq', 'zea', 'bat-smg', 'zh', 'zh-tw', 'zh-cn' - ), - 'alphabetic_sr' => array( - 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an', 'arc', - 'roa-rup', 'frp', 'arz', 'as', 'ast', 'gn', 'av', 'ay', 'az', 'bjn', 'id', - 'ms', 'bg', 'bm', 'zh-min-nan', 'nan', 'map-bms', 'jv', 'su', 'ba', 'be', - 'be-x-old', 'bh', 'bcl', 'bi', 'bn', 'bo', 'bar', 'bs', 'bpy', 'br', 'bug', - 'bxr', 'ca', 'ceb', 'ch', 'cbk-zam', 'sn', 'tum', 'ny', 'cho', 'chr', 'co', - 'cy', 'cv', 'cs', 'da', 'dk', 'pdc', 'de', 'nv', 'dsb', 'na', 'dv', 'dz', - 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', 'ext', 'eu', 'ee', 'fa', - 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', 'sm', 'gag', 'gd', 'gl', - 'gan', 'ki', 'glk', 'got', 'gu', 'ha', 'hak', 'xal', 'haw', 'he', 'hi', 'ho', - 'hsb', 'hr', 'hy', 'io', 'ig', 'ii', 'ilo', 'ia', 'ie', 'iu', 'ik', 'os', - 'xh', 'zu', 'is', 'it', 'ja', 'ka', 'kl', 'kr', 'pam', 'krc', 'csb', 'kk', - 'kw', 'rw', 'ky', 'mrj', 'rn', 'sw', 'km', 'kn', 'ko', 'kv', 'kg', 'ht', - 'ks', 'ku', 'kj', 'lad', 'lbe', 'la', 'ltg', 'lv', 'to', 'lb', 'lez', 'lt', - 'lij', 'li', 'ln', 'lo', 'jbo', 'lg', 'lmo', 'hu', 'mk', 'mg', 'mt', 'mi', - 'min', 'cdo', 'mwl', 'ml', 'mdf', 'mo', 'mn', 'mr', 'mus', 'my', 'mzn', 'nah', - 'fj', 'ne', 'nl', 'nds-nl', 'cr', 'new', 'nap', 'ce', 'frr', 'pih', 'no', 'nb', - 'nn', 'nrm', 'nov', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pfl', - 'pag', 'pap', 'koi', 'pi', 'pcd', 'pms', 'nds', 'pnb', 'pl', 'pt', 'pnt', - 'ps', 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy', 'rm', 'qu', 'ru', 'rue', - 'sa', 'sah', 'se', 'sg', 'sc', 'sco', 'sd', 'stq', 'st', 'nso', 'tn', 'sq', - 'si', 'scn', 'simple', 'ss', 'sk', 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', - 'sr', 'sh', 'fi', 'sv', 'ta', 'shi', 'tl', 'kab', 'roa-tara', 'tt', 'te', - 'tet', 'th', 'ti', 'vi', 'tg', 'tokipona', 'tp', 'tpi', 'chy', 've', 'tr', - 'tk', 'tw', 'udm', 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vo', 'fiu-vro', - 'wa', 'vls', 'war', 'wo', 'wuu', 'ts', 'xmf', 'yi', 'yo', 'diq', 'zea', 'zh', - 'zh-tw', 'zh-cn', 'zh-classical', 'zh-yue', 'bat-smg' - ), - 'alphabetic_fy' => array( - 'aa', 'ab', 'ace', 'af', 'ay', 'ak', 'als', 'am', 'an', 'ang', 'ar', 'arc', - 'arz', 'as', 'ast', 'av', 'az', 'ba', 'bar', 'bat-smg', 'bcl', 'be', 'be-x-old', - 'bg', 'bh', 'bi', 'bjn', 'bm', 'bn', 'bo', 'bpy', 'br', 'bs', 'bug', 'bxr', - 'ca', 'cbk-zam', 'cdo', 'ce', 'ceb', 'ch', 'chy', 'cho', 'chr', 'cy', 'ckb', - 'co', 'cr', 'crh', 'cs', 'csb', 'cu', 'cv', 'da', 'de', 'diq', 'dk', 'dsb', 'dv', - 'dz', 'ee', 'el', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'fa', 'ff', 'fi', - 'fy', 'fiu-vro', 'fj', 'fo', 'fr', 'frp', 'frr', 'fur', 'ga', 'gag', 'gan', 'gd', - 'gl', 'glk', 'gn', 'got', 'gu', 'gv', 'ha', 'hak', 'haw', 'he', 'hi', 'hy', - 'hif', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'yi', - 'ik', 'ilo', 'io', 'yo', 'is', 'it', 'iu', 'ja', 'jbo', 'jv', 'ka', 'kaa', 'kab', - 'kbd', 'kg', 'ki', 'ky', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'koi', 'kr', 'krc', - 'ks', 'ksh', 'ku', 'kv', 'kw', 'la', 'lad', 'lb', 'lbe', 'lez', 'lg', 'li', - 'lij', 'lmo', 'ln', 'lo', 'lt', 'ltg', 'lv', 'map-bms', 'mdf', 'mg', 'mh', 'mhr', - 'mi', 'my', 'min', 'myv', 'mk', 'ml', 'mn', 'mo', 'mr', 'mrj', 'ms', 'mt', 'mus', - 'mwl', 'mzn', 'na', 'nah', 'nan', 'nap', 'nds', 'nds-nl', 'ne', 'new', 'ng', 'ny', - 'nl', 'nn', 'no', 'nov', 'nrm', 'nso', 'nv', 'oc', 'om', 'or', 'os', 'pa', 'pag', - 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pi', 'pih', 'pl', 'pms', 'pnb', 'pnt', 'ps', - 'pt', 'qu', 'rm', 'rmy', 'rn', 'ro', 'roa-rup', 'roa-tara', 'ru', 'rue', 'rw', - 'sa', 'sah', 'sc', 'scn', 'sco', 'sd', 'se', 'sg', 'sh', 'shi', 'si', 'simple', - 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'srn', 'ss', 'st', 'stq', 'su', 'sv', - 'sw', 'szl', 'ta', 'te', 'tet', 'tg', 'th', 'ti', 'ty', 'tk', 'tl', 'tn', 'to', - 'tokipona', 'tp', 'tpi', 'tr', 'ts', 'tt', 'tum', 'tw', 'udm', 'ug', 'uk', 'ur', - 'uz', 've', 'vec', 'vep', 'vi', 'vls', 'vo', 'wa', 'war', 'wo', 'wuu', 'xal', - 'xh', 'xmf', 'za', 'zea', 'zh', 'zh-classical', 'zh-cn', 'zh-yue', 'zh-min-nan', - 'zh-tw', 'zu' - ), -); + /** + * @todo this is a bit wikimedia-specific and need to find a better place for this stuff, + * such as mediawiki-config, mediawiki messages for custom orders, or somewhere. + * + * alphabetic and alphabetic revised come from: + * http://meta.wikimedia.org/w/index.php?title=MediaWiki:Interwiki_config-sorting_order-native-languagename + * http://meta.wikimedia.org/w/index.php?title=MediaWiki:Interwiki_config-sorting_order-native-languagename-firstword (revised) + * and from pywikipedia for alphabetic_sr + */ + 'interwikiSortOrders' => array( + 'alphabetic' => array( + 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an', 'arc', + 'roa-rup', 'frp', 'as', 'ast', 'gn', 'av', 'ay', 'az', 'bm', 'bn', 'bjn', + 'zh-min-nan', 'nan', 'map-bms', 'ba', 'be', 'be-x-old', 'bh', 'bcl', 'bi', + 'bg', 'bar', 'bo', 'bs', 'br', 'bxr', 'ca', 'cv', 'ceb', 'cs', 'ch', + 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'co', 'cy', 'da', 'dk', 'pdc', 'de', + 'dv', 'nv', 'dsb', 'dz', 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', + 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', + 'gag', 'gd', 'gl', 'gan', 'ki', 'glk', 'gu', 'got', 'hak', 'xal', 'ko', 'ha', + 'haw', 'hy', 'hi', 'ho', 'hsb', 'hr', 'io', 'ig', 'ilo', 'bpy', 'id', 'ia', + 'ie', 'iu', 'ik', 'os', 'xh', 'zu', 'is', 'it', 'he', 'jv', 'kl', 'kn', 'kr', + 'pam', 'krc', 'ka', 'ks', 'csb', 'kk', 'kw', 'rw', 'rn', 'sw', 'kv', 'kg', + 'ht', 'ku', 'kj', 'ky', 'mrj', 'lad', 'lbe', 'lez', 'lo', 'ltg', 'la', 'lv', + 'lb', 'lt', 'lij', 'li', 'ln', 'jbo', 'lg', 'lmo', 'hu', 'mk', 'mg', 'ml', + 'mt', 'mi', 'mr', 'xmf', 'arz', 'mzn', 'ms', 'min', 'cdo', 'mwl', 'mdf', 'mo', + 'mn', 'mus', 'my', 'nah', 'na', 'fj', 'nl', 'nds-nl', 'cr', 'ne', 'new', 'ja', + 'nap', 'ce', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov', 'ii', 'oc', 'mhr', + 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pi', 'pfl', 'pag', 'pnb', 'pap', 'ps', + 'koi', 'km', 'pcd', 'pms', 'tpi', 'nds', 'pl', 'tokipona', 'tp', 'pnt', 'pt', + 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy', 'rm', 'qu', 'rue', 'ru', 'sah', + 'se', 'sm', 'sa', 'sg', 'sc', 'sco', 'stq', 'st', 'nso', 'tn', 'sq', 'scn', + 'si', 'simple', 'sd', 'ss', 'sk', 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', + 'sh', 'su', 'fi', 'sv', 'tl', 'ta', 'shi', 'kab', 'roa-tara', 'tt', 'te', 'tet', + 'th', 'ti', 'tg', 'to', 'chr', 'chy', 've', 'tr', 'tk', 'tw', 'udm', 'bug', + 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vi', 'vo', 'fiu-vro', 'wa', 'zh-classical', + 'vls', 'war', 'wo', 'wuu', 'ts', 'yi', 'yo', 'zh-yue', 'diq', 'zea', 'bat-smg', + 'zh', 'zh-tw', 'zh-cn' + ), + 'alphabetic_revised' => array( + 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an', 'arc', 'roa-rup', + 'frp', 'as', 'ast', 'gn', 'av', 'ay', 'az', 'bjn', 'id', 'ms', 'bm', 'bn', + 'zh-min-nan', 'nan', 'map-bms', 'jv', 'su', 'ba', 'min', 'be', 'be-x-old', 'bh', + 'bcl', 'bi', 'bar', 'bo', 'bs', 'br', 'bug', 'bg', 'bxr', 'ca', 'ceb', 'cv', 'cs', + 'ch', 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'co', 'cy', 'da', 'dk', 'pdc', 'de', + 'dv', 'nv', 'dsb', 'na', 'dz', 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', + 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', 'sm', + 'gag', 'gd', 'gl', 'gan', 'ki', 'glk', 'gu', 'got', 'hak', 'xal', 'ko', 'ha', 'haw', + 'hy', 'hi', 'ho', 'hsb', 'hr', 'io', 'ig', 'ilo', 'bpy', 'ia', 'ie', 'iu', 'ik', + 'os', 'xh', 'zu', 'is', 'it', 'he', 'kl', 'kn', 'kr', 'pam', 'ka', 'ks', 'csb', + 'kk', 'kw', 'rw', 'ky', 'rn', 'mrj', 'sw', 'kv', 'kg', 'ht', 'ku', 'kj', 'lad', + 'lbe', 'lez', 'lo', 'la', 'ltg', 'lv', 'to', 'lb', 'lt', 'lij', 'li', 'ln', 'jbo', + 'lg', 'lmo', 'hu', 'mk', 'mg', 'ml', 'krc', 'mt', 'mi', 'mr', 'xmf', 'arz', 'mzn', + 'cdo', 'mwl', 'koi', 'mdf', 'mo', 'mn', 'mus', 'my', 'nah', 'fj', 'nl', 'nds-nl', + 'cr', 'ne', 'new', 'ja', 'nap', 'ce', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov', + 'ii', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pi', 'pfl', 'pag', 'pnb', + 'pap', 'ps', 'km', 'pcd', 'pms', 'nds', 'pl', 'pnt', 'pt', 'aa', 'kaa', 'crh', 'ty', + 'ksh', 'ro', 'rmy', 'rm', 'qu', 'ru', 'rue', 'sah', 'se', 'sa', 'sg', 'sc', 'sco', + 'stq', 'st', 'nso', 'tn', 'sq', 'scn', 'si', 'simple', 'sd', 'ss', 'sk', 'sl', + 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', 'sh', 'fi', 'sv', 'tl', 'ta', 'shi', + 'kab', 'roa-tara', 'tt', 'te', 'tet', 'th', 'vi', 'ti', 'tg', 'tpi', 'tokipona', + 'tp', 'chr', 'chy', 've', 'tr', 'tk', 'tw', 'udm', 'uk', 'ur', 'ug', 'za', + 'vec', 'vep', 'vo', 'fiu-vro', 'wa', 'zh-classical', 'vls', 'war', 'wo', 'wuu', + 'ts', 'yi', 'yo', 'zh-yue', 'diq', 'zea', 'bat-smg', 'zh', 'zh-tw', 'zh-cn' + ), + 'alphabetic_sr' => array( + 'ace', 'kbd', 'af', 'ak', 'als', 'am', 'ang', 'ab', 'ar', 'an', 'arc', + 'roa-rup', 'frp', 'arz', 'as', 'ast', 'gn', 'av', 'ay', 'az', 'bjn', 'id', + 'ms', 'bg', 'bm', 'zh-min-nan', 'nan', 'map-bms', 'jv', 'su', 'ba', 'be', + 'be-x-old', 'bh', 'bcl', 'bi', 'bn', 'bo', 'bar', 'bs', 'bpy', 'br', 'bug', + 'bxr', 'ca', 'ceb', 'ch', 'cbk-zam', 'sn', 'tum', 'ny', 'cho', 'chr', 'co', + 'cy', 'cv', 'cs', 'da', 'dk', 'pdc', 'de', 'nv', 'dsb', 'na', 'dv', 'dz', + 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', 'ext', 'eu', 'ee', 'fa', + 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', 'sm', 'gag', 'gd', 'gl', + 'gan', 'ki', 'glk', 'got', 'gu', 'ha', 'hak', 'xal', 'haw', 'he', 'hi', 'ho', + 'hsb', 'hr', 'hy', 'io', 'ig', 'ii', 'ilo', 'ia', 'ie', 'iu', 'ik', 'os', + 'xh', 'zu', 'is', 'it', 'ja', 'ka', 'kl', 'kr', 'pam', 'krc', 'csb', 'kk', + 'kw', 'rw', 'ky', 'mrj', 'rn', 'sw', 'km', 'kn', 'ko', 'kv', 'kg', 'ht', + 'ks', 'ku', 'kj', 'lad', 'lbe', 'la', 'ltg', 'lv', 'to', 'lb', 'lez', 'lt', + 'lij', 'li', 'ln', 'lo', 'jbo', 'lg', 'lmo', 'hu', 'mk', 'mg', 'mt', 'mi', + 'min', 'cdo', 'mwl', 'ml', 'mdf', 'mo', 'mn', 'mr', 'mus', 'my', 'mzn', 'nah', + 'fj', 'ne', 'nl', 'nds-nl', 'cr', 'new', 'nap', 'ce', 'frr', 'pih', 'no', 'nb', + 'nn', 'nrm', 'nov', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pfl', + 'pag', 'pap', 'koi', 'pi', 'pcd', 'pms', 'nds', 'pnb', 'pl', 'pt', 'pnt', + 'ps', 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy', 'rm', 'qu', 'ru', 'rue', + 'sa', 'sah', 'se', 'sg', 'sc', 'sco', 'sd', 'stq', 'st', 'nso', 'tn', 'sq', + 'si', 'scn', 'simple', 'ss', 'sk', 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', + 'sr', 'sh', 'fi', 'sv', 'ta', 'shi', 'tl', 'kab', 'roa-tara', 'tt', 'te', + 'tet', 'th', 'ti', 'vi', 'tg', 'tokipona', 'tp', 'tpi', 'chy', 've', 'tr', + 'tk', 'tw', 'udm', 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vo', 'fiu-vro', + 'wa', 'vls', 'war', 'wo', 'wuu', 'ts', 'xmf', 'yi', 'yo', 'diq', 'zea', 'zh', + 'zh-tw', 'zh-cn', 'zh-classical', 'zh-yue', 'bat-smg' + ), + 'alphabetic_fy' => array( + 'aa', 'ab', 'ace', 'af', 'ay', 'ak', 'als', 'am', 'an', 'ang', 'ar', 'arc', + 'arz', 'as', 'ast', 'av', 'az', 'ba', 'bar', 'bat-smg', 'bcl', 'be', 'be-x-old', + 'bg', 'bh', 'bi', 'bjn', 'bm', 'bn', 'bo', 'bpy', 'br', 'bs', 'bug', 'bxr', + 'ca', 'cbk-zam', 'cdo', 'ce', 'ceb', 'ch', 'chy', 'cho', 'chr', 'cy', 'ckb', + 'co', 'cr', 'crh', 'cs', 'csb', 'cu', 'cv', 'da', 'de', 'diq', 'dk', 'dsb', 'dv', + 'dz', 'ee', 'el', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'fa', 'ff', 'fi', + 'fy', 'fiu-vro', 'fj', 'fo', 'fr', 'frp', 'frr', 'fur', 'ga', 'gag', 'gan', 'gd', + 'gl', 'glk', 'gn', 'got', 'gu', 'gv', 'ha', 'hak', 'haw', 'he', 'hi', 'hy', + 'hif', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'yi', + 'ik', 'ilo', 'io', 'yo', 'is', 'it', 'iu', 'ja', 'jbo', 'jv', 'ka', 'kaa', 'kab', + 'kbd', 'kg', 'ki', 'ky', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'koi', 'kr', 'krc', + 'ks', 'ksh', 'ku', 'kv', 'kw', 'la', 'lad', 'lb', 'lbe', 'lez', 'lg', 'li', + 'lij', 'lmo', 'ln', 'lo', 'lt', 'ltg', 'lv', 'map-bms', 'mdf', 'mg', 'mh', 'mhr', + 'mi', 'my', 'min', 'myv', 'mk', 'ml', 'mn', 'mo', 'mr', 'mrj', 'ms', 'mt', 'mus', + 'mwl', 'mzn', 'na', 'nah', 'nan', 'nap', 'nds', 'nds-nl', 'ne', 'new', 'ng', 'ny', + 'nl', 'nn', 'no', 'nov', 'nrm', 'nso', 'nv', 'oc', 'om', 'or', 'os', 'pa', 'pag', + 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pi', 'pih', 'pl', 'pms', 'pnb', 'pnt', 'ps', + 'pt', 'qu', 'rm', 'rmy', 'rn', 'ro', 'roa-rup', 'roa-tara', 'ru', 'rue', 'rw', + 'sa', 'sah', 'sc', 'scn', 'sco', 'sd', 'se', 'sg', 'sh', 'shi', 'si', 'simple', + 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'srn', 'ss', 'st', 'stq', 'su', 'sv', + 'sw', 'szl', 'ta', 'te', 'tet', 'tg', 'th', 'ti', 'ty', 'tk', 'tl', 'tn', 'to', + 'tokipona', 'tp', 'tpi', 'tr', 'ts', 'tt', 'tum', 'tw', 'udm', 'ug', 'uk', 'ur', + 'uz', 've', 'vec', 'vep', 'vi', 'vls', 'vo', 'wa', 'war', 'wo', 'wuu', 'xal', + 'xh', 'xmf', 'za', 'zea', 'zh', 'zh-classical', 'zh-cn', 'zh-yue', 'zh-min-nan', + 'zh-tw', 'zu' + ), + ), + ); + + return $defaults; +} ); diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php index a1f75b4..9b6a18b 100644 --- a/lib/WikibaseLib.php +++ b/lib/WikibaseLib.php @@ -79,6 +79,8 @@ define( 'WBL_VERSION', '0.4 alpha' . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); +define( 'WBL_DIR', __DIR__ ); + $wgExtensionCredits['wikibase'][] = array( 'path' => __DIR__, 'name' => 'WikibaseLib', @@ -167,8 +169,9 @@ // Resource Loader Modules: $wgResourceModules = array_merge( $wgResourceModules, include( __DIR__ . "/resources/Resources.php" ) ); +$wgWBSettings = array(); -include_once( __DIR__ . '/config/WikibaseLib.default.php' ); +$wgValueFormatters['wikibase-entityid'] = 'Wikibase\Lib\EntityIdFormatter'; if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { include_once( __DIR__ . '/config/WikibaseLib.experimental.php' ); diff --git a/lib/config/WikibaseLib.default.php b/lib/config/WikibaseLib.default.php index 7ec0fa5..6a4aa3a 100644 --- a/lib/config/WikibaseLib.default.php +++ b/lib/config/WikibaseLib.default.php @@ -29,65 +29,65 @@ * @licence GNU GPL v2+ */ -if ( !defined( 'WBL_VERSION' ) ) { - die( 'Not an entry point.' ); -} +return call_user_func( function() { -$wgWBSettings = array(); + $defaults = array( -// alternative: application/vnd.php.serialized -$wgWBSettings['serializationFormat'] = CONTENT_FORMAT_JSON; + // alternative: application/vnd.php.serialized + 'serializationFormat' => CONTENT_FORMAT_JSON, -// whether changes get recorded to wb_changes -$wgWBSettings['useChangesTable'] = true; + // whether changes get recorded to wb_changes + 'useChangesTable' => true, -$wgWBSettings['entityPrefixes'] = array( - 'q' => \Wikibase\Item::ENTITY_TYPE, - 'p' => \Wikibase\Property::ENTITY_TYPE, -); + 'entityPrefixes' => array( + 'q' => \Wikibase\Item::ENTITY_TYPE, + 'p' => \Wikibase\Property::ENTITY_TYPE, + ), -$wgWBSettings['siteLinkGroup'] = 'wikipedia'; + 'siteLinkGroup' => 'wikipedia', -// local by default. Set to something LBFactory understands. -$wgWBSettings['changesDatabase'] = false; + // local by default. Set to something LBFactory understands. + 'changesDatabase' => false, -// JSON is more robust against version differences between repo and client, -// but only once the client can cope with the JSON form of the change. -$wgWBSettings['changesAsJson'] = true; + // JSON is more robust against version differences between repo and client, + // but only once the client can cope with the JSON form of the change. + 'changesAsJson' => true, -// list of logical database names of local client wikis. -// may contain mappings from site-id to db-name. -$wgWBSettings['localClientDatabases'] = array(); + // list of logical database names of local client wikis. + // may contain mappings from site-id to db-name. + 'localClientDatabases' => array(), -$wgWBSettings['dispatchBatchChunkFactor'] = 3; -$wgWBSettings['dispatchBatchCacheFactor'] = 3; + 'dispatchBatchChunkFactor' => 3, + 'dispatchBatchCacheFactor' => 3, -$wgWBSettings['changeHandlers'] = array( - 'wikibase-item~add' => 'Wikibase\ItemChange', - 'wikibase-property~add' => 'Wikibase\EntityChange', - 'wikibase-query~add' => 'Wikibase\EntityChange', + 'changeHandlers' => array( + 'wikibase-item~add' => 'Wikibase\ItemChange', + 'wikibase-property~add' => 'Wikibase\EntityChange', + 'wikibase-query~add' => 'Wikibase\EntityChange', - 'wikibase-item~update' => 'Wikibase\ItemChange', - 'wikibase-property~update' => 'Wikibase\EntityChange', - 'wikibase-query~update' => 'Wikibase\EntityChange', + 'wikibase-item~update' => 'Wikibase\ItemChange', + 'wikibase-property~update' => 'Wikibase\EntityChange', + 'wikibase-query~update' => 'Wikibase\EntityChange', - 'wikibase-item~remove' => 'Wikibase\ItemChange', - 'wikibase-property~remove' => 'Wikibase\EntityChange', - 'wikibase-query~remove' => 'Wikibase\EntityChange', + 'wikibase-item~remove' => 'Wikibase\ItemChange', + 'wikibase-property~remove' => 'Wikibase\EntityChange', + 'wikibase-query~remove' => 'Wikibase\EntityChange', - 'wikibase-item~refresh' => 'Wikibase\ItemChange', - 'wikibase-property~refresh' => 'Wikibase\EntityChange', - 'wikibase-query~refresh' => 'Wikibase\EntityChange', + 'wikibase-item~refresh' => 'Wikibase\ItemChange', + 'wikibase-property~refresh' => 'Wikibase\EntityChange', + 'wikibase-query~refresh' => 'Wikibase\EntityChange', - 'wikibase-item~restore' => 'Wikibase\ItemChange', - 'wikibase-property~restore' => 'Wikibase\EntityChange', - 'wikibase-query~restore' => 'Wikibase\EntityChange', -); + 'wikibase-item~restore' => 'Wikibase\ItemChange', + 'wikibase-property~restore' => 'Wikibase\EntityChange', + 'wikibase-query~restore' => 'Wikibase\EntityChange', + ), -$wgWBSettings['dataTypes'] = array( - 'wikibase-item', - 'commonsMedia', - 'string', -); + 'dataTypes' => array( + 'wikibase-item', + 'commonsMedia', + 'string', + ), + ); -$wgValueFormatters['wikibase-entityid'] = 'Wikibase\Lib\EntityIdFormatter'; \ No newline at end of file + return $defaults; +} ); diff --git a/lib/includes/Settings.php b/lib/includes/Settings.php index 35de02a..41478c4 100644 --- a/lib/includes/Settings.php +++ b/lib/includes/Settings.php @@ -30,6 +30,7 @@ * * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > + * @author Daniel Kinzler */ class Settings extends SettingsArray { @@ -46,6 +47,24 @@ if ( $instance === null ) { $settings = array(); + // load appropriate defaults ------------------- + if ( defined( 'WBL_VERSION' ) ) { + $settings = array_merge( $settings, self::loadDefaults( WBL_DIR . '/config/WikibaseLib.default.php' ) ); + } + + if ( defined( 'WB_VERSION' ) ) { + $settings = array_merge( $settings, self::loadDefaults( WB_DIR . '/config/Wikibase.default.php' ) ); + } + + if ( defined( 'WBC_VERSION' ) ) { + $settings = array_merge( $settings, self::loadDefaults( WBC_DIR . '/config/WikibaseClient.default.php' ) ); + } + + // merge appropriate settings ------------------- + if ( defined( 'WBL_VERSION' ) ) { + $settings = array_merge( $settings, $GLOBALS['wgWBSettings'] ); + } + if ( defined( 'WB_VERSION' ) ) { $settings = array_merge( $settings, $GLOBALS['wgWBRepoSettings'] ); } @@ -54,14 +73,22 @@ $settings = array_merge( $settings, $GLOBALS['wgWBClientSettings'] ); } - $settings = array_merge( $settings, $GLOBALS['wgWBSettings'] ); - $instance = new static( $settings ); } return $instance; } + protected static function loadDefaults( $path ) { + $defaults = include( $path ); + + if ( !is_array( $defaults ) ) { + throw new \MWException( "Defaults file not found: $path" ); + } + + return $defaults; + } + /** * Shortcut to ::singleton()->getSetting * diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 1a6e586..7bf7611 100755 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -50,6 +50,8 @@ define( 'WB_VERSION', '0.4 alpha' . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); +define( 'WB_DIR', __DIR__ ); + $wgExtensionCredits['wikibase'][] = array( 'path' => __DIR__, 'name' => 'Wikibase Repository', @@ -176,7 +178,7 @@ $wgWBStores['sqlstore'] = 'Wikibase\SqlStore'; -include_once( __DIR__ . '/config/Wikibase.default.php' ); +$wgWBRepoSettings = array(); if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { include_once( __DIR__ . '/config/Wikibase.experimental.php' ); diff --git a/repo/config/Wikibase.default.php b/repo/config/Wikibase.default.php index ffb2828..da4768c 100644 --- a/repo/config/Wikibase.default.php +++ b/repo/config/Wikibase.default.php @@ -29,50 +29,50 @@ * @licence GNU GPL v2+ */ -if ( !defined( 'WB_VERSION' ) ) { - die( 'Not an entry point.' ); -} +return call_user_func( function() { -$dir = __DIR__ . '/'; + $defaults = array( -$wgWBRepoSettings = array(); + // Set API in debug mode + // do not turn on in production! + 'apiInDebug' => false, -// Set API in debug mode -// do not turn on in production! -$wgWBRepoSettings['apiInDebug'] = false; + // Additional settings for API when debugging is on to + // facilitate testing. + 'apiDebugWithPost' => false, + 'apiDebugWithRights' => false, + 'apiDebugWithTokens' => false, -// Additional settings for API when debugging is on to -// facilitate testing. -$wgWBRepoSettings['apiDebugWithPost'] = false; -$wgWBRepoSettings['apiDebugWithRights'] = false; -$wgWBRepoSettings['apiDebugWithTokens'] = false; + 'defaultStore' => 'sqlstore', -$wgWBRepoSettings['defaultStore'] = 'sqlstore'; + 'idBlacklist' => array( + 1, + 23, + 42, + 1337, + 9001, + 31337, + 720101010, + ), -$wgWBRepoSettings['idBlacklist'] = array( - 1, - 23, - 42, - 1337, - 9001, - 31337, - 720101010, -); + // Allow the TermIndex table to work without the term_search_key field, + // for sites that can not easily roll out schema changes on large tables. + // This means that all searches will use exact matching + // (depending on the database's collation). + 'withoutTermSearchKey' => false, -// Allow the TermIndex table to work without the term_search_key field, -// for sites that can not easily roll out schema changes on large tables. -// This means that all searches will use exact matching -// (depending on the database's collation). -$wgWBRepoSettings['withoutTermSearchKey'] = false; + 'entityNamespaces' => array(), -$wgWBRepoSettings['entityNamespaces'] = array(); + // These are used for multilanguage strings that should have a soft length constraint + 'multilang-limits' => array( + 'length' => 250, + ), -// These are used for multilanguage strings that should have a soft length constraint -$wgWBRepoSettings['multilang-limits'] = array( - 'length' => 250, -); + 'multilang-truncate-length' => 32, -$wgWBRepoSettings['multilang-truncate-length'] = 32; + // Should the page names (titles) be normalized against the external site + 'normalizeItemByTitlePageNames' => false, + ); -// Should the page names (titles) be normalized against the external site -$wgWBRepoSettings['normalizeItemByTitlePageNames'] = false; + return $defaults; +} ); -- To view, visit https://gerrit.wikimedia.org/r/62815 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I14422cd85a3cf0200ea89953251b78b6b8d813cb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits