Merge "Split down patch-comment-table.sql"
[lhc/web/wiklou.git] / includes / actions / RawAction.php
index f6c4472..0586e09 100644 (file)
@@ -111,7 +111,8 @@ class RawAction extends FormlessAction {
                        $rootPage = strtok( $title->getText(), '/' );
                        $userFromTitle = User::newFromName( $rootPage, 'usable' );
                        if ( !$userFromTitle || $userFromTitle->getId() === 0 ) {
-                               $elevated = $this->getUser()->isAllowed( 'editinterface' );
+                               $elevated = MediaWikiServices::getInstance()->getPermissionManager()
+                                       ->userHasRight( $this->getUser(), 'editinterface' );
                                $elevatedText = $elevated ? 'by elevated ' : '';
                                $log = LoggerFactory::getInstance( "security" );
                                $log->warning(
@@ -237,23 +238,31 @@ class RawAction extends FormlessAction {
         */
        public function getOldId() {
                $oldid = $this->getRequest()->getInt( 'oldid' );
+               $rl = MediaWikiServices::getInstance()->getRevisionLookup();
                switch ( $this->getRequest()->getText( 'direction' ) ) {
                        case 'next':
                                # output next revision, or nothing if there isn't one
-                               $nextid = 0;
+                               $nextRev = null;
                                if ( $oldid ) {
-                                       $nextid = $this->getTitle()->getNextRevisionID( $oldid );
+                                       $oldRev = $rl->getRevisionById( $oldid );
+                                       if ( $oldRev ) {
+                                               $nextRev = $rl->getNextRevision( $oldRev );
+                                       }
                                }
-                               $oldid = $nextid ?: -1;
+                               $oldid = $nextRev ? $nextRev->getId() : -1;
                                break;
                        case 'prev':
                                # output previous revision, or nothing if there isn't one
+                               $prevRev = null;
                                if ( !$oldid ) {
                                        # get the current revision so we can get the penultimate one
                                        $oldid = $this->page->getLatest();
                                }
-                               $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
-                               $oldid = $previd ?: -1;
+                               $oldRev = $rl->getRevisionById( $oldid );
+                               if ( $oldRev ) {
+                                       $prevRev = $rl->getPreviousRevision( $oldRev );
+                               }
+                               $oldid = $prevRev ? $prevRev->getId() : -1;
                                break;
                        case 'cur':
                                $oldid = 0;
@@ -269,9 +278,7 @@ class RawAction extends FormlessAction {
         * @return string
         */
        public function getContentType() {
-               // Use getRawVal instead of getVal because we only
-               // need to match against known strings, there is no
-               // storing of localised content or other user input.
+               // Optimisation: Avoid slow getVal(), this isn't user-generated content.
                $ctype = $this->getRequest()->getRawVal( 'ctype' );
 
                if ( $ctype == '' ) {