3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 namespace MediaWiki\Storage
;
26 use Wikimedia\Rdbms\LBFactory
;
29 * Service for instantiating BlobStores
31 * This can be used to create BlobStore objects for other wikis.
35 class BlobStoreFactory
{
57 public function __construct(
59 WANObjectCache
$cache,
63 $this->lbFactory
= $lbFactory;
64 $this->cache
= $cache;
65 $this->config
= $mainConfig;
66 $this->contLang
= $contLang;
72 * @param bool|string $wikiId The ID of the target wiki database. Use false for the local wiki.
76 public function newBlobStore( $wikiId = false ) {
77 return $this->newSqlBlobStore( $wikiId );
81 * @internal Please call newBlobStore and use the BlobStore interface.
83 * @param bool|string $wikiId The ID of the target wiki database. Use false for the local wiki.
85 * @return SqlBlobStore
87 public function newSqlBlobStore( $wikiId = false ) {
88 $lb = $this->lbFactory
->getMainLB( $wikiId );
89 $store = new SqlBlobStore(
95 $store->setCompressBlobs( $this->config
->get( 'CompressRevisions' ) );
96 $store->setCacheExpiry( $this->config
->get( 'RevisionCacheExpiry' ) );
97 $store->setUseExternalStore( $this->config
->get( 'DefaultExternalStore' ) !== false );
99 if ( $this->config
->get( 'LegacyEncoding' ) ) {
100 $store->setLegacyEncoding( $this->config
->get( 'LegacyEncoding' ), $this->contLang
);