r12283 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12282‎ | r12283 | r12284 >
Date:10:50, 29 December 2005
Author:magnus_manske
Status:old
Tags:
Comment:
finishing moving of code from inex.php to includes/Wiki.php
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/index.php
@@ -64,87 +64,10 @@
6565 require_once( './LocalSettings.php' );
6666 require_once( 'includes/Setup.php' );
6767
68 -wfProfileIn( 'main-misc-setup' );
69 -OutputPage::setEncodings(); # Not really used yet
70 -
71 -
7268 # The wiki action class
7369 require_once ( "includes/Wiki.php" ) ;
7470 $wgTheWiki = new MediaWikiType ;
7571
76 -
77 -# Query string fields
78 -$action = $wgRequest->getVal( 'action', 'view' );
79 -$title = $wgRequest->getVal( 'title' );
80 -
81 -if ($wgRequest->getVal( 'printable' ) == 'yes') {
82 - $wgOut->setPrintable();
83 -}
84 -
85 -if ( '' == $title && 'delete' != $action ) {
86 - $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
87 -} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
88 - # URLs like this are generated by RC, because rc_title isn't always accurate
89 - $wgTitle = Title::newFromID( $curid );
90 -} else {
91 - $wgTitle = Title::newFromURL( $title );
92 - /* check variant links so that interwiki links don't have to worry about
93 - the possible different language variants
94 - */
95 - if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
96 - $wgContLang->findVariantLink( $title, $wgTitle );
97 -
98 -}
99 -wfProfileOut( 'main-misc-setup' );
100 -
101 -# Debug statement for user levels
102 -// print_r($wgUser);
103 -
104 -$search = $wgRequest->getText( 'search' );
105 -if( !is_null( $search ) && $search !== '' ) {
106 - // Compatibility with old search URLs which didn't use Special:Search
107 - // Do this above the read whitelist check for security...
108 - $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
109 -}
110 -
111 -# If the user is not logged in, the Namespace:title of the article must be in
112 -# the Read array in order for the user to see it. (We have to check here to
113 -# catch special pages etc. We check again in Article::view())
114 -if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
115 - $wgOut->loginToUse();
116 - $wgOut->output();
117 - exit;
118 -}
119 -
120 -
121 -$wgTheWiki->mSearch = $search ;
122 -$wgTheWiki->main_action () ;
123 -# $search = $wgTheWiki->mSearch ; # Not needed
124 -
125 -
126 -# Deferred updates aren't really deferred anymore. It's important to report errors to the
127 -# user, and that means doing this before OutputPage::output(). Note that for page saves,
128 -# the client will wait until the script exits anyway before following the redirect.
129 -wfProfileIn( 'main-updates' );
130 -foreach ( $wgDeferredUpdateList as $up ) {
131 - $up->doUpdate();
132 -}
133 -wfProfileOut( 'main-updates' );
134 -
135 -wfProfileIn( 'main-cleanup' );
136 -$wgLoadBalancer->saveMasterPos();
137 -
138 -# Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
139 -$wgLoadBalancer->commitAll();
140 -
141 -$wgOut->output();
142 -
143 -foreach ( $wgPostCommitUpdateList as $up ) {
144 - $up->doUpdate();
145 -}
146 -
147 -wfProfileOut( 'main-cleanup' );
148 -
14972 logProfilingData();
15073 $wgLoadBalancer->closeAll();
15174 wfDebug( "Request ended normally\n" );
Index: trunk/phase3/includes/Wiki.php
@@ -4,7 +4,105 @@
55 #wiki class
66
77 class MediaWikiType {
 8+
 9+ var $mSearch ;
 10+
 11+ /**
 12+ * Constuctor
 13+ */
 14+ function MediaWikiType () {
 15+ OutputPage::setEncodings(); # Not really used yet
816
 17+ $this->main_setup () ;
 18+ $this->check_search () ;
 19+ $this->check_user_read () ;
 20+ $this->main_action () ;
 21+ $this->main_updates () ;
 22+ $this->main_cleanup () ;
 23+ }
 24+
 25+ function check_search () {
 26+ global $wgRequest , $wgTitle ;
 27+ $this->mSearch = $wgRequest->getText( 'search' );
 28+ if( !is_null( $this->mSearch ) && $this->mSearch !== '' ) {
 29+ // Compatibility with old search URLs which didn't use Special:Search
 30+ // Do this above the read whitelist check for security...
 31+ $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
 32+ }
 33+ }
 34+
 35+ function check_user_read () {
 36+ global $wgTitle , $wgOut ;
 37+ # If the user is not logged in, the Namespace:title of the article must be in
 38+ # the Read array in order for the user to see it. (We have to check here to
 39+ # catch special pages etc. We check again in Article::view())
 40+ if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
 41+ $wgOut->loginToUse();
 42+ $wgOut->output();
 43+ exit;
 44+ }
 45+ }
 46+
 47+
 48+ function main_setup () {
 49+ global $wgRequest , $wgOut , $wgTitle , $wgContLang ;
 50+ global $action , $title ;
 51+ wfProfileIn( 'main-misc-setup' );
 52+
 53+ # Query string fields
 54+ $action = $wgRequest->getVal( 'action', 'view' );
 55+ $title = $wgRequest->getVal( 'title' );
 56+
 57+ if ($wgRequest->getVal( 'printable' ) == 'yes') {
 58+ $wgOut->setPrintable();
 59+ }
 60+
 61+ if ( '' == $title && 'delete' != $action ) {
 62+ $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 63+ } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
 64+ # URLs like this are generated by RC, because rc_title isn't always accurate
 65+ $wgTitle = Title::newFromID( $curid );
 66+ } else {
 67+ $wgTitle = Title::newFromURL( $title );
 68+ /* check variant links so that interwiki links don't have to worry about
 69+ the possible different language variants
 70+ */
 71+ if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
 72+ $wgContLang->findVariantLink( $title, $wgTitle );
 73+
 74+ }
 75+ wfProfileOut( 'main-misc-setup' );
 76+ }
 77+
 78+ function main_updates () {
 79+ # Deferred updates aren't really deferred anymore. It's important to report errors to the
 80+ # user, and that means doing this before OutputPage::output(). Note that for page saves,
 81+ # the client will wait until the script exits anyway before following the redirect.
 82+ wfProfileIn( 'main-updates' );
 83+ global $wgDeferredUpdateList ;
 84+ foreach ( $wgDeferredUpdateList as $up ) {
 85+ $up->doUpdate();
 86+ }
 87+ wfProfileOut( 'main-updates' );
 88+ }
 89+
 90+ function main_cleanup () {
 91+ global $wgLoadBalancer , $wgOut , $wgPostCommitUpdateList ;
 92+ wfProfileIn( 'main-cleanup' );
 93+ $wgLoadBalancer->saveMasterPos();
 94+
 95+ # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
 96+ $wgLoadBalancer->commitAll();
 97+
 98+ $wgOut->output();
 99+
 100+ foreach ( $wgPostCommitUpdateList as $up ) {
 101+ $up->doUpdate();
 102+ }
 103+
 104+ wfProfileOut( 'main-cleanup' );
 105+ }
 106+
9107 function main_action () {
10108 global $wgTitle , $wgArticle , $wgRequest , $wgOut , $wgServer ;
11109 global $wgDisableInternalSearch , $wgUseCategoryMagic , $wgDisabledActions , $action ;

Status & tagging log