r85602 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85601‎ | r85602 | r85603 >
Date:01:37, 7 April 2011
Author:dale
Status:deferred
Tags:
Comment:
fixed transcoding tests bug where local cache of transcode state was not cleared after completed job ( only affects tests since a separate php instance would query the db )
Modified paths:
  • /trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/tests/phpunit/TestVideoTranscode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TimedMediaHandler/tests/phpunit/TestVideoTranscode.php
@@ -3,7 +3,7 @@
44 * @ingroup timedmedia
55 * @author michael dale
66 */
7 -class TesVideoTranscode extends ApiTestCaseVideoUpload{
 7+class TesVideoTranscode extends ApiTestCaseVideoUpload {
88
99 /**
1010 * Once video files are uploaded test transcoding
@@ -36,7 +36,7 @@
3737
3838 // Check if the transcode jobs were added:
3939 // get results: query jobs table
40 - $db = wfGetDB( DB_SLAVE );
 40+ $db = wfGetDB( DB_MASTER );
4141 $res = $db->select( 'transcode', '*', array(
4242 'transcode_image_name' => ucfirst( $fileName )
4343 ) );
@@ -59,23 +59,25 @@
6060 // Now run the transcode job queue
6161 $status = $this->runTranscodeJobs();
6262
 63+
 64+ $res = $db->select( 'transcode', '*', array(
 65+ 'transcode_image_name' => ucfirst( $fileName )
 66+ ) );
 67+
6368 // Now check if the derivatives were created:
64 - list($result,,) = $this->doApiRequest( $params );
 69+ list($result,,) = $this->doApiRequest( $params );
6570 $derivatives = $this->getDerivativesFromResult( $result );
6671
6772 // Check that every requested encode was encoded:
6873 foreach( $targetEncodes as $transcodeKey => $row ){
6974 $targetEncodeFound = false;
70 - foreach( $derivatives as $derv ){
71 - // The transcode key is always the last part of the file name:
 75+ foreach( $derivatives as $derv ){
 76+ // The transcode key is always the last part of the file name:
7277 if( substr( $derv['src'], -1 * strlen( $transcodeKey ) ) == $transcodeKey ){
73 - // Check that the derivative matches our encode settings:
74 - $this->assertEquals( $derv['width'], WebVideoTranscode::$derivativeSettings[ $row->transcode_key ]['width'] );
75 - // We can't really check "bandwith" since the bitrate does not always exactly match up with encode settings
7678 $targetEncodeFound = true;
7779 }
7880 }
79 - // Test that all target encodes are found:
 81+ // Test that target encode was found:
8082 $this->assertTrue( $targetEncodeFound );
8183 }
8284
Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php
@@ -136,7 +136,10 @@
137137 * Invalidate the cache of all pages where the video is displayed
138138 */
139139 function invalidateCache(){
140 - // the file page cache should be invalidated:
 140+ // The static cache of webVideoTranscode should be cleared
 141+ webVideoTranscode::clearTranscodeCache();
 142+
 143+ // The file page cache should be invalidated:
141144 $this->title->invalidateCache();
142145
143146 // TODO if the video is used in over 500 pages add to 'job queue'
Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
@@ -288,6 +288,12 @@
289289 // Else return the state:
290290 return self::$transcodeStateCache[$fileName][$transcodeKey]['ready'];
291291 }
 292+ /**
 293+ * Clear the transcode state cache:
 294+ */
 295+ public static function clearTranscodeCache(){
 296+ self::$transcodeStateCache = null;
 297+ }
292298
293299 /**
294300 * Populates the local transcoding state cache with the current DB state of transcodes
@@ -324,7 +330,7 @@
325331 }
326332
327333 /**
328 - * Try to add a source to the sources param
 334+ * Try to add a source to the sources list
329335 * if the source is not found update the job queue
330336 */
331337 public static function tryAddSource( &$file, &$sources, $transcodeKey, $dataPrefix = '' ){

Status & tagging log