Move FileUpload hook out of the transaction.
authorPlatonides <platonides@users.mediawiki.org>
Tue, 31 Aug 2010 13:16:42 +0000 (13:16 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 31 Aug 2010 13:16:42 +0000 (13:16 +0000)
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.

docs/hooks.txt
includes/filerepo/LocalFile.php

index 46af3b0..bbc1bed 100644 (file)
@@ -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
index fce4373..3090106 100644 (file)
@@ -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();