r41085 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41084‎ | r41085 | r41086 >
Date:02:53, 21 September 2008
Author:simetrical
Status:old
Tags:
Comment:
Prohibit empty page titles at a low level

This adds a sanity check to EditPage::doEdit() that throws an exception if the Title's name (sans namespace) is empty. Apparently the API edit module doesn't handle this error correctly at a high level, as evidenced by page 19405691 on enwiki. I didn't try to test whether this extra check stops the particular error, but it doesn't hurt in any case.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1415,11 +1415,16 @@
14161416 function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
14171417 global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
14181418
 1419+ # Low-level sanity check
 1420+ if( $this->mTitle->getText() == '' ) {
 1421+ throw new MWException( 'Something is trying to edit an article with an empty title' );
 1422+ }
 1423+
 1424+ wfProfileIn( __METHOD__ );
 1425+
14191426 if ($user == null) {
14201427 $user = $wgUser;
14211428 }
1422 -
1423 - wfProfileIn( __METHOD__ );
14241429 $good = true;
14251430
14261431 if ( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) {