Some cleanup to Article::view() and related:
[lhc/web/wiklou.git] / includes / WikiPage.php
index 4bc7873..9b7a02c 100644 (file)
@@ -24,21 +24,21 @@ class WikiPage extends Page {
        public $mCounter = -1;               // !< Integer (-1 means "not loaded")
        public $mDataLoaded = false;         // !< Boolean
        public $mIsRedirect = false;         // !< Boolean
-       public $mLatest = false;             // !< Boolean
+       public $mLatest = false;             // !< Integer (false means "not loaded")
        public $mPreparedEdit = false;           // !< Array
 
        /**
         * @var Title
         */
-       public $mRedirectTarget = null;
+       protected $mRedirectTarget = null;
 
        /**
         * @var Revision
         */
-       public $mLastRevision = null;
+       protected $mLastRevision = null;
 
-       public $mTimestamp = '';             // !< String
-       public $mTouched = '19700101000000'; // !< String
+       protected $mTimestamp = '';             // !< String
+       protected $mTouched = '19700101000000'; // !< String
        /**@}}*/
 
        /**
@@ -205,7 +205,7 @@ class WikiPage extends Page {
                                        return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) );
                                }
                        } else {
-                               if ( $rt->getNamespace() == NS_SPECIAL ) {
+                               if ( $rt->isSpecialPage() ) {
                                        // Gotta handle redirects to special pages differently:
                                        // Fill the HTTP response "Location" header and ignore
                                        // the rest of the page we're on.
@@ -718,7 +718,7 @@ class WikiPage extends Page {
                return $wgEnableParserCache
                        && $user->getStubThreshold() == 0
                        && $this->exists()
-                       && empty( $oldid )
+                       && ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
                        && $this->mTitle->isWikitextPage();
        }
 
@@ -977,9 +977,11 @@ class WikiPage extends Page {
                        if ( $section == 'new' ) {
                                # Inserting a new section
                                $subject = $summary ? wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" : '';
-                               $text = strlen( trim( $oldtext ) ) > 0
+                               if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
+                                       $text = strlen( trim( $oldtext ) ) > 0
                                                ? "{$oldtext}\n\n{$subject}{$text}"
                                                : "{$subject}{$text}";
+                               }
                        } else {
                                # Replacing an existing section; roll out the big guns
                                global $wgParser;
@@ -1529,10 +1531,6 @@ class WikiPage extends Page {
         */
        public function estimateRevisionCount() {
                $dbr = wfGetDB( DB_SLAVE );
-
-               // For an exact count...
-               // return $dbr->selectField( 'revision', 'COUNT(*)',
-               //      array( 'rev_page' => $this->getId() ), __METHOD__ );
                return $dbr->estimateRowCount( 'revision', '*',
                        array( 'rev_page' => $this->getId() ), __METHOD__ );
        }
@@ -1760,6 +1758,8 @@ class WikiPage extends Page {
         * roll back to, e.g. user is the sole contributor. This function
         * performs permissions checks on $user, then calls commitRollback()
         * to do the dirty work
+        * 
+        * @todo: seperate the business/permission stuff out from backend code
         *
         * @param $fromP String: Name of the user whose edits to rollback.
         * @param $summary String: Custom summary. Set to default summary if empty.