Avoid "No transaction is active" saveFileDependencies() tests errors
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 12 Sep 2016 03:46:43 +0000 (20:46 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 12 Sep 2016 03:46:43 +0000 (20:46 -0700)
Unit tests run in CLI mode without DBO_TRX

Change-Id: Icee9cf84cb9e057b329dd3960fcc9b238af478a3

includes/resourceloader/ResourceLoaderModule.php

index 43cf78b..44f7e12 100644 (file)
@@ -486,9 +486,11 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
                                        ]
                                );
 
-                               $dbw->onTransactionResolution( function () use ( &$scopeLock ) {
-                                       ScopedCallback::consume( $scopeLock ); // release after commit
-                               } );
+                               if ( $dbw->trxLevel() ) {
+                                       $dbw->onTransactionResolution( function () use ( &$scopeLock ) {
+                                               ScopedCallback::consume( $scopeLock ); // release after commit
+                                       } );
+                               }
                        }
                } catch ( Exception $e ) {
                        wfDebugLog( 'resourceloader', __METHOD__ . ": failed to update DB: $e" );