Yaron Koren has submitted this change and it was merged.
Change subject: Add caching of Cargo DB instance
......................................................................
Add caching of Cargo DB instance
Change-Id: Ib1ac8daf23dd1346a14d32aba3e8b2dc7c840b94
---
M CargoUtils.php
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
Yaron Koren: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CargoUtils.php b/CargoUtils.php
index 8d9076a..c8433b1 100644
--- a/CargoUtils.php
+++ b/CargoUtils.php
@@ -8,6 +8,8 @@
class CargoUtils {
+ static $CargoDB = null;
+
/**
*
* @global string $wgDBuser
@@ -20,6 +22,10 @@
* @return Database
*/
public static function getDB() {
+ if ( self::$CargoDB != null && self::$CargoDB->isOpen() ) {
+ return self::$CargoDB;
+ }
+
global $wgDBuser, $wgDBpassword, $wgDBprefix;
global $wgCargoDBserver, $wgCargoDBname, $wgCargoDBuser,
$wgCargoDBpassword, $wgCargoDBtype;
$dbw = wfGetDB( DB_MASTER );
@@ -47,7 +53,8 @@
'tablePrefix' => $dbTablePrefix,
];
- return Database::factory( $wgCargoDBtype, $params );
+ self::$CargoDB = Database::factory( $wgCargoDBtype, $params );
+ return self::$CargoDB;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/316801
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1ac8daf23dd1346a14d32aba3e8b2dc7c840b94
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits