Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -788,6 +788,8 @@ |
789 | 789 | |
790 | 790 | 'FileUpload': When a file upload occurs |
791 | 791 | $file : Image object representing the file that was uploaded |
| 792 | +$reupload : Boolean indicating if there was a previously another image there or not (since 1.17) |
| 793 | +$hasDescription : Boolean indicating that there was already a description page and a new one from the comment wasn't created (since 1.17) |
792 | 794 | |
793 | 795 | 'FileUndeleteComplete': When a file is undeleted |
794 | 796 | $title: title object to the file |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -928,9 +928,6 @@ |
929 | 929 | $article->doEdit( $pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC ); |
930 | 930 | } |
931 | 931 | |
932 | | - # Hooks, hooks, the magic of hooks... |
933 | | - wfRunHooks( 'FileUpload', array( $this ) ); |
934 | | - |
935 | 932 | # Commit the transaction now, in case something goes wrong later |
936 | 933 | # The most important thing is that files don't get lost, especially archives |
937 | 934 | $dbw->commit(); |
— | — | @@ -941,6 +938,9 @@ |
942 | 939 | # which in fact doesn't really exist (bug 24978) |
943 | 940 | $this->saveToCache(); |
944 | 941 | |
| 942 | + # Hooks, hooks, the magic of hooks... |
| 943 | + wfRunHooks( 'FileUpload', array( $this, $reupload, $descTitle->exists() ) ); |
| 944 | + |
945 | 945 | # Invalidate cache for all pages using this file |
946 | 946 | $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' ); |
947 | 947 | $update->doUpdate(); |
Index: trunk/extensions/FileSearch/FileSearchIndexer.php |
— | — | @@ -19,20 +19,21 @@ |
20 | 20 | * |
21 | 21 | * @param Image $file |
22 | 22 | */ |
23 | | - public static function upload( $file ) { |
24 | | - $title = $file->getTitle(); |
25 | | - $article = new Article( $title ); |
26 | | - # If the description page doesn't exist at this time, then we're |
27 | | - # dealing with a fresh upload; in this case, the index update will |
28 | | - # be done when the page is deleted. On the other hand, if it *does* |
29 | | - # exist, then there won't be a search index update, so we have to |
30 | | - # trigger one ourselves. Not the cleanest of methods... |
31 | | - if( $title->exists() ) { |
| 23 | + public static function upload( $file, $reupload, $hasDescription ) { |
| 24 | + # If we create the description page with the upload, there will be |
| 25 | + # a SearchUpdate when the page is created. |
| 26 | + # Otherwise, if the page exists there won't be a search index update, |
| 27 | + # so we have to trigger one ourselves |
| 28 | + if( $hasDescription ) { |
32 | 29 | global $wgDeferredUpdateList; |
| 30 | + $title = $file->getTitle(); |
| 31 | + $article = new Article( $title ); |
| 32 | + |
33 | 33 | $update = new SearchUpdate( $title->getArticleId(), |
34 | 34 | $title->getPrefixedText(), $article->getContent() ); |
35 | 35 | array_push( $wgDeferredUpdateList, $update ); |
36 | 36 | } |
| 37 | + return true; |
37 | 38 | } |
38 | 39 | |
39 | 40 | /** |
— | — | @@ -48,9 +49,9 @@ |
49 | 50 | wfDebugLog( 'filesearch', "Update called for `{$title}`" ); |
50 | 51 | $titleObj = Title::makeTitle( NS_IMAGE, $title ); |
51 | 52 | $image = wfFindFile( $titleObj ); |
52 | | - if ( !$image->exists() ) { |
| 53 | + if ( !$image || !$image->exists() ) { |
53 | 54 | wfDebugLog( 'filesearch', "Image does not exist: $title" ); |
54 | | - return; |
| 55 | + return true; |
55 | 56 | } |
56 | 57 | $extractor = self::getExtractor( ( $mime = $image->getMimeType() ) ); |
57 | 58 | if( $extractor instanceof Extractor ) { |
— | — | @@ -62,6 +63,7 @@ |
63 | 64 | wfDebugLog( 'filesearch', "No suitable extractor found for `{$mime}`" ); |
64 | 65 | } |
65 | 66 | } |
| 67 | + return true; |
66 | 68 | } |
67 | 69 | |
68 | 70 | /** |