From 4dbbbfa5507bba2c05100324237aceb760afe4ed Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Thu, 18 Apr 2024 00:45:55 +0200 Subject: SqlBlobStore: Directly store ES addresses in content table Introduce "es:" which has ?flags= as url parameter and store that instead. Bug: T362566 Change-Id: I9d8409fdbd757ef061aa38ff6248cf614f6ef2de --- includes/externalstore/ExternalStoreFactory.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'includes/externalstore') diff --git a/includes/externalstore/ExternalStoreFactory.php b/includes/externalstore/ExternalStoreFactory.php index 68f4dacb23ff..5e3fa13ad768 100644 --- a/includes/externalstore/ExternalStoreFactory.php +++ b/includes/externalstore/ExternalStoreFactory.php @@ -20,6 +20,7 @@ class ExternalStoreFactory implements LoggerAwareInterface { private $localDomainId; /** @var LoggerInterface */ private $logger; + private $stores = []; /** * @param string[] $externalStores See $wgExternalStores @@ -72,6 +73,10 @@ class ExternalStoreFactory implements LoggerAwareInterface { * @throws ExternalStoreException When $proto is not recognized */ public function getStore( $proto, array $params = [] ) { + $cacheKey = $proto . ':' . json_encode( $params ); + if ( isset( $this->stores[$cacheKey] ) ) { + return $this->stores[$cacheKey]; + } $protoLowercase = strtolower( $proto ); // normalize if ( !$this->protocols || !in_array( $protoLowercase, $this->protocols ) ) { throw new ExternalStoreException( "Protocol '$proto' is not enabled." ); @@ -103,7 +108,8 @@ class ExternalStoreFactory implements LoggerAwareInterface { } // Any custom modules should be added to $wgAutoLoadClasses for on-demand loading - return new $class( $params ); + $this->stores[$cacheKey] = new $class( $params ); + return $this->stores[$cacheKey]; } /** -- cgit v1.2.3