Commit fc792a9f authored by Henning Leutz's avatar Henning Leutz 🥋

fix: refactor: mongo longterm cache -> host and database mix solved

parent 014b5535
......@@ -74,6 +74,9 @@
<conf name="type">
<type><![CDATA[string]]></type>
</conf>
<conf name="mongo_host">
<type><![CDATA[string]]></type>
</conf>
<conf name="mongo_database">
<type><![CDATA[string]]></type>
</conf>
......@@ -303,11 +306,16 @@
<locale group="quiqqer/quiqqer" var="quiqqer.settings.longTimeCache.mongo.title"/>
</title>
<input conf="longtime.mongo_database" type="text" placeholder="local">
<input conf="longtime.mongo_host" type="text" placeholder="localhost">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.longTimeCache.mongo.server"/>
</text>
</input>
<input conf="longtime.mongo_database" type="text" placeholder="local">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.longTimeCache.mongo.database"/>
</text>
</input>
<input conf="longtime.mongo_collection" type="text" placeholder="quiqqer.store">
<text>
......
......@@ -210,10 +210,15 @@ class LongTermCache
);
} else {
$conf = $Config->get('longtime');
$database = 'localhost';
$host = 'localhost';
$database = 'local';
$collection = \md5(__FILE__);
// database server
if (!empty($conf['mongo_host'])) {
$host = $conf['mongo_host'];
}
if (!empty($conf['mongo_database'])) {
$database = $conf['mongo_database'];
}
......@@ -222,17 +227,17 @@ class LongTermCache
$collection = $conf['mongo_collection'];
}
if (\strpos($database, 'mongodb://') === false) {
$database = 'mongodb://'.$database;
if (\strpos($host, 'mongodb://') === false) {
$host = 'mongodb://'.$host;
}
if (!empty($conf['mongo_username']) && !empty($conf['mongo_password'])) {
$Client = new \MongoDB\Client($database, [
$Client = new \MongoDB\Client($host, [
"username" => $conf['mongo_username'],
"password" => $conf['mongo_password']
]);
} else {
$Client = new \MongoDB\Client($database);
$Client = new \MongoDB\Client($host);
}
self::$Driver = new QuiqqerMongoDriver([
......
......@@ -120,7 +120,7 @@ class QuiqqerMongoDriver extends AbstractDriver
{
return [
'mongo' => 'quiqqer',
'database' => null,
'database' => 'local',
'collection' => 'quiqqer.store'
];
}
......
......@@ -2714,6 +2714,9 @@
<locale name="quiqqer.settings.longTimeCache.mongo.server">
<de><![CDATA[MongoDB Server]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.database">
<de><![CDATA[MongoDB Datenbank]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.username">
<de><![CDATA[MongoDB Bentzername]]></de>
</locale>
......
......@@ -2654,6 +2654,9 @@ You can also ignore the console user permissions check with '--ignore-file-permi
<locale name="quiqqer.settings.longTimeCache.mongo.title">
<en><![CDATA[Long term cache with a Mongo DB]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.database">
<en><![CDATA[MongoDB Database]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.server">
<en><![CDATA[MongoDB Server]]></en>
</locale>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment