]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Theme.php
Avoid memory issue in exception
[friendica.git] / src / Core / Theme.php
index 1ea39d606c763556a8ab94934e5b98e61e217801..62dfaa51f3072f45ce8d3bc56e871b2f0f4e3d5a 100644 (file)
@@ -7,8 +7,9 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
-use Friendica\Core\Logger;
-use Friendica\Core\System;
+use Friendica\Model\Profile;
+
+require_once 'boot.php';
 
 /**
  * Some functions to handle themes
@@ -89,8 +90,9 @@ class Theme
         *
         * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg].
         *
-        * @param sring $theme The name of the theme
+        * @param string $theme The name of the theme
         * @return string
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function getScreenshot($theme)
        {
@@ -147,6 +149,7 @@ class Theme
         * @param string $file Filename
         * @param string $root Full root path
         * @return string Path to the file or empty string if the file isn't found
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function getPathForFile($file, $root = '')
        {
@@ -192,18 +195,19 @@ class Theme
         */
        public static function getStylesheetPath($theme)
        {
+               if (!file_exists('view/theme/' . $theme . '/style.php')) {
+                       return 'view/theme/' . $theme . '/style.css';
+               }
+
                $a = BaseObject::getApp();
 
-               $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
-               if (file_exists('view/theme/' . $theme . '/style.php')) {
-                       if ($a->is_mobile) {
-                               // Workaround for iOS Safari not sending the cookie for static files
-                               return 'view/theme/' . $theme . '/style' . $opts;
-                       } else {
-                               return 'view/theme/' . $theme . '/style.pcss' . $opts;
-                       }
+               $query_params = [];
+
+               $puid = Profile::getThemeUid($a);
+               if ($puid) {
+                       $query_params['puid'] = $puid;
                }
 
-               return 'view/theme/' . $theme . '/style.css';
+               return 'view/theme/' . $theme . '/style.pcss' . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
        }
 }