creecros / Customizer

Kanboard - Customizer adds GUI for logo, favicon and themes
MIT License
199 stars 28 forks source link

Undefined variable: plugin_folder in ... /plugins/Customizer/Plugin.php on line 128 #123

Closed Blackrapier-muc closed 3 years ago

Blackrapier-muc commented 3 years ago

After upgrading my Kanboard instance from 1.2.9 to the current 1.2.18, the following message always appears in the log:

2021/03/01 15:15:36 [error] 16776 # 16776: * 675 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined variable: plugin_folder in /var/www/html/kanboard/plugins/Customizer/Plugin.php on line 128PHP message: PHP Notice: Undefined variable: plugin_folder in /var/www/html/kanboard/plugins/Customizer/Plugin.php on line 129 "while reading response header from upstream, client: *. * . *. *, server: xx.xxxxx.xxx, request: "GET/?controller=SoundNotificationController&action=soundNotifications&plugin=SoundNotification&_=1614608036365 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host:" xx.xxxxx.xxx

This error also occurs when accessing the TaskViewController, UserAjaxController or the BoardViewController

The following versions are installed on the server: PHP version: 7.4.3 PHP SAPI: fpm-fcgi HTTP client: cURL Operating system version: Linux 5.4.0-66-generic Database driver: MySQL Database version: 10.3.25-MariaDB-0ubuntu0.20.04.1

Installed plugins:

eguaj commented 3 years ago

I concur, I observed the same warning: the $plugin_folder is effectively not defined in the onStartup() method.

I fixed it by adding the $plugin_folder = basename(PLUGINS_DIR); directive as seen in the initialize() method:

--- Customizer/Plugin.php.orig  2021-02-10 14:18:24.000000000 +0100
+++ Customizer/Plugin.php       2021-03-01 16:11:05.921069209 +0100
@@ -123,6 +123,7 @@

     public function onStartup()
     {
+        $plugin_folder = basename(PLUGINS_DIR);
         Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
         $user_id = $this->customizerFileModel->getUserSessionId();
         $user_theme = $this->userMetadataModel->get($user_id, 'themeSelection', $this->configModel->get('themeSelection', $plugin_folder.'/Customizer/Assets/css/theme.css' ));

This missing $project_folder var was also throwing the following PHP Warning:

PHP Warning:  filemtime(): stat failed for /Customizer/Assets/css/theme.css in /.../kanboard/app/Helper/AssetHelper.php on line 37

I also had the following PHP Warning that I fixed by setting the ownership of the plugins/Customizer/Assets/css/userthemes to www-data (chown -R www-data: plugins/Customizer/Assets/css/userthemes):

PHP Warning:  unlink(plugins/Customizer/Assets/css/userthemes/.gitignore): Permission denied in /.../kanboard/plugins/Customizer/Plugin.php on line 30
creecros commented 3 years ago

when I get a chance I can add it to the repo, unless you want to make a PR.

creecros commented 3 years ago

@eguaj @Blackrapier-muc

Think this is all set now. Added plugin dir variable to onStartup(), and removed userthemes folder from inital folder structure, letting Customizer make the folder with 755 permissions and correct user, to avoid permissions issues in the future.