]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #7194 from nupplaphil/bug/hover
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 27 May 2019 01:20:21 +0000 (21:20 -0400)
committerGitHub <noreply@github.com>
Mon, 27 May 2019 01:20:21 +0000 (21:20 -0400)
frio: Fix hovercard vanish

mod/photos.php
src/Factory/LoggerFactory.php
src/Module/Admin/Logs/Settings.php
src/Module/Admin/Summary.php
src/Module/Profile.php

index 61f1b795301836f96687f3bbc38d8d27d974bf91..b18c06e2a3a4e5bf4b410f47b1a83f3c910b1245 100644 (file)
@@ -29,8 +29,8 @@ use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Map;
 use Friendica\Util\Security;
-use Friendica\Util\Temporal;
 use Friendica\Util\Strings;
+use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 
 function photos_init(App $a) {
@@ -315,7 +315,7 @@ function photos_post(App $a)
                $str_group_deny    = !empty($_POST['group_deny'])    ? perms2str($_POST['group_deny'])    : '';
                $str_contact_deny  = !empty($_POST['contact_deny'])  ? perms2str($_POST['contact_deny'])  : '';
 
-               $resource_id = $a->argv[2];
+               $resource_id = $a->argv[3];
 
                if (!strlen($albname)) {
                        $albname = DateTimeFormat::localNow('Y');
@@ -418,10 +418,11 @@ function photos_post(App $a)
 
                if ($item_id) {
                        $item = Item::selectFirst(['tag', 'inform'], ['id' => $item_id, 'uid' => $page_owner_uid]);
-               }
-               if (DBA::isResult($item)) {
-                       $old_tag    = $item['tag'];
-                       $old_inform = $item['inform'];
+
+                       if (DBA::isResult($item)) {
+                               $old_tag    = $item['tag'];
+                               $old_inform = $item['inform'];
+                       }
                }
 
                if (strlen($rawtags)) {
@@ -524,13 +525,13 @@ function photos_post(App $a)
                                }
                        }
 
-                       $newtag = $old_tag;
+                       $newtag = $old_tag ?? '';
                        if (strlen($newtag) && strlen($str_tags)) {
                                $newtag .= ',';
                        }
                        $newtag .= $str_tags;
 
-                       $newinform = $old_inform;
+                       $newinform = $old_inform ?? '';
                        if (strlen($newinform) && strlen($inform)) {
                                $newinform .= ',';
                        }
@@ -735,7 +736,7 @@ function photos_post(App $a)
                @unlink($src);
                $foo = 0;
                Hook::callAll('photo_post_end',$foo);
-               exit();
+               return;
        }
 
        $exif = $image->orient($src);
@@ -761,7 +762,7 @@ function photos_post(App $a)
        if (!$r) {
                Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG);
                notice(L10n::t('Image upload failed.') . EOL);
-               exit();
+               return;
        }
 
        if ($width > 640 || $height > 640) {
index 444a98cde5c48300b1e15df77037ac8d1991da70..bdd85cf3ae3e1d48aeeb221a9ccb33f2635abd89 100644 (file)
@@ -26,6 +26,7 @@ class LoggerFactory
 {
        /**
         * A list of classes, which shouldn't get logged
+        *
         * @var array
         */
        private static $ignoreClassList = [
@@ -37,8 +38,8 @@ class LoggerFactory
        /**
         * Creates a new PSR-3 compliant logger instances
         *
-        * @param string        $channel The channel of the logger instance
-        * @param Configuration $config  The config
+        * @param string        $channel  The channel of the logger instance
+        * @param Configuration $config   The config
         * @param Profiler      $profiler The profiler of the app
         *
         * @return LoggerInterface The PSR-3 compliant logger instance
@@ -55,8 +56,8 @@ class LoggerFactory
                }
 
                $introspection = new Introspection(self::$ignoreClassList);
-               $level = $config->get('system', 'loglevel');
-               $loglevel = self::mapLegacyConfigDebugLevel((string)$level);
+               $level         = $config->get('system', 'loglevel');
+               $loglevel      = self::mapLegacyConfigDebugLevel((string)$level);
 
                switch ($config->get('system', 'logger_config', 'stream')) {
                        case 'monolog':
@@ -71,7 +72,10 @@ class LoggerFactory
 
                                $stream = $config->get('system', 'logfile');
 
-                               static::addStreamHandler($logger, $stream, $loglevel);
+                               // just add a stream in case it's either writable or not file
+                               if (!is_file($stream) || is_writable($stream)) {
+                                       static::addStreamHandler($logger, $stream, $loglevel);
+                               }
                                break;
 
                        case 'syslog':
@@ -81,7 +85,12 @@ class LoggerFactory
                        case 'stream':
                        default:
                                $stream = $config->get('system', 'logfile');
-                               $logger = new StreamLogger($channel, $stream, $introspection, $loglevel);
+                               // just add a stream in case it's either writable or not file
+                               if (!is_file($stream) || is_writable($stream)) {
+                                       $logger = new StreamLogger($channel, $stream, $introspection, $loglevel);
+                               } else {
+                                       $logger = new VoidLogger();
+                               }
                                break;
                }
 
@@ -105,8 +114,8 @@ class LoggerFactory
         *
         * It should never get filled during normal usage of Friendica
         *
-        * @param string        $channel The channel of the logger instance
-        * @param Configuration $config  The config
+        * @param string        $channel  The channel of the logger instance
+        * @param Configuration $config   The config
         * @param Profiler      $profiler The profiler of the app
         *
         * @return LoggerInterface The PSR-3 compliant logger instance
@@ -120,7 +129,8 @@ class LoggerFactory
                $stream      = $config->get('system', 'dlogfile');
                $developerIp = $config->get('system', 'dlogip');
 
-               if (!isset($developerIp) || !$debugging) {
+               if ((!isset($developerIp) || !$debugging) &&
+                   (!is_file($stream) || is_writable($stream))) {
                        $logger = new VoidLogger();
                        Logger::setDevLogger($logger);
                        return $logger;
@@ -149,7 +159,7 @@ class LoggerFactory
                                break;
 
                        case 'syslog':
-                               $logger = new SyslogLogger($channel, $introspection,  LogLevel::DEBUG);
+                               $logger = new SyslogLogger($channel, $introspection, LogLevel::DEBUG);
                                break;
 
                        case 'stream':
@@ -172,6 +182,7 @@ class LoggerFactory
 
        /**
         * Mapping a legacy level to the PSR-3 compliant levels
+        *
         * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#5-psrlogloglevel
         *
         * @param string $level the level to be mapped
@@ -208,9 +219,9 @@ class LoggerFactory
        /**
         * Adding a handler to a given logger instance
         *
-        * @param LoggerInterface $logger  The logger instance
-        * @param mixed           $stream  The stream which handles the logger output
-        * @param string          $level   The level, for which this handler at least should handle logging
+        * @param LoggerInterface $logger The logger instance
+        * @param mixed           $stream The stream which handles the logger output
+        * @param string          $level  The level, for which this handler at least should handle logging
         *
         * @return void
         *
index d55618454f1a86c1cb5e4610eb81cc2db75d5f79..b9a5e3832d87b3d3dd6027a0c9cb1442a1eb723d 100644 (file)
@@ -22,6 +22,12 @@ class Settings extends BaseAdminModule
                        $debugging = !empty($_POST['debugging']);
                        $loglevel  = defaults($_POST, 'loglevel', LogLevel::ERROR);
 
+                       if (is_file($logfile) &&
+                       !is_writeable($logfile)) {
+                               notice(L10n::t('The logfile \'%s\' is not writable. No logging possible', $logfile));
+                               return;
+                       }
+
                        Config::set('system', 'logfile', $logfile);
                        Config::set('system', 'debugging', $debugging);
                        Config::set('system', 'loglevel', $loglevel);
index 98fd74fb32da214ab0af8d5b08c12a5dc4401a7c..6261ac75caf937057c7ffacf8906726e013d4b8e 100644 (file)
@@ -74,6 +74,23 @@ class Summary extends BaseAdminModule
                                $well_known, $well_known, $a->getBaseURL() . '/help/Install');
                }
 
+               // Check logfile permission
+               if (Config::get('system', 'debugging')) {
+                       $stream = Config::get('system', 'logfile');
+
+                       if (is_file($stream) &&
+                           !is_writeable($stream)) {
+                               $warningtext[] = L10n::t('The logfile \'%s\' is not writable. No logging possible', $stream);
+                       }
+
+                       $stream = Config::get('system', 'dlogfile');
+
+                       if (is_file($stream) &&
+                           !is_writeable($stream)) {
+                               $warningtext[] = L10n::t('The logfile \'%s\' is not writable. No logging possible', $stream);
+                       }
+               }
+
                // check legacy basepath settings
                $configLoader = new ConfigFileLoader($a->getBasePath(), $a->getMode());
                $configCache = new Config\Cache\ConfigCache();
index 30dee0cb56dafa7e89a821fc0a2ca47b18a2e5fa..afebede4d0dcdf155145cfa9c8c51d0340d6a943 100644 (file)
@@ -193,8 +193,8 @@ class Profile extends BaseModule
                        $commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
                        $commvisitor = $commpage && $remote_contact;
 
-                       $a->page['aside'] .= Widget::postedByYear(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
-                       $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? XML::escape($category) : ''));
+                       $a->page['aside'] .= Widget::postedByYear(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'] ?? 0, true);
+                       $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], XML::escape($category));
                        $a->page['aside'] .= Widget::tagCloud();
 
                        if (Security::canWriteToUserWall($a->profile['profile_uid'])) {