From fd1ddad98df45bc3c18be7980c1cbe68ce6b219c Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 26 Sep 2020 14:18:01 +0200 Subject: Add mutex on datastore I/O operations To make sure that there is no concurrent operation on the datastore file. Fixes #1132 --- application/container/ContainerBuilder.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'application/container/ContainerBuilder.php') diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index 55bb51b5..c21d58dd 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Shaarli\Container; +use malkusch\lock\mutex\FlockMutex; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Bookmark\BookmarkServiceInterface; use Shaarli\Config\ConfigManager; @@ -84,6 +85,7 @@ class ContainerBuilder return new BookmarkFileService( $container->conf, $container->history, + new FlockMutex(fopen(SHAARLI_MUTEX_FILE, 'r'), 2), $container->loginManager->isLoggedIn() ); }; -- cgit v1.2.3 From 4cf3564d28dc8e4d08a3e64f09ad045ffbde97ae Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 25 Sep 2020 13:29:36 +0200 Subject: Add a setting to retrieve bookmark metadata asynchrounously - There is a new standalone script (metadata.js) which requests a new controller to get bookmark metadata and fill the form async - This feature is enabled with the new setting: general.enable_async_metadata (enabled by default) - general.retrieve_description is now enabled by default - A small rotating loader animation has a been added to bookmark inputs when metadata is being retrieved (default template) - Custom JS htmlentities has been removed and mathiasbynens/he library is used instead Fixes #1563 --- application/container/ContainerBuilder.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'application/container/ContainerBuilder.php') diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index c21d58dd..fd94a1c3 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php @@ -14,6 +14,7 @@ use Shaarli\Front\Controller\Visitor\ErrorController; use Shaarli\Front\Controller\Visitor\ErrorNotFoundController; use Shaarli\History; use Shaarli\Http\HttpAccess; +use Shaarli\Http\MetadataRetriever; use Shaarli\Netscape\NetscapeBookmarkUtils; use Shaarli\Plugin\PluginManager; use Shaarli\Render\PageBuilder; @@ -90,6 +91,10 @@ class ContainerBuilder ); }; + $container['metadataRetriever'] = function (ShaarliContainer $container): MetadataRetriever { + return new MetadataRetriever($container->conf, $container->httpAccess); + }; + $container['pageBuilder'] = function (ShaarliContainer $container): PageBuilder { return new PageBuilder( $container->conf, -- cgit v1.2.3 From b38a1b0209f546d4824a0db81a34c4e30fcdebaf Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 20 Oct 2020 11:47:07 +0200 Subject: Use PSR-3 logger for login attempts Fixes #1122 --- application/container/ContainerBuilder.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'application/container/ContainerBuilder.php') diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index fd94a1c3..d84418ad 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Shaarli\Container; use malkusch\lock\mutex\FlockMutex; +use Psr\Log\LoggerInterface; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Bookmark\BookmarkServiceInterface; use Shaarli\Config\ConfigManager; @@ -49,6 +50,9 @@ class ContainerBuilder /** @var LoginManager */ protected $login; + /** @var LoggerInterface */ + protected $logger; + /** @var string|null */ protected $basePath = null; @@ -56,12 +60,14 @@ class ContainerBuilder ConfigManager $conf, SessionManager $session, CookieManager $cookieManager, - LoginManager $login + LoginManager $login, + LoggerInterface $logger ) { $this->conf = $conf; $this->session = $session; $this->login = $login; $this->cookieManager = $cookieManager; + $this->logger = $logger; } public function build(): ShaarliContainer @@ -72,6 +78,7 @@ class ContainerBuilder $container['sessionManager'] = $this->session; $container['cookieManager'] = $this->cookieManager; $container['loginManager'] = $this->login; + $container['logger'] = $this->logger; $container['basePath'] = $this->basePath; $container['plugins'] = function (ShaarliContainer $container): PluginManager { @@ -99,6 +106,7 @@ class ContainerBuilder return new PageBuilder( $container->conf, $container->sessionManager->getSession(), + $container->logger, $container->bookmarkService, $container->sessionManager->generateToken(), $container->loginManager->isLoggedIn() -- cgit v1.2.3 From b99e00f7cd5f7e2090f44cd97bfb426db55340c2 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 8 Nov 2020 15:02:45 +0100 Subject: Manually fix remaining PHPCS errors --- application/container/ContainerBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/container/ContainerBuilder.php') diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index d84418ad..f0234eca 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php @@ -158,7 +158,7 @@ class ContainerBuilder $container['updater'] = function (ShaarliContainer $container): Updater { return new Updater( - UpdaterUtils::read_updates_file($container->conf->get('resource.updates')), + UpdaterUtils::readUpdatesFile($container->conf->get('resource.updates')), $container->bookmarkService, $container->conf, $container->loginManager->isLoggedIn() -- cgit v1.2.3