From a5e26f5c22aa5ebafffe2513b7c0f77cbc39218c Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Wed, 29 Nov 2006 18:21:56 +0000 Subject: [PATCH] Patch from LeonWP: added UploadForm:BeforeProcessing hook in SpecialUpload.php --- RELEASE-NOTES | 1 + docs/hooks.txt | 5 +++++ includes/SpecialUpload.php | 22 ++++++++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7133e79a41..a2031dfc83 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -226,6 +226,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fix display of link in "already rolled back" message for image/category pages * (bug 6016) Left-aligned images should stack vertically, like right-aligned images, not horizontally. +* Patch from LeonWP: added UploadForm:BeforeProcessing hook in SpecialUpload.php == Languages updated == diff --git a/docs/hooks.txt b/docs/hooks.txt index ab699e66b2..c7f900c7ba 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -443,6 +443,11 @@ You might set the member-variables $uploadFormTextTop and $uploadFormTextAfterSummary to inject text (HTML) either before or after the editform. +'UploadForm:BeforeProcessing': at the beginning of processUpload() +$form: UploadForm object +Lets you poke at member variables like $mUploadDescription before the +file is saved. + 'UploadVerification': additional chances to reject an uploaded file string $saveName: destination file name string $tempName: filesystem path to the temporary file for checks diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index fc262e18ca..8a14146f2e 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -51,9 +51,9 @@ class UploadForm { return; } - # Placeholders for text injection by hooks (empty per default) - $this->uploadFormTextTop = ""; - $this->uploadFormTextAfterSummary = ""; + # Placeholders for text injection by hooks (empty per default) + $this->uploadFormTextTop = ""; + $this->uploadFormTextAfterSummary = ""; $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ); $this->mReUpload = $request->getCheck( 'wpReUpload' ); @@ -266,6 +266,12 @@ class UploadForm { function processUpload() { global $wgUser, $wgOut; + if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) + { + wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." ); + return false; + } + /* Check for PHP error if any, requires php 4.2 or newer */ if( $this->mUploadError == 1/*UPLOAD_ERR_INI_SIZE*/ ) { $this->mainUploadForm( wfMsgHtml( 'largefileserver' ) ); @@ -701,11 +707,11 @@ class UploadForm { global $wgUseCopyrightUpload; global $wgRequest, $wgAllowCopyUploads; - if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) - { - wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" ); - return false; - } + if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) + { + wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" ); + return false; + } $cols = intval($wgUser->getOption( 'cols' )); $ew = $wgUser->getOption( 'editwidth' ); -- 2.20.1