Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history.section autofill should not be case sensitive #2088

Closed
plegall opened this issue Jan 18, 2024 · 0 comments
Closed

history.section autofill should not be case sensitive #2088

plegall opened this issue Jan 18, 2024 · 0 comments

Comments

@plegall
Copy link
Member

plegall commented Jan 18, 2024

In this code (include/functions.inc.php function pwg_log:

  // If plugin developers add their own sections, Piwigo will automatically add it in the history.section enum column
  if (isset($page['section']))
  {
    // set cache if not available
    if (!isset($conf['history_sections_cache']))
    {
      conf_update_param('history_sections_cache', get_enums(HISTORY_TABLE, 'section'), true);
    }

    $conf['history_sections_cache'] = safe_unserialize($conf['history_sections_cache']);

    if (in_array($page['section'], $conf['history_sections_cache']))
    {
      $section = $page['section'];
    }
    elseif (preg_match('/^[a-zA-Z0-9_-]+$/', $page['section']))
    {
      $history_sections = get_enums(HISTORY_TABLE, 'section');
      $history_sections[] = $page['section'];

      // alter history table structure, to include a new 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'];
    }
  }

We do as if the history.section is case sensitive. It's not. If you try to add section42 in the ENUM field while Section42 already exists, MySQL will throw an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant