Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable 4.4.8 #2712

Merged
merged 97 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
7a0cbbe
fix: debug option show stack trace
pifou25 May 18, 2024
c5e58f7
Merge branch 'jeedom:alpha' into fix/debug_traces
pifou25 May 26, 2024
4c59313
Merge branch 'jeedom:alpha' into fix/debug_traces
pifou25 May 27, 2024
ca52393
fix deprecated notices
pifou25 May 26, 2024
30e0895
Merge branch 'jeedom:alpha' into fix/debug_traces
pifou25 May 31, 2024
f7d0c89
fix: debug option show stack trace
pifou25 May 18, 2024
2c023f6
remove unused toggle function from core.js
pifou25 Jun 1, 2024
7d58339
Merge pull request #2654 from pifou25/fix/debug_traces
zoic21 Jun 6, 2024
4d7c6f3
Merge pull request #2657 from pifou25/fix/notices
zoic21 Jun 6, 2024
8a5aa10
pump to 4.48
zoic21 Jun 6, 2024
4641cef
update changelog
zoic21 Jun 6, 2024
28efa92
fix #2668
zoic21 Jun 6, 2024
4258c31
bugfix
zoic21 Jun 6, 2024
b2252f3
Fix #2671
zoic21 Jun 6, 2024
e2a7266
update changelog
zoic21 Jun 6, 2024
e9d1379
python2 version not displayed in health page because output was on st…
Mips2648 Jun 7, 2024
d74c59b
check database on sick.php
pifou25 Jun 8, 2024
72f2683
bugfix
zoic21 Jun 8, 2024
37ae963
Update sleep.default.html
Phpvarious Jun 10, 2024
a164009
Merge pull request #2682 from Phpvarious/patch-25
zoic21 Jun 11, 2024
76d1a2a
PR #2675
zoic21 Jun 11, 2024
1d8622c
update changelog
zoic21 Jun 11, 2024
6445d10
typo
zoic21 Jun 11, 2024
778ca42
typo
zoic21 Jun 11, 2024
8e81e54
Update utils.inc.php
zoic21 Jun 11, 2024
bc16446
Update user.class.php
zoic21 Jun 11, 2024
c2c476c
Update user.class.php
zoic21 Jun 11, 2024
d247ded
Update reboot.js
Phpvarious Jun 12, 2024
f9e29d4
fix #2686
zoic21 Jun 12, 2024
2503f8f
update changelog
zoic21 Jun 12, 2024
adf8f8e
Begin #2687
zoic21 Jun 12, 2024
6bfcac5
update changelog
zoic21 Jun 12, 2024
dca1c99
continue #2687
zoic21 Jun 12, 2024
518c570
continue #2687
zoic21 Jun 12, 2024
875d04e
continue #2687
zoic21 Jun 12, 2024
cc139b6
update changelog
zoic21 Jun 12, 2024
512efd0
refactoring on scenarios list filter
noodom Jun 13, 2024
2151776
Update scenario.default.html
noodom Jun 13, 2024
8cbb41b
for #2689
zoic21 Jun 13, 2024
d6c28bb
#2689
zoic21 Jun 13, 2024
0bab608
update changelog
zoic21 Jun 13, 2024
d2c5500
Merge pull request #2685 from Phpvarious/patch-26
zoic21 Jun 14, 2024
2459e32
Update desktop.main.css
Phpvarious Jun 16, 2024
54d592e
used cache for plugin size
zoic21 Jun 17, 2024
aa1994a
typo
zoic21 Jun 17, 2024
3a749a5
improvements
zoic21 Jun 17, 2024
5f83b64
Merge pull request #2691 from Phpvarious/patch-27
Sekiro-kost Jun 17, 2024
50df268
update changelog
zoic21 Jun 17, 2024
4b969a9
fix #2621
zoic21 Jun 17, 2024
a8b52e6
update changelog
zoic21 Jun 17, 2024
7d11d58
fix #2693
zoic21 Jun 18, 2024
8f06a40
Linkg to #2693
zoic21 Jun 18, 2024
0421bc3
Link to #2693
zoic21 Jun 18, 2024
3debe78
update changelog
zoic21 Jun 18, 2024
7bde32c
Handle user for fulldata
zoic21 Jun 19, 2024
adb5afe
Prevent warning on sql request
zoic21 Jun 19, 2024
b64f560
Merge pull request #2677 from pifou25/sick_database
zoic21 Jun 19, 2024
c24bd59
Merge pull request #2674 from Mips2648/fix-python-version-not-displayed
zoic21 Jun 19, 2024
8891373
update changelog
zoic21 Jun 19, 2024
4aad688
Merge pull request #2688 from noodom/patch-23
zoic21 Jun 19, 2024
92a40c4
update changelog
zoic21 Jun 19, 2024
4db7139
protect function system::fuserk
Mips2648 Jun 19, 2024
7fb8580
Begin handle #2698
zoic21 Jun 19, 2024
e051f63
Continue #2698
zoic21 Jun 19, 2024
ceb7905
add cronIsDue for #2698
zoic21 Jun 19, 2024
1207d95
update changelog
zoic21 Jun 19, 2024
b7859f7
Merge pull request #2697 from Mips2648/deb12-fix-argument-must-be-of-…
zoic21 Jun 20, 2024
08837b5
Update changelog
zoic21 Jun 20, 2024
38bcde5
Fix for #2699
zoic21 Jun 20, 2024
63952a6
#2699
zoic21 Jun 20, 2024
590afd3
update changelog
zoic21 Jun 20, 2024
e618f9d
#2699
zoic21 Jun 20, 2024
453c2f8
patch usage of pip list if non-standard version format
Mips2648 Jun 21, 2024
3e7a4f0
fix: deprecated and warning notices
pifou25 Jun 22, 2024
570bbd6
fix: manage php8 migration for curl functions
pifou25 Jun 22, 2024
d6d7a08
json_decode as as array, not object
Flobul Jun 22, 2024
3896832
Merge pull request #2700 from Mips2648/patch-for-pip-non-standard-ver…
zoic21 Jun 22, 2024
e274ef9
fix #2704
zoic21 Jun 23, 2024
3934d23
Link to #2705
zoic21 Jun 23, 2024
50a04c6
fix #2705
zoic21 Jun 23, 2024
4cc001b
fix: catch redis unavailable error and fallback to default cache
pifou25 Jun 23, 2024
1cac8ee
Merge pull request #2695 from jeedom/zoic21-patch-1
zoic21 Jun 24, 2024
b26a315
Implemente #2707
zoic21 Jun 24, 2024
d55c18b
Merge pull request #2706 from pifou25/fix/redis_check
zoic21 Jun 24, 2024
340708d
Merge pull request #2703 from Flobul/patch-7
zoic21 Jun 24, 2024
d134578
Merge pull request #2702 from pifou25/fix/curl_php8
zoic21 Jun 24, 2024
3cc679a
typo
zoic21 Jun 24, 2024
e5e2af6
typo
zoic21 Jun 24, 2024
51ad668
update changlog
zoic21 Jun 24, 2024
8bd42ce
Merge pull request #2701 from pifou25/fix/deprecated_notices
zoic21 Jun 24, 2024
bc3a42c
update changelog
zoic21 Jun 24, 2024
56fa6b8
Merge pull request #2708 from jeedom/alpha
zoic21 Jun 24, 2024
6899050
fix "Call to undefined method jeedom::getOsVersion()"
Mips2648 Jun 24, 2024
ea800cd
Merge pull request #2709 from Mips2648/alpha
zoic21 Jun 24, 2024
1fa6f11
update changelog
zoic21 Jun 24, 2024
1c911fc
Merge pull request #2710 from jeedom/alpha
zoic21 Jun 24, 2024
d5f449e
Update plugin.class.php
zoic21 Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/ajax/plugin.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if (!isConnect('admin')) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$plugin = plugin::byId(init('id'));
$plugin = plugin::byId(init('id'),init('full',0));
$update = update::byLogicalId(init('id'));
$return = utils::o2a($plugin);
$return['activate'] = $plugin->isActive();
Expand Down
19 changes: 18 additions & 1 deletion core/api/jeeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
/** @var bool $_RESTRICTED */
global $_RESTRICTED;
$_RESTRICTED = false;


if (init('type') != '') {
try {

if (init('type') == 'ask') {
if (trim(init('token')) == '' || strlen(init('token')) < 64) {
throw new Exception(__('Commande inconnue ou Token invalide', __FILE__));
Expand All @@ -60,6 +63,13 @@
sleep(5);
throw new Exception(__('Vous n\'êtes pas autorisé à effectuer cette action, IP :', __FILE__) . ' ' . getClientIp());
}

if(config::byKey('api::forbidden::method', 'core', '') !== '' && preg_match(config::byKey('api::forbidden::method', 'core', ''), init('type'))){
throw new Exception(__('Cette demande n\'est autorisée', __FILE__) . ' ' . getClientIp());
}
if(config::byKey('api::allow::method', 'core', '') !== '' && !preg_match(config::byKey('api::allow::method', 'core', ''), init('type'))){
throw new Exception(__('Cette demande n\'est autorisée', __FILE__) . ' ' . getClientIp());
}
$type = init('type');
log::add('api', 'debug', __('Demande sur l\'api http venant de :', __FILE__) . ' ' . getClientIp() . ' => ' . json_encode($_GET));

Expand Down Expand Up @@ -225,7 +235,7 @@
if ($type == 'fullData') {
log::add('api', 'debug', __('Demande API pour les commandes', __FILE__));
header('Content-Type: application/json');
echo json_encode(jeeObject::fullData(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024);
echo json_encode(jeeObject::fullData(null,$_USER_GLOBAL), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE, 1024);
die();
}
if ($type == 'variable') {
Expand Down Expand Up @@ -269,6 +279,13 @@
throw new Exception(__('Requête invalide. Version JSON-RPC invalide :', __FILE__) . ' ' . $jsonrpc->getJsonrpc(), -32001);
}

if(config::byKey('api::forbidden::method', 'core', '') !== '' && preg_match(config::byKey('api::forbidden::method', 'core', ''), $jsonrpc->getMethod())){
throw new Exception(__('Cette demande n\'est autorisée', __FILE__));
}
if(config::byKey('api::allow::method', 'core', '') !== '' && !preg_match(config::byKey('api::allow::method', 'core', ''), $jsonrpc->getMethod())){
throw new Exception(__('Cette demande n\'est autorisée', __FILE__) . ' ' . getClientIp());
}

$params = $jsonrpc->getParams();

if (!isset($params['plugin']) || $params['plugin'] == '') {
Expand Down
9 changes: 9 additions & 0 deletions core/class/DB.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ public static function &Prepare($_query, $_params, $_fetchType = self::FETCH_TYP
$stmt = static::getConnection()->prepare($_query);
$res = NULL;
if ($stmt != false && $stmt->execute($_params) != false) {
if(preg_match('/^update|^replace|^delete|^create|^drop|^alter|^truncate/i', $_query)){
$errorInfo = $stmt->errorInfo();
if ($errorInfo[0] != 0000) {
static::$lastConnection = 0;
throw new Exception('[MySQL] Error code : ' . $errorInfo[0] . ' (' . $errorInfo[1] . '). ' . $errorInfo[2] . ' : ' . $_query);
}
static::$lastConnection = strtotime('now');
return $res;
}
if ($_fetchType == static::FETCH_TYPE_ROW) {
if ($_fetch_opt === null) {
$res = $stmt->fetch($_fetch_param);
Expand Down
50 changes: 32 additions & 18 deletions core/class/cache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,46 +96,60 @@ public static function stats($_details = false) {
* @name getCache()
* @access public
* @static
* @param string $_engine to override the current cache defined in configuration
* @return \Doctrine\Common\Cache\CacheProvider
*/
public static function getCache() {
if (self::$cache !== null) {
public static function getCache($_engine = null) {
if ($_engine === null && self::$cache !== null) {
return self::$cache;
}
$engine = config::byKey('cache::engine');
if ($engine == 'MemcachedCache' && !class_exists('memcached')) {
$engine = 'FilesystemCache';
config::save('cache::engine', 'FilesystemCache');
}
if ($engine == 'RedisCache' && !class_exists('redis')) {
$engine = 'FilesystemCache';
config::save('cache::engine', 'FilesystemCache');
if( $_engine === null){
// get current cache
$engine = config::byKey('cache::engine');
}else{
// override existing configuration
$engine = $_engine;
config::save('cache::engine', $_engine);
}
switch ($engine) {
case 'FilesystemCache':
self::$cache = new \Doctrine\Common\Cache\FilesystemCache(self::getFolder());
break;
case 'PhpFileCache':
self::$cache = new \Doctrine\Common\Cache\FilesystemCache(self::getFolder());
break;
case 'MemcachedCache':
// check if memcached extention is available
if (!class_exists('memcached')) {
log::add( __CLASS__, 'error', 'memcached extension not installed, fall back to FilesystemCache.');
return self::getCache( 'FilesystemCache');
}
$memcached = new Memcached();
$memcached->addServer(config::byKey('cache::memcacheaddr'), config::byKey('cache::memcacheport'));
self::$cache = new \Doctrine\Common\Cache\MemcachedCache();
self::$cache->setMemcached($memcached);
break;
case 'RedisCache':
// check if redis extension is available
if (!class_exists('redis')) {
log::add( __CLASS__, 'error', 'redis extension not installed, fall back to FilesystemCache.');
return self::getCache( 'FilesystemCache');
}
$redis = new Redis();
$redisAddr = config::byKey('cache::redisaddr');
if (strncmp($redisAddr, '/', 1) === 0) {
$redis->connect($redisAddr);
} else {
$redis->connect($redisAddr, config::byKey('cache::redisport'));
try{
// try to connect to redis
if (strncmp($redisAddr, '/', 1) === 0) {
$redis->connect($redisAddr);
} else {
$redis->connect($redisAddr, config::byKey('cache::redisport'));
}
}catch( Exception $e){
// error : fall back to FilesystemCache
log::add( __CLASS__, 'error', 'Unable to connect to redis instance, fall back to FilesystemCache.'."\n".$e->getMessage());
return self::getCache( 'FilesystemCache');
}
self::$cache = new \Doctrine\Common\Cache\RedisCache();
self::$cache->setRedis($redis);
break;
default:
default: // default is FilesystemCache
self::$cache = new \Doctrine\Common\Cache\FilesystemCache(self::getFolder());
break;
}
Expand Down
2 changes: 1 addition & 1 deletion core/class/cmd.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ public function toHtml($_version = 'dashboard', $_options = '') {
$coupleArray = explode('|', $element);
$cmdValue = $this->getCmdValue();
if (is_object($cmdValue) && $cmdValue->getType() == 'info') {
if ($cmdValue->execCmd() == $coupleArray[0]) {
if ($cmdValue->execCmd() == $coupleArray[0] || $cmdValue->execCmd() == $coupleArray[1]) {
$listOption .= '<option value="' . $coupleArray[0] . '" selected>' . $coupleArray[1] . '</option>';
$foundSelect = true;
} else {
Expand Down
6 changes: 5 additions & 1 deletion core/class/cron.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ public function isDue() {
return false;
}
try {
$schedule = explode(' ',$this->getSchedule());
if(count($schedule) == 6 && $schedule[5] != strtotime('Y')){
return false;
}
$c = new Cron\CronExpression(checkAndFixCron($this->getSchedule()), new Cron\FieldFactory);
try {
if ($c->isDue()) {
Expand Down Expand Up @@ -551,7 +555,7 @@ public function setDeamonSleepTime($_deamonSleepTime) {
}

public function getOption() {
return json_decode($this->option, true);
return json_decode($this->option ?? '', true);
}

public function getOnce($_default = 0) {
Expand Down
5 changes: 4 additions & 1 deletion core/class/eqLogic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ public static function toHumanReadable($_input) {
}

public static function fromHumanReadable($_input) {
if(empty($_input)){
return $_input;
}
$isJson = false;
if (is_json($_input)) {
$isJson = true;
Expand Down Expand Up @@ -525,7 +528,7 @@ public static function fromHumanReadable($_input) {
return $_input;
}
$text = $_input;
preg_match_all("/#\[(.*?)\]\[(.*?)\]#/", $text, $matches);
preg_match_all( "/#\[(.*?)\]\[(.*?)\]#/", $text, $matches);
if (count($matches) == 3) {
$countMatches = count($matches[0]);
for ($i = 0; $i < $countMatches; $i++) {
Expand Down
3 changes: 3 additions & 0 deletions core/class/jeeObject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public static function toHumanReadable($_input) {
}

public static function fromHumanReadable($_input) {
if(empty($_input)){
return $_input;
}
$isJson = false;
if (is_json($_input)) {
$isJson = true;
Expand Down
27 changes: 14 additions & 13 deletions core/class/jeedom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,19 @@ public static function health() {
'comment' => '',
'key' => 'uptodate'
);

$status = shell_exec('systemctl status fail2ban.service');
$failed = stripos($status, 'failed') !== false;
$running = stripos($status, 'running') !== false;
$state = $failed ? 0 : ($running ? 1 : 2);
$return[] = array(
'name' => __('Etat du service fail2ban', __FILE__),
'state' => $failed ? 0 : ($running ? 1 : 2),
'result' => $failed ? __('En échec', __FILE__) : ($running ? __('Actif', __FILE__) : __('Désactivé', __FILE__)),
'comment' => ($failed || !$running) ? __("Le service Linux fail2ban est désactivé ou en échec : les tentatives d'accès infructueuses à Jeedom ne résulteront pas en un bannissement des IP concernées. Vérifiez l'état du service si vous souhaitez réactiver fail2ban.", __FILE__) : '',
'key' => 'service::fail2ban'
);
if (version_compare(system::getOsVersion(), '12', '<')) {
$status = shell_exec('systemctl status fail2ban.service');
$failed = stripos($status, 'failed') !== false;
$running = stripos($status, 'running') !== false;
$state = $failed ? 0 : ($running ? 1 : 2);
$return[] = array(
'name' => __('Etat du service fail2ban', __FILE__),
'state' => $failed ? 0 : ($running ? 1 : 2),
'result' => $failed ? __('En échec', __FILE__) : ($running ? __('Actif', __FILE__) : __('Désactivé', __FILE__)),
'comment' => ($failed || !$running) ? __("Le service Linux fail2ban est désactivé ou en échec : les tentatives d'accès infructueuses à Jeedom ne résulteront pas en un bannissement des IP concernées. Vérifiez l'état du service si vous souhaitez réactiver fail2ban.", __FILE__) : '',
'key' => 'service::fail2ban'
);
}

$state = (config::byKey('enableCron', 'core', 1, true) != 0) ? true : false;
$return[] = array(
Expand Down Expand Up @@ -459,7 +460,7 @@ public static function health() {
);

if (shell_exec('which python') != '') {
$value = shell_exec('python --version');
$value = shell_exec('python --version 2>&1'); // prior python 3.4, 'python --version' output was on stderr
$return[] = array(
'name' => __('Python', __FILE__),
'state' => true,
Expand Down
2 changes: 1 addition & 1 deletion core/class/jsonrpcClient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private function send($_request, $_timeout = 15, $_file = null, $_maxRetry = 2)
if (curl_errno($ch)) {
$this->error = 'Erreur curl sur : ' . $this->apiAddr . '. Détail :' . curl_error($ch);
}
curl_close($ch);
unset($ch);
return $response;
}

Expand Down
2 changes: 1 addition & 1 deletion core/class/network.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static function test($_mode = 'external', $_timeout = 15) {
return false;
}
}
curl_close($ch);
unset($ch);
if (trim($data) != 'ok') {
log::add('network', 'debug', 'Retour NOK sur ' . $url . ' => ' . $data);
return false;
Expand Down
26 changes: 20 additions & 6 deletions core/class/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class plugin {

/* * ***********************Méthodes statiques*************************** */

public static function byId($_id) {
public static function byId($_id,$_full = false) {
global $JEEDOM_INTERNAL_CONFIG;
if (is_string($_id) && isset(self::$_cache[$_id])) {
return self::$_cache[$_id];
if (is_string($_id) && isset(self::$_cache[$_id.'::'.$_full])) {
return self::$_cache[$_id.'::'.$_full];
}
if (!file_exists($_id) || strpos($_id, '/') === false) {
$path = self::getPathById($_id);
Expand Down Expand Up @@ -109,7 +109,6 @@ public static function byId($_id) {
$plugin->changelog_beta = (isset($data['changelog_beta'])) ? str_replace('#language#', config::byKey('language', 'core', 'fr_FR'), $data['changelog_beta']) : '';
$plugin->documentation_beta = (isset($data['documentation_beta'])) ? str_replace('#language#', config::byKey('language', 'core', 'fr_FR'), $data['documentation_beta']) : '';
if (isset($data['specialAttributes'])) {

if (isset($data['specialAttributes']['object'])) {
$plugin->specialAttributes['object'] = $data['specialAttributes']['object'];
}
Expand All @@ -132,6 +131,7 @@ public static function byId($_id) {
'type' => 'class',
);
}

$plugin->functionality['interact'] = array('exists' => method_exists($plugin->getId(), 'interact'), 'controlable' => 1);
$plugin->functionality['cron'] = array('exists' => method_exists($plugin->getId(), 'cron'), 'controlable' => 1);
$plugin->functionality['cron5'] = array('exists' => method_exists($plugin->getId(), 'cron5'), 'controlable' => 1);
Expand All @@ -142,6 +142,12 @@ public static function byId($_id) {
$plugin->functionality['cronDaily'] = array('exists' => method_exists($plugin->getId(), 'cronDaily'), 'controlable' => 1);
$plugin->functionality['deadcmd'] = array('exists' => method_exists($plugin->getId(), 'deadCmd'), 'controlable' => 0);
$plugin->functionality['health'] = array('exists' => method_exists($plugin->getId(), 'health'), 'controlable' => 0);
if($_full){
if($plugin->getCache('usedSpace',-1) == -1){
$plugin->setCache('usedSpace',getDirectorySize(__DIR__ . '/../../plugins/' . $data['id']),86400);
}
$plugin->usedSpace = $plugin->getCache('usedSpace',-1);
}
if (!isset($JEEDOM_INTERNAL_CONFIG['plugin']['category'][$plugin->category])) {
foreach ($JEEDOM_INTERNAL_CONFIG['plugin']['category'] as $key => $value) {
if (!isset($value['alias'])) {
Expand All @@ -153,8 +159,7 @@ public static function byId($_id) {
}
}
}
$plugin->usedSpace = getDirectorySize(__DIR__ . '/../../plugins/' . $data['id']);
self::$_cache[$plugin->id] = $plugin;
self::$_cache[$plugin->id.'::'.$_full] = $plugin;
return $plugin;
}

Expand Down Expand Up @@ -1332,4 +1337,13 @@ public function setWhiteListFolders($paths) {
$this->whiteListFolders = (array) $paths;
return $this;
}

public function getCache($_key = '', $_default = '') {
$cache = cache::byKey('pluginCacheAttr' . $this->getId())->getValue();
return utils::getJsonAttr($cache, $_key, $_default);
}

public function setCache($_key, $_value = null, $_lifetime = 0) {
cache::set('pluginCacheAttr' . $this->getId(), utils::setJsonAttr(cache::byKey('pluginCacheAttr' . $this->getId())->getValue(), $_key, $_value), $_lifetime);
}
}
21 changes: 21 additions & 0 deletions core/class/scenario.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,9 @@ public static function toHumanReadable($_input) {
* @return string|object|array return value will depends on $_input received
*/
public static function fromHumanReadable($_input) {
if(empty($_input)){
return $_input;
}
$isJson = false;
if (is_json($_input)) {
$isJson = true;
Expand Down Expand Up @@ -1191,6 +1194,12 @@ public function calculateScheduleDate() {
$c = new Cron\CronExpression(checkAndFixCron($schedule), new Cron\FieldFactory);
$calculatedDate_tmp['prevDate'] = $c->getPreviousRunDate()->format('Y-m-d H:i:s');
$calculatedDate_tmp['nextDate'] = $c->getNextRunDate()->format('Y-m-d H:i:s');
if(count($schedule) == 6 && $schedule[5] != $c->getPreviousRunDate()->format('Y')){
$calculatedDate['prevDate'] = '';
}
if(count($schedule) == 6 && $schedule[5] != $c->getNextRunDate()->format('Y')){
$calculatedDate['nextDate'] = '';
}
} catch (Exception $exc) {
} catch (Error $exc) {
}
Expand All @@ -1206,10 +1215,18 @@ public function calculateScheduleDate() {
$c = new Cron\CronExpression(checkAndFixCron($this->getSchedule()), new Cron\FieldFactory);
$calculatedDate['prevDate'] = $c->getPreviousRunDate()->format('Y-m-d H:i:s');
$calculatedDate['nextDate'] = $c->getNextRunDate()->format('Y-m-d H:i:s');
$schedule = explode(' ',$this->getSchedule());
if(count($schedule) == 6 && $schedule[5] != $c->getPreviousRunDate()->format('Y')){
$calculatedDate['prevDate'] = '';
}
if(count($schedule) == 6 && $schedule[5] != $c->getNextRunDate()->format('Y')){
$calculatedDate['nextDate'] = '';
}
} catch (Exception $exc) {
} catch (Error $exc) {
}
}

return $calculatedDate;
}
/**
Expand All @@ -1230,6 +1247,10 @@ public function isDue() {
if (is_array($this->getSchedule())) {
foreach (($this->getSchedule()) as $schedule) {
try {
$schedule = explode(' ',$this->getSchedule());
if(count($schedule) == 6 && $schedule[5] != strtotime('Y')){
return false;
}
$c = new Cron\CronExpression(checkAndFixCron($schedule), new Cron\FieldFactory);
try {
if ($c->isDue()) {
Expand Down
Loading
Loading