r12612 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12611‎ | r12612 | r12613 >
Date:19:33, 11 January 2006
Author:magnus_manske
Status:old
Tags:
Comment:
Moving more stuff to Wiki.php
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/index.php
@@ -27,7 +27,7 @@
2828 require_once( './includes/Defines.php' );
2929
3030 if( !file_exists( 'LocalSettings.php' ) ) {
31 - $IP = "." ;
 31+ $IP = ".";
3232 require_once( 'includes/DefaultSettings.php' ); # used for printing the version
3333 ?>
3434 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -71,6 +71,11 @@
7272 require_once( './LocalSettings.php' );
7373 require_once( 'includes/Setup.php' );
7474
 75+
 76+# Initialize MediaWiki base class
 77+require_once( "includes/Wiki.php" );
 78+$mediaWiki = new MediaWiki();
 79+
7580 wfProfileIn( 'main-misc-setup' );
7681 OutputPage::setEncodings(); # Not really used yet
7782
@@ -78,31 +83,13 @@
7984 $action = $wgRequest->getVal( 'action', 'view' );
8085 $title = $wgRequest->getVal( 'title' );
8186
82 -if ($wgRequest->getVal( 'printable' ) == 'yes') {
83 - $wgOut->setPrintable();
 87+$wgTitle = $mediaWiki->checkInitialQueries( $title,$action,$wgOut, $wgRequest, $wgContLang );
 88+if ($wgTitle == NULL) {
 89+ unset( $wgTitle );
8490 }
8591
86 -if ( '' == $title && 'delete' != $action ) {
87 - $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
88 -} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
89 - # URLs like this are generated by RC, because rc_title isn't always accurate
90 - $wgTitle = Title::newFromID( $curid );
91 -} else {
92 - $wgTitle = Title::newFromURL( $title );
93 - /* check variant links so that interwiki links don't have to worry about
94 - the possible different language variants
95 - */
96 - if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
97 - $wgContLang->findVariantLink( $title, $wgTitle );
98 -
99 -}
10092 wfProfileOut( 'main-misc-setup' );
10193
102 -
103 -# Initialize MediaWiki base class
104 -require_once( "includes/Wiki.php" );
105 -$mediaWiki = new MediaWiki();
106 -
10794 # Setting global variables in mediaWiki
10895 $mediaWiki->setVal( "Server", $wgServer );
10996 $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch );
@@ -115,7 +102,7 @@
116103 $mediaWiki->setVal( "DisabledActions", $wgDisabledActions );
117104
118105 $wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest );
119 -$mediaWiki->finalCleanup ( $wgDeferredUpdateList , $wgLoadBalancer , $wgOut ) ;
 106+$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgLoadBalancer, $wgOut );
120107
121108 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
122109 $mediaWiki->doUpdates( $wgPostCommitUpdateList );
Index: trunk/phase3/includes/Wiki.php
@@ -40,9 +40,9 @@
4141 * Initialization of ... everything
4242 @return Article either the object to become $wgArticle, or NULL
4343 */
44 - function initialize ( &$title, &$output, &$user, $request ) {
 44+ function initialize ( &$title, &$output, &$user, $request) {
4545 wfProfileIn( 'MediaWiki::initialize' );
46 - $this->preliminaryChecks ( $title , $output , $request ) ;
 46+ $this->preliminaryChecks ( $title, $output, $request ) ;
4747 $article = NULL;
4848 if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
4949 $article = $this->initializeArticle( $title, $request );
@@ -52,8 +52,40 @@
5353 return $article;
5454 }
5555
56 - function preliminaryChecks ( &$title , &$output , $request ) {
 56+ /**
 57+ * Checks some initial queries
 58+ * Note that $title here is *not* a Title object, but a string!
 59+ */
 60+ function checkInitialQueries( $title,$action,&$output,$request, $lang) {
 61+ if ($request->getVal( 'printable' ) == 'yes') {
 62+ $output->setPrintable();
 63+ }
 64+
 65+ $ret = NULL ;
 66+
 67+
 68+ if ( '' == $title && 'delete' != $action ) {
 69+ $ret = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 70+ } elseif ( $curid = $request->getInt( 'curid' ) ) {
 71+ # URLs like this are generated by RC, because rc_title isn't always accurate
 72+ $ret = Title::newFromID( $curid );
 73+ } else {
 74+ $ret = Title::newFromURL( $title );
 75+ /* check variant links so that interwiki links don't have to worry about
 76+ the possible different language variants
 77+ */
 78+ if( count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0 )
 79+ $lang->findVariantLink( $title, $ret );
 80+
 81+ }
 82+ return $ret ;
 83+ }
5784
 85+ /**
 86+ * Checks for search query and anon-cannot-read case
 87+ */
 88+ function preliminaryChecks ( &$title, &$output, $request ) {
 89+
5890 # Debug statement for user levels
5991 // print_r($wgUser);
6092
@@ -174,7 +206,7 @@
175207 /**
176208 * Cleaning up by doing deferred updates, calling loadbalancer and doing the output
177209 */
178 - function finalCleanup ( &$deferredUpdates , &$loadBalancer , &$output ) {
 210+ function finalCleanup ( &$deferredUpdates, &$loadBalancer, &$output ) {
179211 wfProfileIn( 'MediaWiki::finalCleanup' );
180212 $this->doUpdates( $deferredUpdates );
181213 $loadBalancer->saveMasterPos();

Follow-up revisions

RevisionCommit summaryAuthorDate
r77975* Don't unset $wgTitle if it's null, just let it as is so that the variable i...ialex12:35, 7 December 2010

Status & tagging log