From 8b4d2aa0f2263b844f112952453b6f727fac3771 Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Fri, 13 Sep 2019 21:01:16 +0200 Subject: [PATCH 1/8] Nouveaux tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eab53875c..012e6dcb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php php: - - 7.1 + - 7.2 services: - docker before_install: From 1adf01bddc177d1ee52906f96924e0b1c41aecd3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2019 07:02:20 +0000 Subject: [PATCH 2/8] Bump pragmarx/google2fa from 6.0.0 to 6.0.1 Bumps [pragmarx/google2fa](https://github.com/antonioribeiro/google2fa) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/antonioribeiro/google2fa/releases) - [Changelog](https://github.com/antonioribeiro/google2fa/blob/master/CHANGELOG.md) - [Commits](https://github.com/antonioribeiro/google2fa/compare/v6.0.0...v6.0.1) Signed-off-by: dependabot-preview[bot] --- composer.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.lock b/composer.lock index 24f8c529f..3502f008d 100644 --- a/composer.lock +++ b/composer.lock @@ -1746,16 +1746,16 @@ }, { "name": "pragmarx/google2fa", - "version": "v6.0.0", + "version": "v6.0.1", "source": { "type": "git", "url": "https://github.com/antonioribeiro/google2fa.git", - "reference": "03f6fb65aaccc21d6f70969db652316ad003b83d" + "reference": "8df7d8fe0734c7ddad5fce2251adf4b3e9218643" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/antonioribeiro/google2fa/zipball/03f6fb65aaccc21d6f70969db652316ad003b83d", - "reference": "03f6fb65aaccc21d6f70969db652316ad003b83d", + "url": "https://api.github.com/repos/antonioribeiro/google2fa/zipball/8df7d8fe0734c7ddad5fce2251adf4b3e9218643", + "reference": "8df7d8fe0734c7ddad5fce2251adf4b3e9218643", "shasum": "" }, "require": { @@ -1798,7 +1798,7 @@ "Two Factor Authentication", "google2fa" ], - "time": "2019-09-11T19:19:55+00:00" + "time": "2019-09-18T22:34:47+00:00" }, { "name": "psr/http-message", @@ -2375,14 +2375,14 @@ "authors": [ { "name": "Evert Pot", - "role": "Developer", "email": "me@evertpot.com", - "homepage": "http://evertpot.com/" + "homepage": "http://evertpot.com/", + "role": "Developer" }, { "name": "Markus Staab", - "role": "Developer", - "email": "markus.staab@redaxo.de" + "email": "markus.staab@redaxo.de", + "role": "Developer" } ], "description": "sabre/xml is an XML library that you may not hate.", From c88e4286ddb8e053df8b75bd40812a2aded27742 Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Tue, 24 Sep 2019 00:10:45 +0200 Subject: [PATCH 3/8] Version update --- CHANGELOG.md | 14 ++++++++++++++ assets/config/Nextdom_version | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faa9582e3..c33fef169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # NextDom Core Changelog --- +## 0.5.0-RC0 + +> ***Release Date : 23/09/2019*** +> +> ***Statut : Release candidate + +* Amélioration de la migration depuis Jeedom +* Possibilité de commander les scénarios depuis le dashboard +* Déplacement du code du core +* Amélioration de compatibilité PHP > 7.2 et Debian Buster +* Correction de bugs +* Correction de l'affichage des updates du Core +* Mise à jour des dépendances + ## 0.4.2 > ***Release Date : 13/09/2019*** > diff --git a/assets/config/Nextdom_version b/assets/config/Nextdom_version index 1d0ba9ea1..88ef58410 100644 --- a/assets/config/Nextdom_version +++ b/assets/config/Nextdom_version @@ -1 +1 @@ -0.4.0 +0.5.0-RC0 From e58da6f5ef2f1be9f9abfcc22255ca84e0eb0516 Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Tue, 24 Sep 2019 21:05:19 +0200 Subject: [PATCH 4/8] Update core on check (git and apt) --- src/Repo/RepoApt.php | 5 +++++ src/Repo/RepoGitHub.php | 49 +++++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/Repo/RepoApt.php b/src/Repo/RepoApt.php index 69f022bec..7d3d74254 100644 --- a/src/Repo/RepoApt.php +++ b/src/Repo/RepoApt.php @@ -79,6 +79,11 @@ public static function checkUpdate(&$targetUpdate) $targetUpdate->save(); } } + else { + $targetUpdate->setSource('github'); + RepoGitHub::checkUpdate($targetUpdate); + $result = true; + } } return $result; } diff --git a/src/Repo/RepoGitHub.php b/src/Repo/RepoGitHub.php index 6b99e2890..7778ee284 100644 --- a/src/Repo/RepoGitHub.php +++ b/src/Repo/RepoGitHub.php @@ -23,6 +23,7 @@ use NextDom\Helpers\NextDomHelper; use NextDom\Helpers\SystemHelper; use NextDom\Managers\ConfigManager; +use NextDom\Model\Entity\Update; require_once __DIR__ . '/../../core/php/core.inc.php'; @@ -78,39 +79,55 @@ class RepoGitHub /* * ***********************Méthodes statiques*************************** */ - public static function checkUpdate(&$_update) + /** + * @param Update $targetUpdate + */ + public static function checkUpdate(&$targetUpdate) { - if (is_array($_update)) { - if (count($_update) < 1) { + if (is_array($targetUpdate)) { + if (count($targetUpdate) < 1) { return; } - foreach ($_update as $update) { + foreach ($targetUpdate as $update) { self::checkUpdate($update); } return; } $client = self::getGithubClient(); + if ($targetUpdate->getType() === 'core') { + exec('cd ' . NEXTDOM_ROOT . ' && git rev-parse --abbrev-ref HEAD 2> /dev/null', $currentBranch); + if (is_array($currentBranch) && count($currentBranch) > 0) { + $targetUpdate->setConfiguration('version', $currentBranch[0]); + $targetUpdate->save(); + } + elseif (!is_dir(NEXTDOM_ROOT . '/.git')) { + $targetUpdate->setSource('apt'); + $targetUpdate->save(); + RepoApt::checkUpdate($targetUpdate); + return; + } + } try { - $branch = $client->api('repo')->branches($_update->getConfiguration('user'), $_update->getConfiguration('repository'), $_update->getConfiguration('version', 'master')); + $branch = $client->api('repo')->branches($targetUpdate->getConfiguration('user'), $targetUpdate->getConfiguration('repository'), $targetUpdate->getConfiguration('version', 'master')); } catch (\Exception $e) { - $_update->setRemoteVersion('repository not found'); - $_update->setStatus('ok'); - $_update->save(); + $targetUpdate->setRemoteVersion('repository not found'); + $targetUpdate->setStatus('ok'); + $targetUpdate->save(); return; } if (!isset($branch['commit']) || !isset($branch['commit']['sha'])) { - $_update->setRemoteVersion('error'); - $_update->setStatus('ok'); - $_update->save(); + $targetUpdate->setRemoteVersion('error'); + $targetUpdate->setStatus('ok'); + $targetUpdate->save(); return; } - $_update->setRemoteVersion($branch['commit']['sha']); - if ($branch['commit']['sha'] != $_update->getLocalVersion()) { - $_update->setStatus('update'); + $targetUpdate->setRemoteVersion($branch['commit']['sha']); + if ($branch['commit']['sha'] != $targetUpdate->getLocalVersion()) { + $targetUpdate->setStatus('update'); } else { - $_update->setStatus('ok'); + $targetUpdate->setStatus('ok'); } - $_update->save(); + $targetUpdate->save(); } public static function getGithubClient() From e0542915844866fb1187d5f639caff59d480604f Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Tue, 24 Sep 2019 21:17:12 +0200 Subject: [PATCH 5/8] Update git local version --- src/Repo/RepoGitHub.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Repo/RepoGitHub.php b/src/Repo/RepoGitHub.php index 7778ee284..0cd9eae1f 100644 --- a/src/Repo/RepoGitHub.php +++ b/src/Repo/RepoGitHub.php @@ -94,6 +94,7 @@ public static function checkUpdate(&$targetUpdate) return; } $client = self::getGithubClient(); + // Check if core data is correct and change type or repository if necessary if ($targetUpdate->getType() === 'core') { exec('cd ' . NEXTDOM_ROOT . ' && git rev-parse --abbrev-ref HEAD 2> /dev/null', $currentBranch); if (is_array($currentBranch) && count($currentBranch) > 0) { @@ -122,6 +123,12 @@ public static function checkUpdate(&$targetUpdate) return; } $targetUpdate->setRemoteVersion($branch['commit']['sha']); + // Read local version + exec('cd ' . NEXTDOM_ROOT . ' && git rev-parse HEAD 2> /dev/null', $localVersion); + if (is_array($currentBranch) && count($currentBranch) > 0) { + $targetUpdate->setLocalVersion($localVersion[0]); + } + // Compare if ($branch['commit']['sha'] != $targetUpdate->getLocalVersion()) { $targetUpdate->setStatus('update'); } else { From 937be31ab541158a1568c338bb22182479f5f9ce Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Wed, 25 Sep 2019 07:16:52 +0200 Subject: [PATCH 6/8] Fix byTrigger Comment consistency --- src/Managers/ConsistencyManager.php | 35 +++++++++++++++++++++++------ src/Managers/ScenarioManager.php | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/Managers/ConsistencyManager.php b/src/Managers/ConsistencyManager.php index 5e6671b10..aa7d85d1b 100644 --- a/src/Managers/ConsistencyManager.php +++ b/src/Managers/ConsistencyManager.php @@ -57,13 +57,18 @@ class ConsistencyManager 'power' => array('key' => 'power', 'name' => 'Puissance', 'calcul' => 'sum', 'icon' => '', 'unit' => 'W', 'allowDisplayZero' => false), ); + /** + * Start consistency check of the system + * + * @throws CoreException + */ public static function checkConsistency() { try { self::ensureConfiguration(); CronManager::clean(); - self::deleteDeprecatedCrons(); - self::ensureCrons(); + self::removeDeprecatedCrons(); + self::checkAllDefaultCrons(); self::cleanWidgetCache(); self::saveObjects(); self::resetCommandsActionID(); @@ -73,6 +78,10 @@ public static function checkConsistency() } } + /** + * TODO: ??? + * @throws \Exception + */ private static function ensureConfiguration() { $summary = ConfigManager::byKey("object:summary"); @@ -86,7 +95,13 @@ private static function ensureConfiguration() } } - private static function deleteDeprecatedCrons() + /** + * Remove deprecated cron task + * + * @throws CoreException + * @throws \ReflectionException + */ + private static function removeDeprecatedCrons() { $cronTasksToRemove = [ ['target_class' => 'nextdom', 'action' => 'persist'], @@ -104,7 +119,10 @@ private static function deleteDeprecatedCrons() } } - private static function ensureCrons() + /** + * Check if all default cron task are present and add it + */ + private static function checkAllDefaultCrons() { foreach (self::getDefaultCrons() as $c_class => $c_data) { foreach ($c_data as $c_name => $c_config) { @@ -262,14 +280,17 @@ private static function resetCommandsActionID() } } + /** + * Check if user.function.class.php has been deletedd + */ private static function ensureUserFunctionExists() { - $source = sprintf("%s/data/php/user.function.class.sample.php", NEXTDOM_DATA); + $baseFile = sprintf("%s/data/php/user.function.class.sample.php", NEXTDOM_DATA); $dest = sprintf("%s/data/php/user.function.class.php", NEXTDOM_DATA); if ((false == file_exists($dest)) && - (true == file_exists($source))) { - copy($source, $dest); + (true == file_exists($baseFile))) { + copy($baseFile, $dest); } } } diff --git a/src/Managers/ScenarioManager.php b/src/Managers/ScenarioManager.php index 8f4aabca3..5e080ce8c 100644 --- a/src/Managers/ScenarioManager.php +++ b/src/Managers/ScenarioManager.php @@ -340,7 +340,7 @@ public static function check($event = null, $forceSyncMode = false) * @return array|mixed|null [] Liste des scénarios * @throws \Exception */ - public static function byTrigger(string $cmdId, $onlyEnabled = true) + public static function byTrigger($cmdId, $onlyEnabled = true) { $values = array('cmd_id' => '%#' . $cmdId . '#%'); $sql = 'SELECT ' . DBHelper::buildField(self::DB_CLASS_NAME) . ' From 9617b4c619d90b61eea01f2ab1899af1380d5c4a Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Wed, 25 Sep 2019 17:22:41 +0200 Subject: [PATCH 7/8] Fix github update --- src/Repo/RepoGitHub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repo/RepoGitHub.php b/src/Repo/RepoGitHub.php index 0cd9eae1f..9f056db00 100644 --- a/src/Repo/RepoGitHub.php +++ b/src/Repo/RepoGitHub.php @@ -125,7 +125,7 @@ public static function checkUpdate(&$targetUpdate) $targetUpdate->setRemoteVersion($branch['commit']['sha']); // Read local version exec('cd ' . NEXTDOM_ROOT . ' && git rev-parse HEAD 2> /dev/null', $localVersion); - if (is_array($currentBranch) && count($currentBranch) > 0) { + if (is_array($localVersion) && count($localVersion) > 0) { $targetUpdate->setLocalVersion($localVersion[0]); } // Compare From 29cd12fb06bcb88ae9484153f238095224eed3bc Mon Sep 17 00:00:00 2001 From: Sylvain Dangin Date: Wed, 25 Sep 2019 20:51:46 +0200 Subject: [PATCH 8/8] Fix plugin10 --- core/class/plugin.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/class/plugin.class.php b/core/class/plugin.class.php index 2491d82b5..d3948e663 100644 --- a/core/class/plugin.class.php +++ b/core/class/plugin.class.php @@ -58,6 +58,11 @@ public static function cron5() PluginManager::cron5(); } + public static function cron10() + { + PluginManager::cron10(); + } + public static function cron15() { PluginManager::cron15();