From 7dc92434e23fe0dc19a79dbcb5d67607e95b317f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 18 Jun 2005 09:45:18 +0000 Subject: [PATCH] * Less gratuitous munging of content sample in delete summary * some code cleanup in deletion form --- RELEASE-NOTES | 1 + includes/Article.php | 48 +++++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f9617fdfbf..c4f2db9cce 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -296,6 +296,7 @@ Various bugfixes, small features, and a few experimental things: * (bug 873) Fix usage of createaccount permission; replaces $wgWhitelistAccount * (bug 1805) Initialise $wgContLang before $wgUser * (bug 2277) Added Friulian language file +* Less gratuitous munging of content sample in delete summary === Caveats === diff --git a/includes/Article.php b/includes/Article.php index 25dfbfb310..3d95135498 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1551,24 +1551,23 @@ class Article { # This code desperately needs to be totally rewritten # Check permissions - if ( ( ! $wgUser->isAllowed('delete') ) ) { + if( ( !$wgUser->isAllowed( 'delete' ) ) ) { $wgOut->sysopRequired(); return; } - if ( wfReadOnly() ) { + if( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } # Better double-check that it hasn't been deleted yet! $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) ); - if ( ( '' == trim( $this->mTitle->getText() ) ) - or ( $this->mTitle->getArticleId() == 0 ) ) { + if( !$this->mTitle->exists() ) { $wgOut->fatalError( wfMsg( 'cannotdelete' ) ); return; } - if ( $confirm ) { + if( $confirm ) { $this->doDelete( $reason ); return; } @@ -1600,8 +1599,8 @@ class Article { # Fetch name(s) of contributors $rev_name = ''; $all_same_user = true; - while ( $row = $dbr->fetchObject( $revisions ) ) { - if ( $rev_name != '' && $rev_name != $row->rev_user_text ) { + while( $row = $dbr->fetchObject( $revisions ) ) { + if( $rev_name != '' && $rev_name != $row->rev_user_text ) { $all_same_user = false; } else { $rev_name = $row->rev_user_text; @@ -1614,44 +1613,39 @@ class Article { #if this is empty, an earlier revision may contain "useful" text $blanked = false; - if($text == '') { - $prevId = $this->mTitle->getPreviousRevisionID( $rev->getId() ); - $rev = Revision::newFromId( $prevId ); - if ( $rev ) { - $text = $rev->getText(); + if( $text == '' ) { + $prev = $rev->getPrevious(); + if( $prev ) { + $text = $prev->getText(); $blanked = true; } } - $length=strlen($text); + $length = strlen( $text ); # this should not happen, since it is not possible to store an empty, new # page. Let's insert a standard text in case it does, though - if($length == 0 && $reason === '') { - $reason = wfMsg('exblank'); + if( $length == 0 && $reason === '' ) { + $reason = wfMsg( 'exblank' ); } - if($length < 500 && $reason === '') { - + if( $length < 500 && $reason === '' ) { # comment field=255, let's grep the first 150 to have some user # space left global $wgContLang; $text = $wgContLang->truncate( $text, 150, '...' ); - # let's strip out newlines and HTML tags - $text=preg_replace('/\"/',"'",$text); - $text=preg_replace('/\/','>',$text); - $text=preg_replace("/[\n\r]/",'',$text); + # let's strip out newlines + $text = preg_replace( "/[\n\r]/", '', $text ); - if(!$blanked) { - if(!$all_same_user) { - $reason = wfMsg ( 'excontent', $text ); + if( !$blanked ) { + if( !$all_same_user ) { + $reason = wfMsg( 'excontent', $text ); } else { - $reason = wfMsg ( 'excontentauthor', $text, $rev_name ); + $reason = wfMsg( 'excontentauthor', $text, $rev_name ); } } else { - $reason = wfMsg ( 'exbeforeblank', $text ); + $reason = wfMsg( 'exbeforeblank', $text ); } } } -- 2.20.1