jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/354564 )

Change subject: Ensure parsercache consistency
......................................................................


Ensure parsercache consistency

- Make sure that anonymous pages only depend on the system default
- Make sure we can roll back and forth videojs and kaltura player
  without poisoning the parser cache
- Get rid of an older private property on parseroutput.

Bug: T100106
Change-Id: I2bf500ffcb2331e0920bc23aeeeaa3577f53f9c7
---
M TimedMediaHandler.hooks.php
M TimedMediaHandler_body.php
2 files changed, 29 insertions(+), 24 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php
index 69010dd..6406a1f 100644
--- a/TimedMediaHandler.hooks.php
+++ b/TimedMediaHandler.hooks.php
@@ -789,19 +789,17 @@
         * @return bool
         */
        public static function rejectParserCacheValue( $parserOutput, 
$wikiPage, $parserOptions ) {
-               if (
-                       $parserOutput->getExtensionData( 
'mw_ext_TMH_hasTimedMediaTransform' )
-                       || isset( $parserOutput->hasTimedMediaTransform )
-               ) {
-                       /* page has old style TMH elements */
-                       if (
-                               self::activePlayerMode() === 'mwembed' &&
+               if ( $parserOutput->getExtensionData( 
'mw_ext_TMH_hasTimedMediaTransform' ) && (
+                       (
+                               self::defaultPlayerMode() === 'mwembed' &&
                                !in_array( 'mw.MediaWikiPlayer.loader', 
$parserOutput->getModules() )
-                       ) {
-                               wfDebug( 'Bad TMH parsercache value, throw this 
out.' );
-                               $wikiPage->getTitle()->purgeSquid();
-                               return false;
-                       }
+                       ) || (
+                               self::defaultPlayerMode() === 'videojs' &&
+                               !in_array( 'ext.tmh.video-js', 
$parserOutput->getModules() )
+                       )
+               ) ) {
+                       $wikiPage->getTitle()->purgeSquid();
+                       return false;
                }
                return true;
        }
@@ -851,17 +849,29 @@
        }
 
        /**
+        * Return the configured player mode for this user
         * @return string
         */
        public static function activePlayerMode() {
-               global $wgTmhWebPlayer, $wgTmhUseBetaFeatures, $wgUser;
+               global $wgTmhUseBetaFeatures, $wgUser;
                $context = new RequestContext();
                if ( $wgTmhUseBetaFeatures && class_exists( 'BetaFeatures' ) &&
                        $wgUser->isSafeToLoad() && 
BetaFeatures::isFeatureEnabled( $context->getUser(), 'tmh-videojs' )
                ) {
                        return 'videojs';
                } else {
-                       return $wgTmhWebPlayer;
+                       return self::defaultPlayerMode();
                }
        }
+
+       /**
+        * Return the default configured player mode
+        * This mode is used for anonymous users
+        * @since 1.30
+        * @return string
+        */
+       public static function defaultPlayerMode() {
+               global $wgTmhWebPlayer;
+               return $wgTmhWebPlayer;
+       }
 }
diff --git a/TimedMediaHandler_body.php b/TimedMediaHandler_body.php
index 3ae07c8..110378b 100644
--- a/TimedMediaHandler_body.php
+++ b/TimedMediaHandler_body.php
@@ -198,28 +198,23 @@
         */
        function parserTransformHook( $parser, $file ) {
                $parserOutput = $parser->getOutput();
-               if ( isset( $parserOutput->hasTimedMediaTransform ) ) {
+               if ( $parserOutput->getExtensionData( 
'mw_ext_TMH_hasTimedMediaTransform' ) ) {
                        return;
                }
-               $parserOutput->hasTimedMediaTransform = true;
-               if ( TimedMediaHandlerHooks::activePlayerMode() === 'mwembed' ) 
{
+               $activePlayerMode = TimedMediaHandlerHooks::activePlayerMode();
+               if ( $activePlayerMode === 'mwembed' ) {
                        $parserOutput->addModuleStyles( 
'ext.tmh.thumbnail.styles' );
                        $parserOutput->addModules( [
                                'mw.MediaWikiPlayer.loader',
                                'mw.PopUpMediaTransform',
                                'mw.TMHGalleryHook.js',
                        ] );
-               }
-
-               if ( TimedMediaHandlerHooks::activePlayerMode() === 'videojs' ) 
{
+               } elseif ( $activePlayerMode === 'videojs' ) {
                        $parserOutput->addModuleStyles( 'ext.tmh.player.styles' 
);
                        $parserOutput->addModules( 'ext.tmh.player' );
                }
 
-               if ( $parserOutput ) {
-                       // Not present when run from outputpage hooks, like 
File/Category etc...
-                       $parserOutput->setExtensionData( 
'mw_ext_TMH_hasTimedMediaTransform', true );
-               }
+               $parserOutput->setExtensionData( 
'mw_ext_TMH_hasTimedMediaTransform', true );
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2bf500ffcb2331e0920bc23aeeeaa3577f53f9c7
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to