diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | lib/l10n/es.js | 14 | ||||
-rw-r--r-- | lib/l10n/es.json | 14 | ||||
-rw-r--r-- | lib/private/Comments/Comment.php | 9 | ||||
-rw-r--r-- | lib/private/FullTextSearch/Model/IndexDocument.php | 7 | ||||
-rw-r--r-- | lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php | 188 | ||||
-rw-r--r-- | lib/private/Repair/Owncloud/SaveAccountsTableData.php | 24 | ||||
-rw-r--r-- | lib/private/Template/IconsCacher.php | 3 | ||||
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 92 | ||||
-rw-r--r-- | lib/public/FullTextSearch/Model/ISearchRequest.php | 20 | ||||
-rw-r--r-- | lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php | 137 |
12 files changed, 483 insertions, 29 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 581c7b54cc8..8eb33b932e9 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -266,6 +266,7 @@ return array( 'OCP\\FullTextSearch\\Model\\IRunner' => $baseDir . '/lib/public/FullTextSearch/Model/IRunner.php', 'OCP\\FullTextSearch\\Model\\ISearchOption' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchOption.php', 'OCP\\FullTextSearch\\Model\\ISearchRequest' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchRequest.php', + 'OCP\\FullTextSearch\\Model\\ISearchRequestSimpleQuery' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php', 'OCP\\FullTextSearch\\Model\\ISearchResult' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchResult.php', 'OCP\\FullTextSearch\\Model\\ISearchTemplate' => $baseDir . '/lib/public/FullTextSearch/Model/ISearchTemplate.php', 'OCP\\FullTextSearch\\Service\\IIndexService' => $baseDir . '/lib/public/FullTextSearch/Service/IIndexService.php', @@ -926,6 +927,7 @@ return array( 'OC\\FullTextSearch\\Model\\DocumentAccess' => $baseDir . '/lib/private/FullTextSearch/Model/DocumentAccess.php', 'OC\\FullTextSearch\\Model\\IndexDocument' => $baseDir . '/lib/private/FullTextSearch/Model/IndexDocument.php', 'OC\\FullTextSearch\\Model\\SearchOption' => $baseDir . '/lib/private/FullTextSearch/Model/SearchOption.php', + 'OC\\FullTextSearch\\Model\\SearchRequestSimpleQuery' => $baseDir . '/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php', 'OC\\FullTextSearch\\Model\\SearchTemplate' => $baseDir . '/lib/private/FullTextSearch/Model/SearchTemplate.php', 'OC\\GlobalScale\\Config' => $baseDir . '/lib/private/GlobalScale/Config.php', 'OC\\Group\\Backend' => $baseDir . '/lib/private/Group/Backend.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index ff8c960df5f..104ae692b02 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -300,6 +300,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\FullTextSearch\\Model\\IRunner' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/IRunner.php', 'OCP\\FullTextSearch\\Model\\ISearchOption' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchOption.php', 'OCP\\FullTextSearch\\Model\\ISearchRequest' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchRequest.php', + 'OCP\\FullTextSearch\\Model\\ISearchRequestSimpleQuery' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php', 'OCP\\FullTextSearch\\Model\\ISearchResult' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchResult.php', 'OCP\\FullTextSearch\\Model\\ISearchTemplate' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Model/ISearchTemplate.php', 'OCP\\FullTextSearch\\Service\\IIndexService' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Service/IIndexService.php', @@ -960,6 +961,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\FullTextSearch\\Model\\DocumentAccess' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/DocumentAccess.php', 'OC\\FullTextSearch\\Model\\IndexDocument' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/IndexDocument.php', 'OC\\FullTextSearch\\Model\\SearchOption' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchOption.php', + 'OC\\FullTextSearch\\Model\\SearchRequestSimpleQuery' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php', 'OC\\FullTextSearch\\Model\\SearchTemplate' => __DIR__ . '/../../..' . '/lib/private/FullTextSearch/Model/SearchTemplate.php', 'OC\\GlobalScale\\Config' => __DIR__ . '/../../..' . '/lib/private/GlobalScale/Config.php', 'OC\\Group\\Backend' => __DIR__ . '/../../..' . '/lib/private/Group/Backend.php', diff --git a/lib/l10n/es.js b/lib/l10n/es.js index 12bc73b4a35..a41af8a0ddf 100644 --- a/lib/l10n/es.js +++ b/lib/l10n/es.js @@ -31,6 +31,14 @@ OC.L10N.register( "Server version %s or lower is required." : "Se necesita la versión %s o inferior del servidor. ", "Logged in user must be an admin or sub admin" : "El usuario activo debe ser un administrador o subadministrador", "Logged in user must be an admin" : "El usuario registrado debe ser un administrador", + "Wiping of device %s has started" : "La limpieza del dispositivo %s ha empezado", + "Wiping of device »%s« has started" : "La limpieza del dispositivo »%s« ha empezado", + "»%s« started remote wipe" : "»%s« ha empezado la limpieza a distancia", + "Device or application »%s« has started the remote wipe process. You will receive another email once the process has finished" : "El dispositivo o la aplicación »%s« ha empezado el proceso de limpieza a distancia. Vas a recibir otro mensaje por correo una vez que el proceso haya concluido.", + "Wiping of device %s has finished" : "La limpieza del dispositivo %s ha concluido", + "Wiping of device »%s« has finished" : "La limpieza del dispositivo »%s« ha concluido", + "»%s« finished remote wipe" : "»%s« ha acabado la limpieza a distancia", + "Device or application »%s« has finished the remote wipe process." : "El dispositivo o la aplicación »%s« ha concluido el proceso de limpieza a distancia.", "Remote wipe started" : "Barrido remoto comenzado.", "A remote wipe was started on device %s" : "Se ha iniciado un barrido remoto en el dispositivo %s.", "Remote wipe finished" : "Barrido remoto finalizado", @@ -65,7 +73,7 @@ OC.L10N.register( "Empty filename is not allowed" : "No se puede dejar el nombre en blanco.", "App \"%s\" cannot be installed because appinfo file cannot be read." : "No se puede instalar la app \"%s\" debido a que no se puede leer la información de la app.", "App \"%s\" cannot be installed because it is not compatible with this version of the server." : "No se puede instalar la aplicación \"%s\" porque no es compatible con esta versión del servidor.", - "__language_name__" : "Castellano", + "__language_name__" : "Español (España)", "This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no responda.", "Help" : "Ayuda", "Apps" : "Aplicaciones", @@ -184,8 +192,8 @@ OC.L10N.register( "Cannot create \"data\" directory" : "No se puede crear el directorio \"data\"", "This can usually be fixed by giving the webserver write access to the root directory. See %s" : "Habitualmente, esto puede arreglarse dando al servidor web acceso de escritura al directorio raíz. Véase %s", "Permissions can usually be fixed by giving the webserver write access to the root directory. See %s." : "Habitualmente, los permisos pueden arreglarse dando al servidor web acceso de escritura al directorio raíz. Véase %s", - "Setting locale to %s failed" : "Ha fallado la activación del idioma %s ", - "Please install one of these locales on your system and restart your webserver." : "Instale uno de estos idiomas en su sistema y reinicie su servidor web.", + "Setting locale to %s failed" : "Ha fallado la activación de la localización %s ", + "Please install one of these locales on your system and restart your webserver." : "Instale uno de estas localización en su sistema y reinicie su servidor web.", "Please ask your server administrator to install the module." : "Consulte al administrador de su servidor para instalar el módulo.", "PHP module %s not installed." : "El módulo PHP %s no está instalado.", "PHP setting \"%s\" is not set to \"%s\"." : "La opción PHP \"%s\" no es \"%s\".", diff --git a/lib/l10n/es.json b/lib/l10n/es.json index f29d4dbc100..e59b04c6c4d 100644 --- a/lib/l10n/es.json +++ b/lib/l10n/es.json @@ -29,6 +29,14 @@ "Server version %s or lower is required." : "Se necesita la versión %s o inferior del servidor. ", "Logged in user must be an admin or sub admin" : "El usuario activo debe ser un administrador o subadministrador", "Logged in user must be an admin" : "El usuario registrado debe ser un administrador", + "Wiping of device %s has started" : "La limpieza del dispositivo %s ha empezado", + "Wiping of device »%s« has started" : "La limpieza del dispositivo »%s« ha empezado", + "»%s« started remote wipe" : "»%s« ha empezado la limpieza a distancia", + "Device or application »%s« has started the remote wipe process. You will receive another email once the process has finished" : "El dispositivo o la aplicación »%s« ha empezado el proceso de limpieza a distancia. Vas a recibir otro mensaje por correo una vez que el proceso haya concluido.", + "Wiping of device %s has finished" : "La limpieza del dispositivo %s ha concluido", + "Wiping of device »%s« has finished" : "La limpieza del dispositivo »%s« ha concluido", + "»%s« finished remote wipe" : "»%s« ha acabado la limpieza a distancia", + "Device or application »%s« has finished the remote wipe process." : "El dispositivo o la aplicación »%s« ha concluido el proceso de limpieza a distancia.", "Remote wipe started" : "Barrido remoto comenzado.", "A remote wipe was started on device %s" : "Se ha iniciado un barrido remoto en el dispositivo %s.", "Remote wipe finished" : "Barrido remoto finalizado", @@ -63,7 +71,7 @@ "Empty filename is not allowed" : "No se puede dejar el nombre en blanco.", "App \"%s\" cannot be installed because appinfo file cannot be read." : "No se puede instalar la app \"%s\" debido a que no se puede leer la información de la app.", "App \"%s\" cannot be installed because it is not compatible with this version of the server." : "No se puede instalar la aplicación \"%s\" porque no es compatible con esta versión del servidor.", - "__language_name__" : "Castellano", + "__language_name__" : "Español (España)", "This is an automatically sent email, please do not reply." : "Este es un correo enviado automáticamente, por favor no responda.", "Help" : "Ayuda", "Apps" : "Aplicaciones", @@ -182,8 +190,8 @@ "Cannot create \"data\" directory" : "No se puede crear el directorio \"data\"", "This can usually be fixed by giving the webserver write access to the root directory. See %s" : "Habitualmente, esto puede arreglarse dando al servidor web acceso de escritura al directorio raíz. Véase %s", "Permissions can usually be fixed by giving the webserver write access to the root directory. See %s." : "Habitualmente, los permisos pueden arreglarse dando al servidor web acceso de escritura al directorio raíz. Véase %s", - "Setting locale to %s failed" : "Ha fallado la activación del idioma %s ", - "Please install one of these locales on your system and restart your webserver." : "Instale uno de estos idiomas en su sistema y reinicie su servidor web.", + "Setting locale to %s failed" : "Ha fallado la activación de la localización %s ", + "Please install one of these locales on your system and restart your webserver." : "Instale uno de estas localización en su sistema y reinicie su servidor web.", "Please ask your server administrator to install the module." : "Consulte al administrador de su servidor para instalar el módulo.", "PHP module %s not installed." : "El módulo PHP %s no está instalado.", "PHP setting \"%s\" is not set to \"%s\"." : "La opción PHP \"%s\" no es \"%s\".", diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php index c7cafa0524d..c9862c64ca6 100644 --- a/lib/private/Comments/Comment.php +++ b/lib/private/Comments/Comment.php @@ -226,14 +226,19 @@ class Comment implements IComment { * */ public function getMentions() { - $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions); + $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"guest\/[a-f0-9]+\"|\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions); if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { return []; } $uids = array_unique($mentions[0]); $result = []; foreach ($uids as $uid) { - $result[] = ['type' => 'user', 'id' => trim(substr($uid, 1), '"')]; + $cleanUid = trim(substr($uid, 1), '"'); + if (strpos($cleanUid, 'guest/') === 0) { + $result[] = ['type' => 'guest', 'id' => $cleanUid]; + } else { + $result[] = ['type' => 'user', 'id' => $cleanUid]; + } } return $result; } diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php index 55cce902a28..d5bef906021 100644 --- a/lib/private/FullTextSearch/Model/IndexDocument.php +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -359,11 +359,16 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * @return IIndexDocument */ final public function addSubTag(string $sub, string $tag): IIndexDocument { - $this->subTags[$sub] = $tag; + if (!array_key_exists($sub, $this->subTags)) { + $this->subTags[$sub] = []; + } + + $this->subTags[$sub][] = $tag; return $this; } + /** * Set the list of sub tags assigned to the original document. * diff --git a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php new file mode 100644 index 00000000000..a01fb232916 --- /dev/null +++ b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php @@ -0,0 +1,188 @@ +<?php +declare(strict_types=1); + + +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +namespace OC\FullTextSearch\Model; + + +use JsonSerializable; +use OCP\FullTextSearch\Model\ISearchRequestSimpleQuery; + + +/** + * @since 17.0.0 + * + * Class SearchRequestSimpleQuery + * + * @package OC\FullTextSearch\Model + */ +final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonSerializable { + + + /** @var int */ + private $type = 0; + + /** @var string */ + private $field = ''; + + /** @var array */ + private $values = []; + + + /** + * SearchRequestQuery constructor. + * + * @param $type + * @param $field + * + * @since 17.0.0 + */ + public function __construct(string $field, int $type) { + $this->field = $field; + $this->type = $type; + } + + + /** + * Get the compare type of the query + * + * @return int + * @since 17.0.0 + */ + public function getType(): int { + return $this->type; + } + + + /** + * Get the field to apply query + * + * @return string + * @since 17.0.0 + */ + public function getField(): string { + return $this->field; + } + + /** + * Set the field to apply query + * + * @param string $field + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function setField(string $field): ISearchRequestSimpleQuery { + $this->field = $field; + + return $this; + } + + + /** + * Get the value to compare (string) + * + * @return array + * @since 17.0.0 + */ + public function getValues(): array { + return $this->values; + } + + + /** + * Add value to compare (string) + * + * @param string $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValue(string $value): ISearchRequestSimpleQuery { + $this->values[] = $value; + + return $this; + } + + /** + * Add value to compare (int) + * + * @param int $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueInt(int $value): ISearchRequestSimpleQuery { + $this->values[] = $value; + + return $this; + } + + /** + * Add value to compare (array) + * + * @param array $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueArray(array $value): ISearchRequestSimpleQuery { + $this->values[] = $value; + + return $this; + } + + /** + * Add value to compare (bool) + * + * @param bool $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueBool(bool $value): ISearchRequestSimpleQuery { + $this->values[] = $value; + + return $this; + } + + + /** + * @return array|mixed + * @since 17.0.0 + */ + public function jsonSerialize() { + return [ + 'type' => $this->getType(), + 'field' => $this->getField(), + 'values' => $this->getValues() + ]; + } + +} diff --git a/lib/private/Repair/Owncloud/SaveAccountsTableData.php b/lib/private/Repair/Owncloud/SaveAccountsTableData.php index c9e67356fb9..f62f8b56b26 100644 --- a/lib/private/Repair/Owncloud/SaveAccountsTableData.php +++ b/lib/private/Repair/Owncloud/SaveAccountsTableData.php @@ -44,6 +44,8 @@ class SaveAccountsTableData implements IRepairStep { /** @var IConfig */ protected $config; + protected $hasForeignKeyOnPersistentLocks = false; + /** * @param IDBConnection $db * @param IConfig $config @@ -77,6 +79,9 @@ class SaveAccountsTableData implements IRepairStep { } // Remove the table + if ($this->hasForeignKeyOnPersistentLocks) { + $this->db->dropTable('persistent_locks'); + } $this->db->dropTable('accounts'); } @@ -85,14 +90,29 @@ class SaveAccountsTableData implements IRepairStep { */ protected function shouldRun() { $schema = $this->db->createSchema(); + $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); - $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts'; + $tableName = $prefix . 'accounts'; if (!$schema->hasTable($tableName)) { return false; } $table = $schema->getTable($tableName); - return $table->hasColumn('user_id'); + if (!$table->hasColumn('user_id')) { + return false; + } + + if ($schema->hasTable($prefix . 'persistent_locks')) { + $locksTable = $schema->getTable($prefix . 'persistent_locks'); + $foreignKeys = $locksTable->getForeignKeys(); + foreach ($foreignKeys as $foreignKey) { + if ($tableName === $foreignKey->getForeignTableName()) { + $this->hasForeignKeyOnPersistentLocks = true; + } + } + } + + return true; } /** diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index dd83ce78775..3c0a270d3f2 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -238,6 +238,9 @@ class IconsCacher { } } + /** + * Add the icons cache css into the header + */ public function injectCss() { $mtime = $this->timeFactory->getTime(); $file = $this->getCachedList(); diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index c4f89a9c63c..9bdaca3a674 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -32,6 +32,7 @@ use Leafo\ScssPhp\Compiler; use Leafo\ScssPhp\Exception\ParserException; use Leafo\ScssPhp\Formatter\Crunched; use Leafo\ScssPhp\Formatter\Expanded; +use OC\Memcache\NullCache; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\IAppData; use OCP\Files\NotFoundException; @@ -42,6 +43,7 @@ use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; use OCP\ILogger; +use OCP\IMemcache; use OCP\IURLGenerator; use OC\Files\AppData\Factory; use OC\Template\IconsCacher; @@ -84,6 +86,9 @@ class SCSSCacher { /** @var ITimeFactory */ private $timeFactory; + /** @var IMemcache */ + private $lockingCache; + /** * @param ILogger $logger * @param Factory $appDataFactory @@ -111,8 +116,13 @@ class SCSSCacher { $this->defaults = $defaults; $this->serverRoot = $serverRoot; $this->cacheFactory = $cacheFactory; - $this->depsCache = $cacheFactory->createDistributed('SCSS-' . md5($this->urlGenerator->getBaseUrl())); + $this->depsCache = $cacheFactory->createDistributed('SCSS-deps-' . md5($this->urlGenerator->getBaseUrl())); $this->isCachedCache = $cacheFactory->createLocal('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl())); + $lockingCache = $cacheFactory->createDistributed('SCSS-locks-' . md5($this->urlGenerator->getBaseUrl())); + if (!($lockingCache instanceof IMemcache)) { + $lockingCache = new NullCache(); + } + $this->lockingCache = $lockingCache; $this->iconsCacher = $iconsCacher; $this->timeFactory = $timeFactory; } @@ -137,10 +147,7 @@ class SCSSCacher { if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) { // Inject icons vars css if any - if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) { - $this->iconsCacher->injectCss(); - } - return true; + return $this->injectCssVariablesIfAny(); } try { @@ -150,7 +157,35 @@ class SCSSCacher { $folder = $this->appData->newFolder($app); } - $cached = $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); + $lockKey = $webDir . '/' . $fileNameSCSS; + + if (!$this->lockingCache->add($lockKey, 'locked!', 120)) { + $retry = 0; + sleep(1); + while ($retry < 10) { + if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) { + // Inject icons vars css if any + $this->lockingCache->remove($lockKey); + $this->logger->debug('SCSSCacher: ' .$lockKey.' is now available after '.$retry.'s. Moving on...', ['app' => 'core']); + return $this->injectCssVariablesIfAny(); + } + $this->logger->debug('SCSSCacher: scss cache file locked for '.$lockKey, ['app' => 'core']); + sleep($retry); + $retry++; + } + $this->logger->debug('SCSSCacher: Giving up scss caching for '.$lockKey, ['app' => 'core']); + return false; + } + + try { + $cached = $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); + } catch (\Exception $e) { + $this->lockingCache->remove($lockKey); + throw $e; + } + + // Cleaning lock + $this->lockingCache->remove($lockKey); // Inject icons vars css if any if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) { @@ -180,19 +215,24 @@ class SCSSCacher { */ private function isCached(string $fileNameCSS, string $app) { $key = $this->config->getSystemValue('version') . '/' . $app . '/' . $fileNameCSS; - if (!$this->config->getSystemValue('debug') && $cacheValue = $this->isCachedCache->get($key)) { + + // If the file mtime is more recent than our cached one, + // let's consider the file is properly cached + if ($cacheValue = $this->isCachedCache->get($key)) { if ($cacheValue > $this->timeFactory->getTime()) { return true; } } + // Creating file cache if none for further checks try { $folder = $this->appData->getFolder($app); } catch (NotFoundException $e) { - // creating css appdata folder - $folder = $this->appData->newFolder($app); + return false; } + // Checking if file size is coherent + // and if one of the css dependency changed try { $cachedFile = $folder->getFile($fileNameCSS); if ($cachedFile->getSize() > 0) { @@ -201,7 +241,7 @@ class SCSSCacher { if ($deps === null) { $depFile = $folder->getFile($depFileName); $deps = $depFile->getContent(); - //Set to memcache for next run + // Set to memcache for next run $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); } $deps = json_decode($deps, true); @@ -228,13 +268,11 @@ class SCSSCacher { */ private function variablesChanged(): bool { $injectedVariables = $this->getInjectedVariables(); - if ($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) { + if ($this->config->getAppValue('core', 'theming.variables') !== md5($injectedVariables)) { $this->resetCache(); - $this->config->setAppValue('core', 'scss.variables', md5($injectedVariables)); - + $this->config->setAppValue('core', 'theming.variables', md5($injectedVariables)); return true; } - return false; } @@ -289,7 +327,7 @@ class SCSSCacher { '@import "functions.scss";' . '@import "' . $fileNameSCSS . '";'); } catch (ParserException $e) { - $this->logger->error($e, ['app' => 'core']); + $this->logger->logException($e, ['app' => 'core']); return false; } @@ -327,7 +365,11 @@ class SCSSCacher { */ public function resetCache() { $this->injectedVariables = null; - $this->cacheFactory->createDistributed('SCSS-')->clear(); + + // do not clear locks + $this->cacheFactory->createDistributed('SCSS-deps-')->clear(); + $this->cacheFactory->createDistributed('SCSS-cached-')->clear(); + $appDirectory = $this->appData->getDirectoryListing(); foreach ($appDirectory as $folder) { foreach ($folder->getDirectoryListing() as $file) { @@ -338,6 +380,7 @@ class SCSSCacher { } } } + $this->logger->debug('SCSSCacher: css cache cleared!'); } /** @@ -358,7 +401,7 @@ class SCSSCacher { $scss->compile($variables); $this->injectedVariables = $variables; } catch (ParserException $e) { - $this->logger->error($e, ['app' => 'core']); + $this->logger->logException($e, ['app' => 'core']); } return $variables; @@ -391,7 +434,7 @@ class SCSSCacher { return substr($this->urlGenerator->linkToRoute('core.Css.getCss', [ 'fileName' => $fileName, 'appName' => $appName, - 'v' => $this->config->getAppValue('core', 'scss.variables', '0') + 'v' => $this->config->getAppValue('core', 'theming.variables', '0') ]), \strlen(\OC::$WEBROOT) + 1); } @@ -449,4 +492,17 @@ class SCSSCacher { return $webRoot . substr($path, strlen($serverRoot)); } + + /** + * Add the icons css cache in the header if needed + * + * @return boolean true + */ + private function injectCssVariablesIfAny() { + // Inject icons vars css if any + if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) { + $this->iconsCacher->injectCss(); + } + return true; + } } diff --git a/lib/public/FullTextSearch/Model/ISearchRequest.php b/lib/public/FullTextSearch/Model/ISearchRequest.php index 073b4805f63..c7e96913018 100644 --- a/lib/public/FullTextSearch/Model/ISearchRequest.php +++ b/lib/public/FullTextSearch/Model/ISearchRequest.php @@ -322,5 +322,25 @@ interface ISearchRequest { public function getFields(): array; + + /** + * Add a MUST search on an extra field + * + * @param ISearchRequestSimpleQuery $query + * + * @return ISearchRequest + * @since 17.0.0 + */ + public function addSimpleQuery(ISearchRequestSimpleQuery $query): ISearchRequest; + + + /** + * Get the list of queries on extra field. + * + * @return ISearchRequestSimpleQuery[] + * @since 17.0.0 + */ + public function getSimpleQueries(): array; + } diff --git a/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php b/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php new file mode 100644 index 00000000000..fb390f8fff1 --- /dev/null +++ b/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php @@ -0,0 +1,137 @@ +<?php +declare(strict_types=1); + + +/** + * FullTextSearch - Full text search framework for Nextcloud + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Maxence Lange <maxence@artificial-owl.com> + * @copyright 2018 + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +namespace OCP\FullTextSearch\Model; + + +/** + * Interface ISearchRequestSimpleQuery + * + * Add a Query during a Search Request... + * - on a specific field, + * - using a specific value, + * - with a specific comparison + * + * @since 17.0.0 + * + * @package OCP\FullTextSearch\Model + */ +interface ISearchRequestSimpleQuery { + + + const COMPARE_TYPE_TEXT = 1; + const COMPARE_TYPE_KEYWORD = 2; + const COMPARE_TYPE_INT_EQ = 3; + const COMPARE_TYPE_INT_GTE = 4; + const COMPARE_TYPE_INT_GT = 5; + const COMPARE_TYPE_INT_LTE = 6; + const COMPARE_TYPE_INT_LT = 7; + const COMPARE_TYPE_BOOL = 8; + const COMPARE_TYPE_ARRAY = 9; + + + /** + * Get the compare type of the query + * + * @return int + * @since 17.0.0 + */ + public function getType(): int; + + + /** + * Get the field to apply query + * + * @return string + * @since 17.0.0 + */ + public function getField(): string; + + /** + * Set the field to apply query + * + * @param string $field + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function setField(string $field): ISearchRequestSimpleQuery; + + + /** + * Get the all values to compare + * + * @return array + * @since 17.0.0 + */ + public function getValues(): array; + + /** + * Add value to compare (string) + * + * @param string $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValue(string $value): ISearchRequestSimpleQuery; + + /** + * Add value to compare (int) + * + * @param int $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueInt(int $value): ISearchRequestSimpleQuery; + + /** + * Add value to compare (array) + * + * @param array $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueArray(array $value): ISearchRequestSimpleQuery; + + /** + * Add value to compare (bool) + * + * @param bool $value + * + * @return ISearchRequestSimpleQuery + * @since 17.0.0 + */ + public function addValueBool(bool $value): ISearchRequestSimpleQuery; + +} + |