r31420 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31419‎ | r31420 | r31421 >
Date:13:35, 1 March 2008
Author:btongminh
Status:old
Tags:
Comment:
Fix description for UploadComplete hook. New hooks: FileDeleteComplete, FileUndeleteComplete
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)
  • /trunk/phase3/includes/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -562,9 +562,23 @@
563563 &$list: List object (defaults to NULL, change it to an object instance and return
564564 false override the list derivative used)
565565
 566+'FileDeleteComplete': When a file is deleted
 567+$file: reference to the deleted file
 568+$oldimage: in case of the deletion of an old image, the name of the old file
 569+$article: in case all revisions of the file are deleted a reference to the article
 570+ associated with the file.
 571+$user: user who performed the deletion
 572+$reason: reason
 573+
566574 'FileUpload': When a file upload occurs
567575 $file : Image object representing the file that was uploaded
568576
 577+'FileUndeleteComplete': When a file is undeleted
 578+$title: title object to the file
 579+$fileVersions: array of undeleted versions. Empty if all versions were restored
 580+$user: user who performed the undeletion
 581+$reason: reason
 582+
569583 'GetBlockedStatus': after loading blocking status of an user from the database
570584 $user: user (object) being checked
571585
@@ -1025,7 +1039,7 @@
10261040 string &$error: output: HTML error to show if upload canceled by returning false
10271041
10281042 'UploadComplete': Upon completion of a file upload
1029 -$image: Image object representing the file that was uploaded
 1043+$uploadForm: Upload form object. File can be accessed by $uploadForm->mLocalFile.
10301044
10311045 'userCan': To interrupt/advise the "user can do X to Y article" check.
10321046 If you want to display an error message, try getUserPermissionsErrors.
Index: trunk/phase3/includes/SpecialUndelete.php
@@ -1055,6 +1055,11 @@
10561056 $this->mFileVersions );
10571057
10581058 if( is_array($ok) ) {
 1059+ if ( $ok[1] ) // Undeleted file count
 1060+ wfRunHooks( 'FileUndeleteComplete', array(
 1061+ $this->mTargetObj, $this->mFileVersions,
 1062+ $wgUser, $this->mComment) );
 1063+
10591064 $skin = $wgUser->getSkin();
10601065 $link = $skin->makeKnownLinkObj( $this->mTargetObj );
10611066 $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );
Index: trunk/phase3/includes/FileDeleteForm.php
@@ -72,6 +72,8 @@
7373 } elseif ( $reason == 'other' ) {
7474 $reason = $this->DeleteReason;
7575 }
 76+
 77+ $article = null;
7678 if( $this->oldimage ) {
7779 $status = $this->file->deleteOld( $this->oldimage, $reason );
7880 if( $status->ok ) {
@@ -90,6 +92,9 @@
9193 $article->doDeleteArticle( $reason );
9294 }
9395 }
 96+ if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array(
 97+ &$this->file, &$this->oldimage, &$article, &$wgUser, &$reason));
 98+
9499 if( !$status->isGood() )
95100 $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
96101 if( $status->ok ) {

Status & tagging log