* Default tidy.conf has been moved from extensions module into includes.
* Ignore lonely '''''
* (bug 3984) Searching in logs by title%
+* (bug 9244) When calling edit page for nonexistent section, generate error inside of just discarding edits, since edit links sometimes go to the wrong place.
* Private logs can now be created using $wgLogRestrictions
* (bug 3576) Revisiondelete completed (RSS feeds checked, carries over delete/undelete)
* Log events, file revisions, archived revisions can be deleted with revisiondelete
/**
* Fetch initial editing page content.
*/
- private function getContent() {
+ private function getContent( $def_text = '' ) {
global $wgOut, $wgRequest, $wgParser;
# Get variables from query string :P
if( $section == 'new' ) {
$text = $this->getPreloadedText( $preload );
} else {
- $text = $wgParser->getSection( $text, $section );
+ $text = $wgParser->getSection( $text, $section, $def_text );
}
}
}
# First time through: get contents, set time for conflict
# checking, etc.
if ( 'initial' == $this->formtype || $this->firsttime ) {
- $this->initialiseForm();
+ if ($this->initialiseForm() === false) {
+ $this->noSuchSectionPage();
+ wfProfileOut( "$fname-business-end" );
+ wfProfileOut( $fname );
+ return;
+ }
if( !$this->mTitle->getArticleId() )
wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) );
}
function initialiseForm() {
$this->edittime = $this->mArticle->getTimestamp();
$this->summary = '';
- $this->textbox1 = $this->getContent();
+ $this->textbox1 = $this->getContent(false);
+ if ($this->textbox1 === false) return false;
+
if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
$this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() );
wfProxyCheck();
+ return true;
}
/**
$wgOut->returnToMain( false );
}
+ /**
+ * Creates a basic error page which informs the user that
+ * they have attempted to edit a nonexistant section.
+ */
+ function noSuchSectionPage() {
+ global $wgOut;
+
+ $wgOut->setPageTitle( wfMsg( 'nosuchsectiontitle' ) );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $wgOut->setArticleRelated( false );
+
+ $wgOut->addWikiText( wfMsg( 'nosuchsectiontext', $this->section ) );
+ $wgOut->returnToMain( false );
+ }
+
/**
* Produce the stock "your edit contains spam" page
*
$uniq = preg_quote( $this->uniqPrefix(), '/' );
$comment = "(?:$uniq-!--.*?QINU)";
$secs = preg_split(
- /*
- "/
- ^(
- (?:$comment|<\/?noinclude>)* # Initial comments will be stripped
- (?:
- (=+) # Should this be limited to 6?
- .+? # Section title...
- \\2 # Ending = count must match start
- |
- ^
- <h([1-6])\b.*?>
- .*?
- <\/h\\3\s*>
- )
- (?:$comment|<\/?noinclude>|\s+)* # Trailing whitespace ok
- )$
- /mix",
- */
"/
(
^
// "Section 0" returns the content before any other section.
$rv = $secs[0];
} else {
- $rv = "";
+ //track missing section, will replace if found.
+ $rv = $newtext;
}
} elseif( $mode == "replace" ) {
if( $section == 0 ) {
}
}
}
- # reinsert stripped tags
- $rv = trim( $stripState->unstripBoth( $rv ) );
+ if (is_string($rv))
+ # reinsert stripped tags
+ $rv = trim( $stripState->unstripBoth( $rv ) );
+
return $rv;
}
*
* @param $text String: text to look in
* @param $section Integer: section number
+ * @param $deftext: default to return if section is not found
* @return string text of the requested section
*/
- public function getSection( $text, $section ) {
- return $this->extractSections( $text, $section, "get" );
+ public function getSection( $text, $section, $deftext='' ) {
+ return $this->extractSections( $text, $section, "get", $deftext );
}
public function replaceSection( $oldtext, $section, $text ) {
);
}
}
+
wfRunHooks( 'SkinTemplateTabs', array( &$this , &$content_actions ) ) ;
} else {
'whitelistacctext' => 'To be allowed to create accounts in this wiki you have to [[Special:Userlogin|log]] in and have the appropriate permissions.',
'confirmedittitle' => 'E-mail confirmation required to edit',
'confirmedittext' => 'You must confirm your e-mail address before editing pages. Please set and validate your e-mail address through your [[Special:Preferences|user preferences]].',
+'nosuchsectiontitle' => 'No such section',
+'nosuchsectiontext' => "You tried to edit a section that doesn't exist. Since there is no section \$1, there's no place to save your edit.",
'loginreqtitle' => 'Login Required',
'loginreqlink' => 'log in',
'loginreqpagetext' => 'You must $1 to view other pages.',
$dbw->query( "DELETE FROM $tbl_rev WHERE rev_id IN ( $set )" );
$dbw->commit();
+
+ #TODO: see if this is a "good" page, to decrement that as well.
+ $pages = $dbw->selectField('site_stats', 'ss_total_pages');
+ $pages--;
+ $dbw->update( 'site_stats',
+ array('ss_total_pages' => $pages ),
+ array( 'ss_row_id' => 1),
+ __METHOD__ );
}