Merge "mediawiki.skinning: Remove obsolete #firstHeading selector"
[lhc/web/wiklou.git] / includes / Title.php
index 1676a1b..7fdeb05 100644 (file)
@@ -944,10 +944,12 @@ class Title {
         * Get the page's content model id, see the CONTENT_MODEL_XXX constants.
         *
         * @throws MWException
+        * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select for update
         * @return string Content model id
         */
-       public function getContentModel() {
-               if ( !$this->mContentModel ) {
+       public function getContentModel( $flags = 0 ) {
+               # Calling getArticleID() loads the field from cache as needed
+               if ( !$this->mContentModel && $this->getArticleID( $flags ) ) {
                        $linkCache = LinkCache::singleton();
                        $this->mContentModel = $linkCache->getGoodLinkFieldObj( $this, 'model' );
                }
@@ -2261,11 +2263,15 @@ class Title {
                                $errors[] = array( 'immobile-target-page' );
                        }
                } elseif ( $action == 'delete' ) {
-                       if ( count( $this->getUserPermissionsErrorsInternal( 'edit',
-                               $user, $doExpensiveQueries, true ) )
-                       ) {
-                               // If they can't edit, they shouldn't delete.
-                               $errors[] = array( 'delete-cantedit' );
+                       $tempErrors = $this->checkPageRestrictions( 'edit',
+                               $user, array(), $doExpensiveQueries, true );
+                       if ( !$tempErrors ) {
+                               $tempErrors = $this->checkCascadingSourcesRestrictions( 'edit',
+                                       $user, $tempErrors, $doExpensiveQueries, true );
+                       }
+                       if ( $tempErrors ) {
+                               // If protection keeps them from editing, they shouldn't be able to delete.
+                               $errors[] = array( 'deleteprotected' );
                        }
                        if ( $doExpensiveQueries && $wgDeleteRevisionsLimit
                                && !$this->userCan( 'bigdelete', $user ) && $this->isBigDeletion()
@@ -3317,8 +3323,8 @@ class Title {
                        // @note: splitTitleString() is a temporary hack to allow MediaWikiTitleCodec to share
                        //        the parsing code with Title, while avoiding massive refactoring.
                        // @todo: get rid of secureAndSplit, refactor parsing code.
-                       $parser = self::getTitleParser();
-                       $parts = $parser->splitTitleString( $dbkey, $this->getDefaultNamespace() );
+                       $titleParser = self::getTitleParser();
+                       $parts = $titleParser->splitTitleString( $dbkey, $this->getDefaultNamespace() );
                } catch ( MalformedTitleException $ex ) {
                        return false;
                }