TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/248998

Change subject: Add module dependencies for files in the file history
......................................................................

Add module dependencies for files in the file history

The file history is shown on diff previews, but the full image is not.
Therefor ImageOpenShowImageInlineBefore-hook was not being hit in that
situation and the players in the history table were broken.

Bug: T63923
Change-Id: I852a554d14a083dd238eedacad7bd5826fefba1d
---
M TimedMediaHandler.hooks.php
1 file changed, 30 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler 
refs/changes/98/248998/1

diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php
index 4710dda..94b6f82 100644
--- a/TimedMediaHandler.hooks.php
+++ b/TimedMediaHandler.hooks.php
@@ -170,6 +170,10 @@
                // Make sure modules are loaded on image pages that don't have 
a media file in the wikitext.
                $wgHooks['ImageOpenShowImageInlineBefore'][] = 
'TimedMediaHandlerHooks::onImageOpenShowImageInlineBefore';
 
+               // Make sure modules are loaded for the image history of image 
pages.
+               // This is needed when ImageOpenShowImageInlineBefore is not 
triggered (diff previews). Bug: T63923
+               $wgHooks['ImagePageFileHistoryLine'][] = 
'TimedMediaHandlerHooks::onImagePageFileHistoryLine';
+
                // Exclude transcoded assets from normal thumbnail purging
                // ( a maintenance script could handle transcode asset purging)
                if ( isset( $wgExcludeFromThumbnailPurge ) ) {
@@ -215,12 +219,34 @@
        }
 
        /**
-        * @param $imagePage ImagePage
-        * @param $wgOut OutputPage
+        * @param ImagePage $imagePage the imagepage that is being rendered
+        * @param OutputPage $out the output for this imagepage
         * @return bool
         */
-       public static function onImageOpenShowImageInlineBefore( $imagePage, 
$out ) {
-               $handler = $imagePage->getDisplayedFile()->getHandler();
+       public static function onImageOpenShowImageInlineBefore( &$imagePage, 
&$out ) {
+               $file = $imagePage->getDisplayedFile();
+               return TimedMediaHandlerHooks::onImagePageHooks( $file, $out );
+       }
+
+       /**
+        * @param ImagePage $imagePage that is being rendered
+        * @param File $file the (old) file added in this history entry
+        * @param string &$line the HTML of the history line
+        * @param string &$css the CSS class of the history line
+        * @return bool
+        */
+       public static function onImagePageFileHistoryLine( $imagePage, $file, 
&$line, &$css ) {
+               $out = $imagePage->getContext()->getOutput();
+               return TimedMediaHandlerHooks::onImagePageHooks( $file, $out );
+       }
+
+       /**
+        * @param File $file the file that is being rendered
+        * @param OutputPage $wgOut the output to which this file is being 
rendered
+        * @return bool
+        */
+       private static function onImagePageHooks( $file, $out ) {
+               $handler = $file->getHandler();
                if ( $handler !== false && $handler instanceof 
TimedMediaHandler ) {
                        $out->addModuleStyles( 'ext.tmh.thumbnail.styles' );
                        $out->addModules( array(

-- 
To view, visit https://gerrit.wikimedia.org/r/248998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I852a554d14a083dd238eedacad7bd5826fefba1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: TheDJ <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to