Skip to content

Commit

Permalink
Fix Zend module SQL upgrade (#6809)
Browse files Browse the repository at this point in the history
* Fix Zend module SQL upgrade
add custom module pathing

* more pathing
  • Loading branch information
sjpadgett committed Aug 31, 2023
1 parent 089daca commit 4f52c1c
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ public function configureAction()
//INSERT MODULE HOOKS IF NOT EXISTS
$moduleDirectory = $this->getInstallerTable()->getModuleDirectory($modId);
//GET MODULE HOOKS FROM A FUNCTION IN CONFIGURATION MODEL CLASS
$hooksArr = $this->getInstallerTable()->getModuleHooks($moduleDirectory);
$hooksArr = $this->getInstallerTable()->getModuleHooks($moduleDirectory) ?: [];

if (count($hooksArr) > 0) {
foreach ($hooksArr as $hook) {
if (count($hook) > 0) {
if (count($hook ?? []) > 0) {
if ($this->getInstallerTable()->checkModuleHookExists($modId, $hook['name']) == "0") {
$this->getInstallerTable()->saveModuleHooks($modId, $hook['name'], $hook['title'], $hook['path']);
}
Expand Down Expand Up @@ -375,7 +375,9 @@ function getModuleVersionFromFile($modId)
//SQL version of Module
$dirModule = $this->getInstallerTable()->getRegistryEntry($modId, "mod_directory");
$ModulePath = $GLOBALS['srcdir'] . "/../" . $GLOBALS['baseModDir'] . "zend_modules/module/" . $dirModule->modDirectory;

if (!is_dir($ModulePath)) {
$ModulePath = $GLOBALS['srcdir'] . "/../" . $GLOBALS['baseModDir'] . "custom_modules/" . $dirModule->modDirectory;
}
$version_of_module = $ModulePath . "/version.php";
$table_sql = $ModulePath . "/table.sql";
$install_sql = $ModulePath . "/sql/install.sql";
Expand Down Expand Up @@ -424,14 +426,21 @@ public function makeButtonForSqlAction(InstModule $mod)
if (!is_dir($sqldir)) {
$sqldir = $ModulePath;
}
if (!is_dir($sqldir)) {
$ModulePath = $GLOBALS['srcdir'] . "/../" . $GLOBALS['baseModDir'] . "custom_modules/" . $dirModule->modDirectory;
$sqldir = $ModulePath . "/sql";
if (!is_dir($sqldir)) {
$sqldir = $ModulePath;
}
}
$mod->sql_action = "";

if (file_exists($sqldir . "/install.sql") && file_exists($ModulePath . "/version.php") && empty($mod->sql_version)) {
$mod->sql_action = "install";
}

if (!empty($mod->sql_version) && $mod->sqlRun == 1) {
$versions = $this->getFilesForUpgrade($mod->modDirectory, $sqldir);
$versions = $this->getFilesForUpgrade($mod->modDirectory, $sqldir) ?: [];

if (count($versions) > 0) {
foreach ($versions as $version => $sfname) {
Expand Down Expand Up @@ -561,7 +570,7 @@ public function UpgradeModuleSQL($modId = '')
$div[] = $string;
$add_query_string++;
}
if (count($matches[1]) == (count($div) - $add_ended_divs) && (!$prev_html_tag && !$curr_html_tag)) {
if (count($matches[1]) == (count($div ?? []) - $add_ended_divs) && (!$prev_html_tag && !$curr_html_tag)) {
$div[] = "</div>";
}
$k++;
Expand Down Expand Up @@ -626,7 +635,7 @@ public function DisableModule($modId = '')
$resp = $this->getInstallerTable()->updateRegistered($modId, "mod_active=1");
if ($resp['status'] == 'failure' && $resp['code'] == '200') {
$plural = "Module";
if (count($resp['value']) > 1) {
if (count($resp['value'] ?? []) > 1) {
$plural = "Modules";
}

Expand Down

0 comments on commit 4f52c1c

Please sign in to comment.