Skip to content

Commit

Permalink
Add some checks for worst case cannot get configuration from DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Mar 18, 2019
1 parent e0a17b6 commit d9077ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions code_igniter/application/controllers/logon.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ public function logout()

public function check_defaults()
{

$oae_url = $this->config->config['oae_url'];
$oae_url = '';
if (!empty($this->config->config['oae_url'])) {
$oae_url = $this->config->config['oae_url'];
}
$oae_url = str_replace('/omk/oae', '/omk/open-audit', $oae_url);
if ($oae_url == '') {
$oae_url = '/omk/open-audit/';
Expand Down Expand Up @@ -329,7 +331,7 @@ public function check_defaults()
if ($license->license == 'none') {
$product = 'Open-AudIT Community';
}
if ($this->config->config['internal_version'] >= 20170620) {
if (!empty($this->config->config['internal_version']) and $this->config->config['internal_version'] >= 20170620) {
$this->m_configuration->update('oae_product', (string)$product, 'system');
} else {
$this->config->config['oae_product'] = 'Open-AudIT Community';
Expand Down
18 changes: 10 additions & 8 deletions code_igniter/application/models/m_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function read($id = '')

public function update($id = '', $value = '', $edited_by = '')
{
if ($this->config->config['internal_version'] < 20160904) {
if (!empty($this->config->config['internal_version']) and $this->config->config['internal_version'] < 20160904) {
return;
}
$this->log->function = strtolower(__METHOD__);
Expand Down Expand Up @@ -172,14 +172,16 @@ public function load()
}

# set all items to value or ''
foreach ($result as $row) {
$temp_name = $row->name;
if (empty($row->value)) {
$this->config->config[$temp_name] = '';
} else {
$this->config->config[$temp_name] = $row->value;
if (!empty($result)) {
foreach ($result as $row) {
$temp_name = $row->name;
if (empty($row->value)) {
$this->config->config[$temp_name] = '';
} else {
$this->config->config[$temp_name] = $row->value;
}
unset($temp_name);
}
unset($temp_name);
}
$temp = array();
if (!empty($_SERVER['REQUEST_URI'])) {
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/models/m_networks.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function upsert($network = null)
if (empty($network->org_id)) {
$network->org_id = 1;
}
if ($this->config->config['internal_version'] < 20160904) {
if (!empty($this->config->config['internal_version']) and $this->config->config['internal_version'] < 20160904) {
return;
}
$sql = "SELECT * FROM networks WHERE networks.org_id = ? AND networks.network = ?";
Expand Down

0 comments on commit d9077ae

Please sign in to comment.