]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fix issue 'You are not authorized to add a link' with thumbnails enabled 1199/head
authorArthurHoaro <arthur@hoa.ro>
Fri, 10 Aug 2018 15:09:51 +0000 (17:09 +0200)
committerArthurHoaro <arthur@hoa.ro>
Fri, 10 Aug 2018 15:09:51 +0000 (17:09 +0200)
Do not try to alter the datastore by updating thumbnails if the user isn't logged in.

Also, do not enable thumbnails if PHP GD extension is not installed/loaded

application/Updater.php
index.php

index c2aa1568cdc01534a3e1efd885e494536884342e..480bff8267956ad82e12d3a4169e7b09f60ee135 100644 (file)
@@ -502,7 +502,7 @@ class Updater
             return true;
         }
 
-        $thumbnailsEnabled = $this->conf->get('thumbnail.enable_thumbnails', true);
+        $thumbnailsEnabled = extension_loaded('gd') && $this->conf->get('thumbnail.enable_thumbnails', true);
         $this->conf->set('thumbnails.mode', $thumbnailsEnabled ? Thumbnailer::MODE_ALL : Thumbnailer::MODE_NONE);
         $this->conf->set('thumbnails.width', 125);
         $this->conf->set('thumbnails.height', 90);
index 925d47a5e476b55260e9cda84fbfa33e554b66cc..4b86a3e2c17ece7338ad04646cedee6150bbbd47 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1635,9 +1635,9 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager)
         uasort($taglist, 'strcasecmp');
         $link['taglist'] = $taglist;
 
-        // Thumbnails enabled, not a note,
+        // Logged in, thumbnails enabled, not a note,
         // and (never retrieved yet or no valid cache file)
-        if ($thumbnailsEnabled && $link['url'][0] != '?'
+        if ($loginManager->isLoggedIn() && $thumbnailsEnabled && $link['url'][0] != '?'
             && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail'])))
         ) {
             $elem = $LINKSDB[$keys[$i]];