From 85cfb003047089324342f7025dbddd656230dab8 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 24 Sep 2011 17:52:53 +0000 Subject: [PATCH] Allow LogEventsList::showLogExtract() to get a Title object instead of having to do Title -> string -> Title conversion --- includes/EditPage.php | 8 ++++---- includes/FileDeleteForm.php | 2 +- includes/HistoryPage.php | 2 +- includes/LogEventsList.php | 14 +++++++++----- includes/ProtectionForm.php | 2 +- includes/specials/SpecialBlock.php | 4 ++-- includes/specials/SpecialContributions.php | 2 +- includes/specials/SpecialDeletedContributions.php | 2 +- includes/specials/SpecialMergeHistory.php | 2 +- includes/specials/SpecialMovepage.php | 4 ++-- includes/specials/SpecialRevisiondelete.php | 4 ++-- includes/specials/SpecialUndelete.php | 4 ++-- includes/specials/SpecialUpload.php | 2 +- includes/specials/SpecialUserrights.php | 2 +- 14 files changed, 29 insertions(+), 25 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 77b1bbfc9c..98039bc0bb 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -807,7 +807,7 @@ class EditPage { LogEventsList::showLogExtract( $wgOut, 'block', - $user->getUserPage()->getPrefixedText(), + $user->getUserPage(), '', array( 'lim' => 1, @@ -830,7 +830,7 @@ class EditPage { } # Give a notice if the user is editing a deleted/moved page... if ( !$this->mTitle->exists() ) { - LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(), + LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle, '', array( 'lim' => 10, 'conds' => array( "log_action != 'revision'" ), 'showIfEmpty' => false, @@ -1649,7 +1649,7 @@ HTML # Then it must be protected based on static groups (regular) $noticeMsg = 'protectedpagewarning'; } - LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', + LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) ); } if ( $this->mTitle->isCascadeProtected() ) { @@ -1667,7 +1667,7 @@ HTML $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', $cascadeSourcesCount ) ); } if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) { - LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', + LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', array( 'lim' => 1, 'showIfEmpty' => false, 'msgKey' => array( 'titleprotectedwarning' ), diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index e2745e2bac..ca195d88fc 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -236,7 +236,7 @@ class FileDeleteForm { private function showLogEntries() { global $wgOut; $wgOut->addHTML( '

' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); - LogEventsList::showLogExtract( $wgOut, 'delete', $this->title->getPrefixedText() ); + LogEventsList::showLogExtract( $wgOut, 'delete', $this->title ); } /** diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 670fe3e6ee..c40fec48a6 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -117,7 +117,7 @@ class HistoryPage { LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), - $this->title->getPrefixedText(), + $this->title, '', array( 'lim' => 10, 'conds' => array( "log_action != 'revision'" ), diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index b1ede05ec9..08949d849b 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -789,7 +789,7 @@ class LogPager extends ReverseChronologicalPager { * @param $list LogEventsList * @param $types String or Array: log types to show * @param $performer String: the user who made the log entries - * @param $title String: the page title the log entries are for + * @param $title String or Title: the page title the log entries are for * @param $pattern String: do a prefix search rather than an exact title match * @param $conds Array: extra conditions for the query * @param $year Integer: the year to start from @@ -909,15 +909,19 @@ class LogPager extends ReverseChronologicalPager { * Set the log reader to return only entries affecting the given page. * (For the block and rights logs, this is a user page.) * - * @param $page String: Title name as text + * @param $page String or Title object: Title name * @param $pattern String */ private function limitTitle( $page, $pattern ) { global $wgMiserMode; - $title = Title::newFromText( $page ); - if( strlen( $page ) == 0 || !$title instanceof Title ) { - return false; + if ( $page instanceof Title ) { + $title = $page; + } else { + $title = Title::newFromText( $page ); + if( strlen( $page ) == 0 || !$title instanceof Title ) { + return false; + } } $this->title = $title->getPrefixedText(); diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index caee18fb03..b73558bee2 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -606,7 +606,7 @@ class ProtectionForm { function showLogExtract( &$out ) { # Show relevant lines from the protection log: $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'protect' ) ) ); - LogEventsList::showLogExtract( $out, 'protect', $this->mTitle->getPrefixedText() ); + LogEventsList::showLogExtract( $out, 'protect', $this->mTitle ); # Let extensions add other relevant log extracts wfRunHooks( 'ProtectionForm::showLogExtract', array($this->mArticle,$out) ); } diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 34c38847f2..d0b806a5db 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -404,7 +404,7 @@ class SpecialBlock extends SpecialPage { LogEventsList::showLogExtract( $out, 'block', - $userpage->getPrefixedText(), + $userpage, '', array( 'lim' => 10, @@ -419,7 +419,7 @@ class SpecialBlock extends SpecialPage { LogEventsList::showLogExtract( $out, 'suppress', - $userpage->getPrefixedText(), + $userpage, '', array( 'lim' => 10, diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 7e513bf6e0..3de70fae2d 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -228,7 +228,7 @@ class SpecialContributions extends SpecialPage { LogEventsList::showLogExtract( $out, 'block', - $nt->getPrefixedText(), + $nt, '', array( 'lim' => 1, diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 99f16547fe..b3fbeb6069 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -422,7 +422,7 @@ class DeletedContributionsPage extends SpecialPage { LogEventsList::showLogExtract( $out, 'block', - $nt->getPrefixedText(), + $nt, '', array( 'lim' => 1, diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index e6580ea0c9..0f046ab68d 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -236,7 +236,7 @@ class SpecialMergeHistory extends SpecialPage { # Show relevant lines from the deletion log: $out->addHTML( '

' . htmlspecialchars( LogPage::logName( 'merge' ) ) . "

\n" ); - LogEventsList::showLogExtract( $out, 'merge', $this->mTargetObj->getPrefixedText() ); + LogEventsList::showLogExtract( $out, 'merge', $this->mTargetObj ); # When we submit, go by page ID to avoid some nasty but unlikely collisions. # Such would happen if a page was renamed after the form loaded, but before submit diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 8fa44a0ab2..f4cc150c67 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -216,7 +216,7 @@ class MovePageForm extends UnlistedSpecialPage { } $out->addHTML( "
\n" ); $out->addWikiMsg( $noticeMsg ); - LogEventsList::showLogExtract( $out, 'protect', $this->oldTitle->getPrefixedText(), '', array( 'lim' => 1 ) ); + LogEventsList::showLogExtract( $out, 'protect', $this->oldTitle, '', array( 'lim' => 1 ) ); $out->addHTML( "
\n" ); } @@ -580,7 +580,7 @@ class MovePageForm extends UnlistedSpecialPage { function showLogFragment( $title ) { $out = $this->getOutput(); $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'move' ) ) ); - LogEventsList::showLogExtract( $out, 'move', $title->getPrefixedText() ); + LogEventsList::showLogExtract( $out, 'move', $title ); } function showSubpages( $title ) { diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 9518e196b7..c5915fb3e3 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -208,12 +208,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { # Show relevant lines from the deletion log $output->addHTML( "

" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); LogEventsList::showLogExtract( $output, 'delete', - $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) ); + $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) ); # Show relevant lines from the suppression log if( $user->isAllowed( 'suppressionlog' ) ) { $output->addHTML( "

" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "

\n" ); LogEventsList::showLogExtract( $output, 'suppress', - $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) ); + $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) ); } } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 246a666efd..6581a1c8f5 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -1076,11 +1076,11 @@ class SpecialUndelete extends SpecialPage { # Show relevant lines from the deletion log: $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) . "\n" ); - LogEventsList::showLogExtract( $out, 'delete', $this->mTargetObj->getPrefixedText() ); + LogEventsList::showLogExtract( $out, 'delete', $this->mTargetObj ); # Show relevant lines from the suppression log: if( $this->getUser()->isAllowed( 'suppressionlog' ) ) { $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'suppress' ) ) . "\n" ); - LogEventsList::showLogExtract( $out, 'suppress', $this->mTargetObj->getPrefixedText() ); + LogEventsList::showLogExtract( $out, 'suppress', $this->mTargetObj ); } if( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) { diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 7fd6e1e794..d6b8d0abc2 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -266,7 +266,7 @@ class SpecialUpload extends SpecialPage { $delNotice = ''; // empty by default if ( $desiredTitleObj instanceof Title && !$desiredTitleObj->exists() ) { LogEventsList::showLogExtract( $delNotice, array( 'delete', 'move' ), - $desiredTitleObj->getPrefixedText(), + $desiredTitleObj, '', array( 'lim' => 10, 'conds' => array( "log_action != 'revision'" ), 'showIfEmpty' => false, diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 5de67fbcf5..8a2fb02d5b 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -606,6 +606,6 @@ class UserrightsPage extends SpecialPage { */ protected function showLogFragment( $user, $output ) { $output->addHTML( Xml::element( 'h2', null, LogPage::logName( 'rights' ) . "\n" ) ); - LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage()->getPrefixedText() ); + LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage() ); } } -- 2.20.1