Skip to content
Permalink
Browse files Browse the repository at this point in the history
Use PageMoveComplete hook (#17)
  • Loading branch information
Universal-Omega committed Jul 19, 2021
1 parent 21ea3dd commit 48be7ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions extension.json
Expand Up @@ -53,8 +53,8 @@
"FileDeleteComplete": [
"GlobalNewFilesHooks::onFileDeleteComplete"
],
"TitleMoveComplete": [
"GlobalNewFilesHooks::onTitleMoveComplete"
"PageMoveComplete": [
"GlobalNewFilesHooks::onPageMoveComplete"
],
"UploadComplete": [
"GlobalNewFilesHooks::onUploadComplete"
Expand Down
9 changes: 6 additions & 3 deletions includes/GlobalNewFilesHooks.php
Expand Up @@ -19,10 +19,13 @@ public static function onFileDeleteComplete( $file, $oldimage, $article, $user,
);
}

public static function onTitleMoveComplete( $title, $newTitle, $user, $oldid, $newid, $reason, $revision ) {
if ( $title->inNamespace( NS_FILE ) ) {
public static function onPageMoveComplete( $old, $new, $userIdentity, $pageid, $redirid, $reason, $revision ) {
$oldTitle = Title::newFromLinkTarget( $old );
$newTitle = Title::newFromLinkTarget( $new );

if ( $oldTitle->inNamespace( NS_FILE ) ) {
JobQueueGroup::singleton()->push(
new GlobalNewFilesMoveJob( [ 'oldtitle' => $title, 'newtitle' => $newTitle ] )
new GlobalNewFilesMoveJob( [ 'oldtitle' => $oldTitle, 'newtitle' => $newTitle ] )
);
}
}
Expand Down

0 comments on commit 48be7ad

Please sign in to comment.