From 0c9e55b0c9719a0817a442f994f26d9ac552c73b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 14 Mar 2016 03:41:28 -0400
Subject: [PATCH] Fix PHP warning when defaults.inc.php is not readable

---
 program/include/rcmail_install.php |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php
index af27e29..40b0aa9 100644
--- a/program/include/rcmail_install.php
+++ b/program/include/rcmail_install.php
@@ -568,26 +568,30 @@
   * Return a list with available subfolders of the plugins directory
   * (with their associated description in composer.json)
   */
-  function list_plugins() 
+  function list_plugins()
   {
     $plugins = array();
     $plugin_dir = INSTALL_PATH . 'plugins/';
 
-    foreach (glob($plugin_dir . '*') as $path) 
-    {
+    foreach (glob($plugin_dir . '*') as $path) {
+      if (!is_dir($path)) {
+        continue;
+      }
 
-      if (is_dir($path) && is_readable($path.'/composer.json'))
-      {
-        $file_json = json_decode(file_get_contents($path.'/composer.json'));
+      if (is_readable($path.'/composer.json')) {
+        $file_json   = json_decode(file_get_contents($path.'/composer.json'));
         $plugin_desc = $file_json->description ?: 'N/A';
       }
-      else
-      {
+      else {
         $plugin_desc = 'N/A';
       }
 
-      $name = substr($path, strlen($plugin_dir));
-      $plugins[] = array('name' => $name, 'desc' => $plugin_desc, 'enabled' => in_array($name, $this->config['plugins']));
+      $name      = substr($path, strlen($plugin_dir));
+      $plugins[] = array(
+        'name'    => $name,
+        'desc'    => $plugin_desc,
+        'enabled' => in_array($name, (array) $this->config['plugins'])
+      );
     }
 
     return $plugins;

--
Gitblit v1.9.1