mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-30 13:33:54 +02:00
fixes #945 pwg_log automatically creates a new history.section in the enum, when needed
This commit is contained in:
+28
-23
@@ -463,28 +463,33 @@ UPDATE '.USER_INFOS_TABLE.'
|
|||||||
$ip = substr($ip, 0, 15);
|
$ip = substr($ip, 0, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
// solves issue 945
|
// If plugin developers add their own sections, Piwigo will automatically add it in the history.section enum column
|
||||||
// If plugin developers add their own sections, Piwigo tries to put them into history table. Since the section
|
if (isset($page['section']))
|
||||||
// column is an enum, php issues a warning. It might be the server is configured to hide those warnings, so the
|
{
|
||||||
// user won't see it. Piwigo core should make a decision if it is better to refuse the insert at all if section is
|
// set cache if not available
|
||||||
// not valid, depending on possible future use of the history table
|
if (!isset($conf['history_sections_cache']))
|
||||||
if(isset($page['section'])) {
|
{
|
||||||
//enum: 'categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats'
|
conf_update_param('history_sections_cache', get_enums(HISTORY_TABLE, 'section'), true);
|
||||||
if(in_array(
|
}
|
||||||
$page['section'],
|
|
||||||
array('categories',
|
$conf['history_sections_cache'] = safe_unserialize($conf['history_sections_cache']);
|
||||||
'tags',
|
|
||||||
'search',
|
if (in_array($page['section'], $conf['history_sections_cache']))
|
||||||
'list',
|
{
|
||||||
'favorites',
|
$section = $page['section'];
|
||||||
'most_visited',
|
}
|
||||||
'best_rated',
|
elseif (preg_match('/^[a-zA-Z0-9_-]+$/', $page['section']))
|
||||||
'recent_pics',
|
{
|
||||||
'recent_cats'
|
$history_sections = get_enums(HISTORY_TABLE, 'section');
|
||||||
)
|
$history_sections[] = $page['section'];
|
||||||
)
|
|
||||||
){
|
// alter history table structure, to include a new section
|
||||||
$mySection = $page['section'];
|
pwg_query('ALTER TABLE '.HISTORY_TABLE.' CHANGE section section enum(\''.implode("','", array_unique($history_sections)).'\') DEFAULT NULL;');
|
||||||
|
|
||||||
|
// and refresh cache
|
||||||
|
conf_update_param('history_sections_cache', get_enums(HISTORY_TABLE, 'section'), true);
|
||||||
|
|
||||||
|
$section = $page['section'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,7 +514,7 @@ INSERT INTO '.HISTORY_TABLE.'
|
|||||||
CURRENT_TIME,
|
CURRENT_TIME,
|
||||||
'.$user['id'].',
|
'.$user['id'].',
|
||||||
\''.$ip.'\',
|
\''.$ip.'\',
|
||||||
'.(isset($mySection) ? "'".$mySection."'" : 'NULL').',
|
'.(isset($section) ? "'".$section."'" : 'NULL').',
|
||||||
'.(isset($page['category']['id']) ? $page['category']['id'] : 'NULL').',
|
'.(isset($page['category']['id']) ? $page['category']['id'] : 'NULL').',
|
||||||
'.(isset($image_id) ? $image_id : 'NULL').',
|
'.(isset($image_id) ? $image_id : 'NULL').',
|
||||||
'.(isset($image_type) ? "'".$image_type."'" : 'NULL').',
|
'.(isset($image_type) ? "'".$image_type."'" : 'NULL').',
|
||||||
|
|||||||
Reference in New Issue
Block a user