Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(update): take into account the removal of older conf.php #7952

Merged
merged 2 commits into from
Oct 9, 2019
Merged
Changes from all commits
Commits
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
23 changes: 11 additions & 12 deletions src/CentreonLegacy/Core/Module/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function upgrade()
usort($orderedUpgrades, 'version_compare');
foreach ($orderedUpgrades as $upgradeName) {
$upgradePath = $upgradesPath . $upgradeName;
if (!preg_match('/^(\d+\.\d+\.\d+)/', $upgradeName, $matches) ||
!$this->services->get('filesystem')->exists($upgradePath . '/conf.php')) {
if (!preg_match('/^(\d+\.\d+\.\d+)/', $upgradeName, $matches)) {
continue;
}

Expand Down Expand Up @@ -103,14 +102,14 @@ private function upgradeModuleConfiguration()

$sth = $this->services->get('configuration_db')->prepare($query);

$sth->bindParam(':name', $this->moduleConfiguration['name'], \PDO::PARAM_STR);
$sth->bindParam(':rname', $this->moduleConfiguration['rname'], \PDO::PARAM_STR);
$sth->bindParam(':is_removeable', $this->moduleConfiguration['is_removeable'], \PDO::PARAM_STR);
$sth->bindParam(':infos', $this->moduleConfiguration['infos'], \PDO::PARAM_STR);
$sth->bindParam(':author', $this->moduleConfiguration['author'], \PDO::PARAM_STR);
$sth->bindParam(':svc_tools', $this->moduleConfiguration['svc_tools'], \PDO::PARAM_STR);
$sth->bindParam(':host_tools', $this->moduleConfiguration['host_tools'], \PDO::PARAM_STR);
$sth->bindParam(':id', $this->moduleId, \PDO::PARAM_INT);
$sth->bindValue(':name', $this->moduleConfiguration['name'], \PDO::PARAM_STR);
$sth->bindValue(':rname', $this->moduleConfiguration['rname'], \PDO::PARAM_STR);
$sth->bindValue(':is_removeable', $this->moduleConfiguration['is_removeable'], \PDO::PARAM_STR);
$sth->bindValue(':infos', $this->moduleConfiguration['infos'], \PDO::PARAM_STR);
$sth->bindValue(':author', $this->moduleConfiguration['author'], \PDO::PARAM_STR);
$sth->bindValue(':svc_tools', $this->moduleConfiguration['svc_tools'] ?? '0', \PDO::PARAM_STR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you check this key/value when modulecnofiguration is set ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been set in the bindValue for now, but those two values will be removed in next versions because no longer used...

$sth->bindValue(':host_tools', $this->moduleConfiguration['host_tools'] ?? '0', \PDO::PARAM_STR);
$sth->bindValue(':id', $this->moduleId, \PDO::PARAM_INT);

$sth->execute();

Expand All @@ -130,8 +129,8 @@ private function upgradeVersion($version)

$sth = $this->services->get('configuration_db')->prepare($query);

$sth->bindParam(':mod_release', $version, \PDO::PARAM_STR);
$sth->bindParam(':id', $this->moduleId, \PDO::PARAM_INT);
$sth->bindValue(':mod_release', $version, \PDO::PARAM_STR);
$sth->bindValue(':id', $this->moduleId, \PDO::PARAM_INT);

$sth->execute();

Expand Down