r53499 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53498‎ | r53499 | r53500 >
Date:23:31, 19 July 2009
Author:minuteelectron
Status:deferred
Tags:
Comment:
Consolidate OmegaWiki patches in to one file and update readme to note these are now targetted at r40000.
Modified paths:
  • /trunk/extensions/Wikidata/patches/ArticleHandlerClassSupport.diff (deleted) (history)
  • /trunk/extensions/Wikidata/patches/DefaultGoPrefix.diff (deleted) (history)
  • /trunk/extensions/Wikidata/patches/EditPageHandlerClassSupport.diff (deleted) (history)
  • /trunk/extensions/Wikidata/patches/LinkTrail.diff (deleted) (history)
  • /trunk/extensions/Wikidata/patches/OmegaWiki.diff (added) (history)
  • /trunk/extensions/Wikidata/patches/PageHistoryHandlerClassSupport.diff (deleted) (history)
  • /trunk/extensions/Wikidata/patches/PreventMovingHandlerNamespaces.diff (deleted) (history)
  • /trunk/extensions/Wikidata/patches/README.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/patches/DefaultGoPrefix.diff
@@ -1,74 +0,0 @@
2 -Index: includes/SearchEngine.php
3 -===================================================================
4 -+++ includes/SearchEngine.php (revision 19785)
5 -@@ -49,7 +49,7 @@
6 - * @private
7 - */
8 - function getNearMatch( $searchterm ) {
9 -- global $wgContLang;
10 -+ global $wgContLang, $wgDefaultGoPrefix;
11 -
12 - $allSearchTerms = array($searchterm);
13 -
14 -@@ -68,6 +68,10 @@
15 - return $title;
16 - }
17 -
18 -+ if( !empty( $wgDefaultGoPrefix ) && $title->getNamespace == NS_MAIN ) {
19 -+ $term = $wgDefaultGoPrefix . $term;
20 -+ }
21 -+
22 - # Now try all lower case (i.e. first letter capitalized)
23 - #
24 - $title = Title::newFromText( $wgContLang->lc( $term ) );
25 -Index: includes/DefaultSettings.php
26 -===================================================================
27 -+++ includes/DefaultSettings.php (revision 19785)
28 -@@ -2476,5 +2476,11 @@
29 - *
30 - */
31 - $wgCustomHandlerPath = array('*'=>"{$IP}/extensions/");
32 -+
33 -+/*
34 -+ * Prefix to be added before "Go" searches, e.g. point to a different
35 -+ * namespace.
36 -+ */
37 -+$wgDefaultGoPrefix = '';
38 -
39 - ?>
40 -Index: includes/SearchEngine.php
41 -===================================================================
42 -+++ includes/SearchEngine.php (revision 49949)
43 -@@ -63,15 +63,24 @@
44 - $title = Title::newFromText( $term );
45 - if (is_null($title))
46 - return NULL;
47 -+ if ( $title->exists() ) {
48 -+ return $title;
49 -+ }
50 -
51 -- if ( $title->getNamespace() == NS_SPECIAL || $title->exists() ) {
52 -+ if ( $title->getNamespace() == NS_SPECIAL ) {
53 - return $title;
54 - }
55 -
56 -- if(!empty($wgDefaultGoPrefix) && $title->getNamespace() == NS_MAIN ) {
57 -- $term=$wgDefaultGoPrefix.$term;
58 -- }
59 --
60 -+ if( !empty($wgDefaultGoPrefix) && $title->getNamespace() == NS_MAIN ) {
61 -+ # if no NS was specified in the query : search the "Expression:" NS
62 -+ $term = $wgDefaultGoPrefix . $term;
63 -+
64 -+ $title = Title::newFromText( $term );
65 -+ if( $title->exists() ) {
66 -+ return $title;
67 -+ }
68 -+ }
69 -+
70 - # Now try all lower case (i.e. first letter capitalized)
71 - #
72 - $title = Title::newFromText( $wgContLang->lc( $term ) );
Index: trunk/extensions/Wikidata/patches/LinkTrail.diff
@@ -1,58 +0,0 @@
2 -Index: includes/SkinTemplate.php
3 -===================================================================
4 -+++ includes/SkinTemplate.php (revision 22408)
5 -@@ -631,6 +631,7 @@
6 - */
7 - function buildContentActionUrls () {
8 - global $wgContLang, $wgOut;
9 -+
10 - $fname = 'SkinTemplate::buildContentActionUrls';
11 - wfProfileIn( $fname );
12 -
13 -@@ -691,10 +692,11 @@
14 - wfProfileIn( "$fname-live" );
15 - if ( $this->mTitle->getArticleId() ) {
16 -
17 -+ wfRunHooks( 'GetHistoryLinkTrail', array( &$trail ) );
18 - $content_actions['history'] = array(
19 - 'class' => ($action == 'history') ? 'selected' : false,
20 - 'text' => wfMsg('history_short'),
21 -- 'href' => $this->mTitle->getLocalUrl( 'action=history')
22 -+ 'href' => $this->mTitle->getLocalUrl( 'action=history' . $trail )
23 - );
24 -
25 - if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
26 -Index: includes/Skin.php
27 -===================================================================
28 -+++ includes/Skin.php (revision 22408)
29 -@@ -1242,11 +1242,12 @@
30 - */
31 - function editUrlOptions() {
32 - global $wgArticle;
33 --
34 -+ $trail = '';
35 -+ wfRunHooks( 'GetEditLinkTrail', array( &$trail ) );
36 - if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
37 -- return "action=edit&oldid=" . intval( $this->mRevisionId );
38 -+ return 'action=edit' . $trail . '&oldid=' . intval( $this->mRevisionId );
39 - } else {
40 -- return "action=edit";
41 -+ return 'action=edit' . $trail;
42 - }
43 - }
44 -
45 -@@ -1318,9 +1319,10 @@
46 -
47 - function historyLink() {
48 - global $wgTitle;
49 --
50 -+ $trail = '';
51 -+ wfRunHooks( 'GetHistoryLinkTrail', array( &$trail ) );
52 - return $this->makeKnownLinkObj( $wgTitle,
53 -- wfMsg( 'history' ), 'action=history' );
54 -+ wfMsg( 'history' ), 'action=history' . $trail );
55 - }
56 -
57 - function whatLinksHere() {
Index: trunk/extensions/Wikidata/patches/PageHistoryHandlerClassSupport.diff
@@ -1,27 +0,0 @@
2 -Index: includes/PageHistory.php
3 -===================================================================
4 -+++ includes/PageHistory.php (revision 19784)
5 -@@ -59,6 +59,22 @@
6 - $fname = 'PageHistory::history';
7 - wfProfileIn( $fname );
8 -
9 -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
10 -+ $namespaceId = $this->mTitle->getNamespace();
11 -+ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
12 -+ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
13 -+ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
14 -+ if( file_exists( $handlerFile ) ) {
15 -+ require_once $handlerFile;
16 -+ $handlerInstance = new $handlerClass();
17 -+ $handlerInstance->history();
18 -+ return;
19 -+ } else {
20 -+ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
21 -+ $handlerFile, $wgContLang->getFormattedNsText( $namespaceId ) );
22 -+ }
23 -+ }
24 -+
25 - /*
26 - * Setup page variables.
27 - */
Index: trunk/extensions/Wikidata/patches/PreventMovingHandlerNamespaces.diff
@@ -1,15 +0,0 @@
2 -Index: includes/Namespace.php
3 -===================================================================
4 -+++ includes/Namespace.php (revision 31818)
5 -@@ -175,7 +175,9 @@
6 - * @return bool
7 - */
8 - function isMovable() {
9 -- return $this->isMovable;
10 -+ #return $this->isMovable;
11 -+ # FIXME: This means that classes with custom handlers are assumed to never be movable
12 -+ return $this->isMovable && empty($this->handlerClass);
13 - }
14 -
15 - /**
Index: trunk/extensions/Wikidata/patches/EditPageHandlerClassSupport.diff
@@ -1,28 +0,0 @@
2 -Index: EditPage.php
3 -===================================================================
4 -+++ EditPage.php (revision 22410)
5 -@@ -342,6 +342,23 @@
6 - wfProfileOut( $fname );
7 - return;
8 - }
9 -+
10 -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
11 -+ $namespaceId = $this->mTitle->getNamespace();
12 -+ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
13 -+ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
14 -+ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
15 -+ if( file_exists( $handlerFile ) ) {
16 -+ require_once $handlerFile;
17 -+ $handlerInstance = new $handlerClass();
18 -+ $handlerInstance->edit();
19 -+ return;
20 -+ } else {
21 -+ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
22 -+ $handlerFile, $wgContLang->getFormattedNsText( $namespaceId ) );
23 -+ }
24 -+ }
25 -+
26 - if ( wfReadOnly() ) {
27 - wfDebug( "$fname: read-only mode is engaged\n" );
28 - if( $this->save || $this->preview ) {
Index: trunk/extensions/Wikidata/patches/ArticleHandlerClassSupport.diff
@@ -1,35 +0,0 @@
2 -Index: includes/Article.php
3 -===================================================================
4 -+++ includes/Article.php (revision 19784)
5 -@@ -604,13 +604,28 @@
6 - function view() {
7 - global $wgUser, $wgOut, $wgRequest, $wgContLang;
8 - global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
9 -- global $wgUseTrackbacks, $wgNamespaceRobotPolicies;
10 -+ global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgTitle;
11 - $sk = $wgUser->getSkin();
12 -
13 - wfProfileIn( __METHOD__ );
14 -
15 -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
16 -+ $namespaceId = $this->mTitle->getNamespace();
17 -+ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
18 -+ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
19 -+ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
20 -+ if( file_exists( $handlerFile ) ) {
21 -+ require_once $handlerFile;
22 -+ $handlerInstance = new $handlerClass();
23 -+ $handlerInstance->view();
24 -+ return;
25 -+ } else {
26 -+ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
27 -+ $handlerFile, $wgContLang->getFormattedNsText( $namespaceId ) );
28 -+ }
29 -+ }
30 -+
31 - $parserCache =& ParserCache::singleton();
32 -- $ns = $this->mTitle->getNamespace(); # shortcut
33 -
34 - # Get variables from query string
35 - $oldid = $this->getOldID();
Index: trunk/extensions/Wikidata/patches/OmegaWiki.diff
@@ -0,0 +1,253 @@
 2+Index: maintenance/updaters.inc
 3+===================================================================
 4+--- maintenance/updaters.inc (revision 40000)
 5+@@ -864,7 +864,7 @@
 6+ * @bug 3946
 7+ */
 8+ function do_page_random_update() {
 9+- global $wgDatabase;
 10++ /*global $wgDatabase;
 11+
 12+ echo "Setting page_random to a random value on rows where it equals 0...";
 13+
 14+@@ -872,7 +872,7 @@
 15+ $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' );
 16+ $rows = $wgDatabase->affectedRows();
 17+
 18+- echo "changed $rows rows\n";
 19++ echo "changed $rows rows\n";*/
 20+ }
 21+
 22+ function do_templatelinks_update() {
 23+@@ -1172,7 +1172,7 @@
 24+ }
 25+
 26+ function do_category_population() {
 27+- if( update_row_exists( 'populate category' ) ) {
 28++ /*if( update_row_exists( 'populate category' ) ) {
 29+ echo "...category table already populated.\n";
 30+ return;
 31+ }
 32+@@ -1182,7 +1182,7 @@
 33+ "may want to hit Ctrl-C and do this manually with maintenance/\n".
 34+ "populateCategory.php.\n";
 35+ populateCategory( '', 10, 0, true );
 36+- echo "Done populating category table.\n";
 37++ echo "Done populating category table.\n";*/
 38+ }
 39+
 40+ function do_populate_parent_id() {
 41+Index: includes/Article.php
 42+===================================================================
 43+--- includes/Article.php (revision 40000)
 44+@@ -684,14 +684,29 @@
 45+ function view() {
 46+ global $wgUser, $wgOut, $wgRequest, $wgContLang;
 47+ global $wgEnableParserCache, $wgStylePath, $wgParser;
 48+- global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
 49++ global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies, $wgTitle;
 50+ global $wgDefaultRobotPolicy;
 51+ $sk = $wgUser->getSkin();
 52+
 53+ wfProfileIn( __METHOD__ );
 54+
 55++ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
 56++ $ns = $this->mTitle->getNamespace();
 57++ if( array_key_exists( $ns, $wgWikiDataHandlerClasses ) ) {
 58++ $handlerClass = $wgWikiDataHandlerClasses[ $ns ];
 59++ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
 60++ if( file_exists( $handlerFile ) ) {
 61++ require_once $handlerFile;
 62++ $handlerInstance = new $handlerClass();
 63++ $handlerInstance->view();
 64++ return;
 65++ } else {
 66++ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
 67++ $handlerFile, $wgContLang->getFormattedNsText( $ns ) );
 68++ }
 69++ }
 70++
 71+ $parserCache = ParserCache::singleton();
 72+- $ns = $this->mTitle->getNamespace(); # shortcut
 73+
 74+ # Get variables from query string
 75+ $oldid = $this->getOldID();
 76+Index: includes/SearchEngine.php
 77+===================================================================
 78+--- includes/SearchEngine.php (revision 40000)
 79+@@ -51,7 +51,7 @@
 80+ * @return Title
 81+ */
 82+ public static function getNearMatch( $searchterm ) {
 83+- global $wgContLang;
 84++ global $wgContLang, $wgDefaultGoPrefix;
 85+
 86+ $allSearchTerms = array($searchterm);
 87+
 88+@@ -71,6 +71,16 @@
 89+ return $title;
 90+ }
 91+
 92++ # Attempt search with default go prefix.
 93++ if( !empty($wgDefaultGoPrefix) && $title->getNamespace() == NS_MAIN ) {
 94++ $term = $wgDefaultGoPrefix . $term;
 95++ $title = Title::newFromText( $term );
 96++ if( $title->exists() ) {
 97++ return $title;
 98++ }
 99++ }
 100++
 101++
 102+ # Now try all lower case (i.e. first letter capitalized)
 103+ #
 104+ $title = Title::newFromText( $wgContLang->lc( $term ) );
 105+Index: includes/EditPage.php
 106+===================================================================
 107+--- includes/EditPage.php (revision 40000)
 108+@@ -422,6 +422,24 @@
 109+ wfProfileOut( __METHOD__ );
 110+ return;
 111+ } else {
 112++
 113++ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
 114++ $namespaceId = $this->mTitle->getNamespace();
 115++ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
 116++ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
 117++ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
 118++ if( file_exists( $handlerFile ) ) {
 119++ require_once $handlerFile;
 120++ $handlerInstance = new $handlerClass();
 121++ $handlerInstance->edit();
 122++ return;
 123++ } else {
 124++ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
 125++ $handlerFie, $wgContLang->getFormattedNsText( $namespaceId ) );
 126++ }
 127++ }
 128++
 129++
 130+ if ( $this->save ) {
 131+ $this->formtype = 'save';
 132+ } else if( $this->preview ) {
 133+Index: includes/api/ApiMain.php
 134+===================================================================
 135+--- includes/api/ApiMain.php (revision 40000)
 136+@@ -62,7 +62,9 @@
 137+ 'expandtemplates' => 'ApiExpandTemplates',
 138+ 'parse' => 'ApiParse',
 139+ 'opensearch' => 'ApiOpenSearch',
 140++ 'query' => 'ApiQuery',
 141+ 'feedwatchlist' => 'ApiFeedWatchlist',
 142++ 'wikidata' => 'ApiWikiData',
 143+ 'help' => 'ApiHelp',
 144+ 'paraminfo' => 'ApiParamInfo',
 145+ );
 146+Index: includes/Namespace.php
 147+===================================================================
 148+--- includes/Namespace.php (revision 40000)
 149+@@ -52,7 +52,9 @@
 150+ * @return bool
 151+ */
 152+ public static function isMovable( $index ) {
 153+- global $wgAllowImageMoving;
 154++ global $wgAllowImageMoving, $wgWikiDataHandlerClasses;
 155++ # FIXME: This means that namespaces with custom handlers are assumed to never be movable.
 156++ if( array_key_exists( $index, $wgWikiDataHandlerClasses ) ) return false;
 157+ return !( $index < NS_MAIN || ($index == NS_IMAGE && !$wgAllowImageMoving) || $index == NS_CATEGORY );
 158+ }
 159+
 160+Index: includes/SkinTemplate.php
 161+===================================================================
 162+--- includes/SkinTemplate.php (revision 40000)
 163+@@ -706,10 +706,11 @@
 164+ wfProfileIn( __METHOD__."-live" );
 165+ if ( $this->mTitle->exists() ) {
 166+
 167++ wfRunHooks( 'GetHistoryLinkTrail', array( &$trail ) );
 168+ $content_actions['history'] = array(
 169+ 'class' => ($action == 'history') ? 'selected' : false,
 170+ 'text' => wfMsg('history_short'),
 171+- 'href' => $this->mTitle->getLocalUrl( 'action=history')
 172++ 'href' => $this->mTitle->getLocalUrl( 'action=history' . $trail )
 173+ );
 174+
 175+ if( $wgUser->isAllowed('delete') ) {
 176+Index: includes/DefaultSettings.php
 177+===================================================================
 178+--- includes/DefaultSettings.php (revision 40000)
 179+@@ -3389,3 +3389,9 @@
 180+ * Requires memcached.
 181+ */
 182+ $wgPasswordAttemptThrottle = array( 'count' => 5, 'seconds' => 300 );
 183++
 184++/*
 185++ * Prefix to be added before "Go" searches, e.g. point to a different
 186++ * namespace.
 187++ */
 188++$wgDefaultGoPrefix = '';
 189+Index: includes/PageHistory.php
 190+===================================================================
 191+--- includes/PageHistory.php (revision 40000)
 192+@@ -79,6 +79,22 @@
 193+
 194+ wfProfileIn( __METHOD__ );
 195+
 196++ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
 197++ $namespaceId = $this->mTitle->getNamespace();
 198++ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
 199++ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
 200++ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
 201++ if( file_exists( $handlerFile ) ) {
 202++ require_once $handlerFile;
 203++ $handlerInstance = new $handlerClass();
 204++ $handlerInstance->history();
 205++ return;
 206++ } else {
 207++ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
 208++ $handlerFile, $wgContLang->getFormattedNsText( $namespaceId ) );
 209++ }
 210++ }
 211++
 212+ /*
 213+ * Setup page variables.
 214+ */
 215+Index: includes/Skin.php
 216+===================================================================
 217+--- includes/Skin.php (revision 40000)
 218+@@ -1465,10 +1465,12 @@
 219+ function editUrlOptions() {
 220+ global $wgArticle;
 221+
 222++ $trail = '';
 223++ wfRunHooks( 'GetEditLinkTrail', array( &$trail ) );
 224+ if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
 225+- return "action=edit&oldid=" . intval( $this->mRevisionId );
 226++ return 'action=edit' . $trail . '&oldid=' . intval( $this->mRevisionId );
 227+ } else {
 228+- return "action=edit";
 229++ return 'action=edit' . $trail;
 230+ }
 231+ }
 232+
 233+@@ -1541,8 +1543,10 @@
 234+ function historyLink() {
 235+ global $wgTitle;
 236+
 237++ $trail = '';
 238++ wfRunHooks( 'GetHistoryLinkTrail', array( &$trail ) );
 239+ return $this->makeKnownLinkObj( $wgTitle,
 240+- wfMsg( 'history' ), 'action=history' );
 241++ wfMsg( 'history' ), 'action=history' . $trail );
 242+ }
 243+
 244+ function whatLinksHere() {
Index: trunk/extensions/Wikidata/patches/README.txt
@@ -1,14 +1,6 @@
2 -This is a set of patches that will allow you to run the Wikidata extension on
3 -MediaWiki trunk r19772 (i.e. outside of the Wikidata branch). This enables the
4 -extension to be gradually upgraded to the latest version of MediaWiki.
 2+This is a patch that will allow you to run the Wikidata extension on MediaWiki
 3+trunk r32000 (i.e. outside of the Wikidata branch).
54
6 -Currently the API is not working, however when the code is in a state where when
7 -it is run on latest trunk the API stuff will essentially "fix itself".
8 -
9 -The following will also need to be added to LocalSettings.php on OmegaWiki (to
10 -replace the database namespace manager). $wgNamespaceAliases will begin
11 -working when the core code reaches r21720.
12 -
135 $wgExtraNamespaces = array(
146 16 => 'Expression',
157 17 => 'Expression_talk',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40000use $wgDBtype in updateLB methodnad01:37, 26 August 2008

Status & tagging log