X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=b6b1a772d86c57fd44f49ac31e8c17ae68acdec9;hb=48aa3b74e7c4a8573fb1808f53bce0c4d460a0cd;hp=941cef9bd869db6f48046ad010cc3269dfccb0b4;hpb=3badc0c7286d9b0c3d4533a91a8bb70c5386421b;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 941cef9bd8..b6b1a772d8 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -22,6 +22,7 @@ class EditPage {
var $deletedSinceEdit = false;
var $formtype;
var $firsttime;
+ var $lastDelete;
# Form values
var $save = false, $preview = false, $diff = false;
@@ -152,6 +153,10 @@ class EditPage {
*/
function edit() {
global $wgOut, $wgUser, $wgRequest, $wgTitle;
+
+ $fname = 'EditPage::edit';
+ wfProfileIn( $fname );
+
// this is not an article
$wgOut->setArticleFlag(false);
@@ -160,25 +165,30 @@ class EditPage {
if( $this->live ) {
$this->livePreview();
+ wfProfileOut( $fname );
return;
}
if ( ! $this->mTitle->userCanEdit() ) {
$wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
+ wfProfileOut( $fname );
return;
}
if ( !$this->preview && !$this->diff && $wgUser->isBlockedFrom( $this->mTitle, !$this->save ) ) {
# When previewing, don't check blocked state - will get caught at save time.
# Also, check when starting edition is done against slave to improve performance.
$this->blockedIPpage();
+ wfProfileOut( $fname );
return;
}
if ( !$wgUser->isAllowed('edit') ) {
if ( $wgUser->isAnon() ) {
$this->userNotLoggedInPage();
+ wfProfileOut( $fname );
return;
} else {
$wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
+ wfProfileOut( $fname );
return;
}
}
@@ -189,6 +199,7 @@ class EditPage {
$this->formtype = 'diff';
} else {
$wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
+ wfProfileOut( $fname );
return;
}
} else {
@@ -208,6 +219,8 @@ class EditPage {
}
}
}
+
+ wfProfileIn( "$fname-business-end" );
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
@@ -224,9 +237,9 @@ class EditPage {
* to only perform it on saves
*/
if ( $this->mTitle->isDeleted() ) {
- $query = $this->getLastDelete();
- if ( !is_null($query) ) {
- $deletetime = $query->log_timestamp;
+ $this->lastDelete = $this->getLastDelete();
+ if ( !is_null($this->lastDelete) ) {
+ $deletetime = $this->lastDelete->log_timestamp;
if ( ($deletetime - $this->starttime) > 0 ) {
$this->deletedSinceEdit = true;
}
@@ -248,6 +261,8 @@ class EditPage {
if ( 'save' == $this->formtype ) {
if ( !$this->attemptSave() ) {
+ wfProfileOut( "$fname-business-end" );
+ wfProfileOut( $fname );
return;
}
}
@@ -259,6 +274,8 @@ class EditPage {
}
$this->showEditForm();
+ wfProfileOut( "$fname-business-end" );
+ wfProfileOut( $fname );
}
/**
@@ -278,6 +295,10 @@ class EditPage {
* @todo document
*/
function importFormData( &$request ) {
+ global $wgLang ;
+ $fname = 'EditPage::importFormData';
+ wfProfileIn( $fname );
+
if( $request->wasPosted() ) {
# These fields need to be checked for encoding.
# Also remove trailing whitespace, but don't remove _initial_
@@ -285,7 +306,8 @@ class EditPage {
$this->textbox1 = $this->safeUnicodeInput( $request, 'wpTextbox1' );
$this->textbox2 = $this->safeUnicodeInput( $request, 'wpTextbox2' );
$this->mMetaData = rtrim( $request->getText( 'metadata' ) );
- $this->summary = $request->getText( 'wpSummary' );
+ # Truncate for whole multibyte characters. +5 bytes for ellipsis
+ $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 250 );
$this->edittime = $request->getVal( 'wpEdittime' );
$this->starttime = $request->getVal( 'wpStarttime' );
@@ -343,6 +365,7 @@ class EditPage {
$this->live = $request->getCheck( 'live' );
$this->editintro = $request->getText( 'editintro' );
+ wfProfileOut( $fname );
}
/**
@@ -364,7 +387,7 @@ class EditPage {
}
function showIntro() {
- global $wgOut;
+ global $wgOut, $wgUser;
$addstandardintro=true;
if($this->editintro) {
$introtitle=Title::newFromText($this->editintro);
@@ -377,7 +400,10 @@ class EditPage {
}
}
if($addstandardintro) {
- $wgOut->addWikiText( wfMsg( 'newarticletext' ) );
+ if ( $wgUser->isLoggedIn() )
+ $wgOut->addWikiText( wfMsg( 'newarticletext' ) );
+ else
+ $wgOut->addWikiText( wfMsg( 'newarticletextanon' ) );
}
}
@@ -388,6 +414,10 @@ class EditPage {
function attemptSave() {
global $wgSpamRegex, $wgFilterCallback, $wgUser, $wgOut;
+ $fname = 'EditPage::attemptSave';
+ wfProfileIn( $fname );
+ wfProfileIn( "$fname-checks" );
+
# Reintegrate metadata
if ( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ;
$this->mMetaData = '' ;
@@ -395,64 +425,83 @@ class EditPage {
# Check for spam
if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
$this->spamPage ( $matches[0] );
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return false;
}
if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
# Error messages or other handling should be performed by the filter function
+ wfProfileOut( $fname );
+ wfProfileOut( "$fname-checks" );
+ return false;
+ }
+ if ( !wfRunHooks( 'EditFilter', array( &$this, $this->textbox1, $this->section ) ) ) {
+ # Error messages or other handling should be performed by the filter function
+ wfProfileOut( $fname );
+ wfProfileOut( "$fname-checks" );
return false;
}
if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
# Check block state against master, thus 'false'.
$this->blockedIPpage();
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return false;
}
if ( !$wgUser->isAllowed('edit') ) {
if ( $wgUser->isAnon() ) {
$this->userNotLoggedInPage();
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return false;
}
else {
$wgOut->readOnlyPage();
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return false;
}
}
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return false;
}
if ( $wgUser->pingLimiter() ) {
$wgOut->rateLimited();
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return false;
}
# If the article has been deleted while editing, don't save it without
# confirmation
if ( $this->deletedSinceEdit && !$this->recreate ) {
+ wfProfileOut( "$fname-checks" );
+ wfProfileOut( $fname );
return true;
}
+ wfProfileOut( "$fname-checks" );
+
# If article is new, insert it.
$aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
if ( 0 == $aid ) {
# Don't save a new article if it's blank.
- if ( ( '' == $this->textbox1 ) ||
- ( wfMsg( 'newarticletext' ) == $this->textbox1 ) ) {
+ if ( ( '' == $this->textbox1 ) ) {
$wgOut->redirect( $this->mTitle->getFullURL() );
+ wfProfileOut( $fname );
return false;
- }
- if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$this->textbox1,
- &$this->summary, &$this->minoredit, &$this->watchthis, NULL)))
- {
-
- $isComment=($this->section=='new');
- $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
- $this->minoredit, $this->watchthis, false, $isComment);
- wfRunHooks('ArticleSaveComplete', array(&$this->mArticle, &$wgUser, $this->textbox1,
- $this->summary, $this->minoredit,
- $this->watchthis, NULL));
}
+
+ $isComment=($this->section=='new');
+ $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
+ $this->minoredit, $this->watchthis, false, $isComment);
+
+ wfProfileOut( $fname );
return false;
}
@@ -471,17 +520,15 @@ class EditPage {
if ( $this->isConflict) {
wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
$this->mArticle->getTimestamp() . "'\n" );
- $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
- $this->section, $this->textbox1, $this->summary, $this->edittime);
+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime);
}
else {
wfDebug( "EditPage::editForm getting section '$this->section'\n" );
- $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
- $this->section, $this->textbox1, $this->summary);
+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
}
- # Suppress edit conflict with self
- if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
+ # Suppress edit conflict with self, except for section edits where merging is required.
+ if ( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
wfDebug( "Suppressing edit conflict, same user.\n" );
$this->isConflict = false;
} else {
@@ -501,10 +548,12 @@ class EditPage {
}
if ( $this->isConflict ) {
+ wfProfileOut( $fname );
return true;
}
# All's well
+ wfProfileIn( "$fname-sectionanchor" );
$sectionanchor = '';
if( $this->section == 'new' ) {
if( $this->summary != '' ) {
@@ -512,7 +561,7 @@ class EditPage {
}
} elseif( $this->section != '' ) {
# Try to get a section anchor from the section source, redirect to edited section if header found
- # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
+ # XXX: might be better to integrate this into Article::replaceSection
# for duplicate heading checking and maybe parsing
$hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches );
# we can't deal with anchors, includes, html etc in the header for now,
@@ -521,6 +570,7 @@ class EditPage {
$sectionanchor = $this->sectionAnchor( $matches[2] );
}
}
+ wfProfileOut( "$fname-sectionanchor" );
// Save errors may fall down to the edit form, but we've now
// merged the section into full text. Clear the section field
@@ -529,23 +579,15 @@ class EditPage {
$this->textbox1 = $text;
$this->section = '';
- if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$text,
- &$this->summary, &$this->minoredit,
- &$this->watchthis, &$sectionanchor)))
- {
- # update the article here
- if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
- $this->watchthis, '', $sectionanchor ))
- {
- wfRunHooks('ArticleSaveComplete',
- array(&$this->mArticle, &$wgUser, $text,
- $this->summary, $this->minoredit,
- $this->watchthis, $sectionanchor));
- return false;
- } else {
- $this->isConflict = true;
- }
+ # update the article here
+ if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
+ $this->watchthis, '', $sectionanchor ) ) {
+ wfProfileOut( $fname );
+ return false;
+ } else {
+ $this->isConflict = true;
}
+ wfProfileOut( $fname );
return true;
}
@@ -557,15 +599,21 @@ class EditPage {
$this->edittime = $this->mArticle->getTimestamp();
$this->textbox1 = $this->mArticle->getContent( true );
$this->summary = '';
- $this->proxyCheck();
+ wfProxyCheck();
}
/**
* Send the edit form and related headers to $wgOut
+ * @param $formCallback Optional callable that takes an OutputPage
+ * parameter; will be called during form output
+ * near the top, for captchas and the like.
*/
- function showEditForm() {
+ function showEditForm( $formCallback=null ) {
global $wgOut, $wgUser, $wgAllowAnonymousMinor, $wgLang, $wgContLang;
+ $fname = 'EditPage::showEditForm';
+ wfProfileIn( $fname );
+
$sk =& $wgUser->getSkin();
$wgOut->setRobotpolicy( 'noindex,nofollow' );
@@ -761,7 +809,7 @@ class EditPage {
// Add an confirmation checkbox and explanation.
$toolbar = '';
$hidden = 'type="hidden" style="display:none;"';
- $recreate = $wgOut->parse( wfMsg( 'confirmrecreate', $query->user_name , $query->log_comment ));
+ $recreate = $wgOut->parse( wfMsg( 'confirmrecreate', $this->lastDelete->user_name , $this->lastDelete->log_comment ));
$recreate .=
"
".
"";
@@ -776,6 +824,12 @@ class EditPage {
{$toolbar}