]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Migrate cache purge function to a proper class
[github/shaarli/Shaarli.git] / index.php
index c639a3bce141b734fa13407fbbfef6b29b249c8f..73d9e0224d96fe8a784e66459aa16e39b316a5b0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -53,7 +53,6 @@ require_once __DIR__ . '/vendor/autoload.php';
 // Shaarli library
 require_once 'application/bookmark/LinkUtils.php';
 require_once 'application/config/ConfigPlugin.php';
-require_once 'application/feed/Cache.php';
 require_once 'application/http/HttpUtils.php';
 require_once 'application/http/UrlUtils.php';
 require_once 'application/updater/UpdaterUtils.php';
@@ -78,6 +77,7 @@ use Shaarli\Languages;
 use Shaarli\Netscape\NetscapeBookmarkUtils;
 use Shaarli\Plugin\PluginManager;
 use Shaarli\Render\PageBuilder;
+use Shaarli\Render\PageCacheManager;
 use Shaarli\Render\ThemeUtils;
 use Shaarli\Router;
 use Shaarli\Security\LoginManager;
@@ -530,6 +530,7 @@ function showLinkList($PAGE, $linkDb, $conf, $pluginManager, $loginManager)
  */
 function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionManager, $loginManager)
 {
+    $pageCacheManager = new PageCacheManager($conf->get('resource.page_cache'));
     $updater = new Updater(
         UpdaterUtils::read_updates_file($conf->get('resource.updates')),
         $bookmarkService,
@@ -543,6 +544,8 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
                 $conf->get('resource.updates'),
                 $updater->getDoneUpdates()
             );
+
+            $pageCacheManager->invalidateCaches();
         }
     } catch (Exception $e) {
         die($e->getMessage());
@@ -1029,7 +1032,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
             try {
                 $conf->write($loginManager->isLoggedIn());
                 $history->updateSettings();
-                invalidateCaches($conf->get('resource.page_cache'));
+                $pageCacheManager->invalidateCaches();
             } catch (Exception $e) {
                 error_log(
                     'ERROR while writing config file after configuration update.' . PHP_EOL .
@@ -1914,6 +1917,7 @@ $app->group('/api/v1', function () {
 
 $app->group('', function () {
     $this->get('/login', '\Shaarli\Front\Controller\LoginController:index')->setName('login');
+    $this->get('/logout', '\Shaarli\Front\Controller\LogoutController:index')->setName('logout');
     $this->get('/picture-wall', '\Shaarli\Front\Controller\PictureWallController:index')->setName('picwall');
 })->add('\Shaarli\Front\ShaarliMiddleware');