From: Platonides Date: Tue, 31 Aug 2010 13:16:42 +0000 (+0000) Subject: Move FileUpload hook out of the transaction. X-Git-Tag: 1.31.0-rc.0~35261 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=a4e6acb2884da7fe40bcc228de9ba1235954228f;p=lhc%2Fweb%2Fwiklou.git Move FileUpload hook out of the transaction. FileSearch relied on the article not existing to detect if it's a but it was broken: always detected it as a reupload. Add a new parameter to the hook to detect reuploads. Fixed other issues on FileSearch extension. --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 46af3b0f0d..bbc1bed88e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -788,6 +788,8 @@ $reason: reason 'FileUpload': When a file upload occurs $file : Image object representing the file that was uploaded +$reupload : Boolean indicating if there was a previously another image there or not (since 1.17) +$hasDescription : Boolean indicating that there was already a description page and a new one from the comment wasn't created (since 1.17) 'FileUndeleteComplete': When a file is undeleted $title: title object to the file diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index fce4373019..309010624f 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -928,9 +928,6 @@ class LocalFile extends File { $article->doEdit( $pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC ); } - # Hooks, hooks, the magic of hooks... - wfRunHooks( 'FileUpload', array( $this ) ); - # Commit the transaction now, in case something goes wrong later # The most important thing is that files don't get lost, especially archives $dbw->commit(); @@ -941,6 +938,9 @@ class LocalFile extends File { # which in fact doesn't really exist (bug 24978) $this->saveToCache(); + # Hooks, hooks, the magic of hooks... + wfRunHooks( 'FileUpload', array( $this, $reupload, $descTitle->exists() ) ); + # Invalidate cache for all pages using this file $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' ); $update->doUpdate();