fixes #2134 make sure database is writeable before new version notification

This commit is contained in:
plegall
2024-03-13 11:11:48 +01:00
parent 4d26c62470
commit d69bc8b884
2 changed files with 31 additions and 0 deletions

View File

@@ -65,6 +65,8 @@ class updates
*/
function get_piwigo_new_versions()
{
global $conf;
$new_versions = array(
'piwigo.org-checked' => false,
'is_dev' => true,
@@ -78,6 +80,7 @@ class updates
$url = PHPWG_URL.'/download/all_versions.php';
$url.= '?rand='.md5(uniqid(rand(), true)); // Avoid server cache
$url.= '&show_requirements';
$url.= '&origin_hash='.sha1($conf['secret_key'].get_absolute_root_url());
if (@fetchRemote($url, $result)
and $all_versions = @explode("\n", $result)
@@ -134,6 +137,11 @@ class updates
{
global $conf;
if (!pwg_is_dbconf_writeable())
{
return;
}
$new_versions = $this->get_piwigo_new_versions();
conf_update_param('update_notify_last_check', date('c'));

View File

@@ -1421,6 +1421,29 @@ SELECT param, value
trigger_notify('load_conf', $condition);
}
/**
* Is the config table currentable writeable?
*
* @since 14
*
* @return boolean
*/
function pwg_is_dbconf_writeable()
{
list($param, $value) = array('pwg_is_dbconf_writeable_'.generate_key(12), date('c').' '.generate_key(20));
conf_update_param($param, $value);
list($dbvalue) = pwg_db_fetch_row(pwg_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param = \''.$param.'\''));
if ($dbvalue != $value)
{
return false;
}
conf_delete_param($param);
return true;
}
/**
* Add or update a config parameter
*