From 2f2e331c33535d8ae1a8c9d95d03a39b5c8a5885 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 9 Feb 2012 22:44:59 -0800 Subject: [PATCH] bug #274 --- include/plugin.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/include/plugin.php b/include/plugin.php index fe325ac3b0..85b51edff5 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -56,25 +56,29 @@ function reload_plugins() { if(count($parr)) { foreach($parr as $pl) { $pl = trim($pl); - - $t = filemtime('addon/' . $pl . '/' . $pl . '.php'); - foreach($installed as $i) { - if(($i['name'] == $pl) && ($i['timestamp'] != $t)) { - logger('Reloading plugin: ' . $i['name']); - @include_once('addon/' . $pl . '/' . $pl . '.php'); - if(function_exists($pl . '_uninstall')) { - $func = $pl . '_uninstall'; - $func(); + $fname = 'addon/' . $pl . '/' . $pl . '.php'; + + if(file_exists($fname)) { + $t = @filemtime($fname); + foreach($installed as $i) { + if(($i['name'] == $pl) && ($i['timestamp'] != $t)) { + logger('Reloading plugin: ' . $i['name']); + @include_once($fname); + + if(function_exists($pl . '_uninstall')) { + $func = $pl . '_uninstall'; + $func(); + } + if(function_exists($pl . '_install')) { + $func = $pl . '_install'; + $func(); + } + q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d LIMIT 1", + intval($t), + intval($i['id']) + ); } - if(function_exists($pl . '_install')) { - $func = $pl . '_install'; - $func(); - } - q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d LIMIT 1", - intval($t), - intval($i['id']) - ); } } }