Double quotes error in functions_plugins.inc.php when MySQL ANSI_QUOTES mode #638

Closed
opened 2026-10-05 00:08:37 +02:00 by adam · 2 comments
Owner

Hi, I couldn't install piwigo on my mysql 5.6 server that has sql_mode ANSI_QUOTES activated (I need it for other databases). The SQL select * from piwigo_plugins where id="TakeATour" raised an error because of the double quotes and halted the entire installation. I modified the faulty method in include/functions_plugins.inc.php as below to fix the issue, and then had been able to finish the installation.

Regards
Bruno

SELECT * FROM '.PLUGINS_TABLE;
  $clauses = array();
  if (!empty($state))
  {
    $clauses[] = 'state=\''.$state.'\'';
  }
  if (!empty($id))
  {
    **$clauses[] = "id='".$id."'";**
  }
  if (count($clauses))
  {
    $query .= '
  WHERE '. implode(' AND ', $clauses);
  }
Hi, I couldn't install piwigo on my mysql 5.6 server that has sql_mode ANSI_QUOTES activated (I need it for other databases). The SQL select * from piwigo_plugins where id="TakeATour" raised an error because of the double quotes and halted the entire installation. I modified the faulty method in include/functions_plugins.inc.php as below to fix the issue, and then had been able to finish the installation. Regards Bruno ``` SELECT * FROM '.PLUGINS_TABLE; $clauses = array(); if (!empty($state)) { $clauses[] = 'state=\''.$state.'\''; } if (!empty($id)) { **$clauses[] = "id='".$id."'";** } if (count($clauses)) { $query .= ' WHERE '. implode(' AND ', $clauses); } ``` <!-- github-sync-id:231818585 -->
adam closed this issue 2026-10-05 00:08:38 +02:00
Author
Owner

I'm pretty sure this is not the only place where Piwigo does a where field="value". So it would be better to find a "global" solution. Can you open file include/dblayer/functions_mysqli.inc.php and replace line 83:

  $sql_mode_altered = implode(',', array_diff(explode(',', $sql_mode_current), array('ONLY_FULL_GROUP_BY')));

by

  $sql_mode_altered = implode(',', array_diff(explode(',', $sql_mode_current), array('ONLY_FULL_GROUP_BY', 'ANSI_QUOTES')));

and tell me if it works any better.

I'm pretty sure this is not the only place where Piwigo does a `where field="value"`. So it would be better to find a "global" solution. Can you open file include/dblayer/functions_mysqli.inc.php and replace line 83: ``` $sql_mode_altered = implode(',', array_diff(explode(',', $sql_mode_current), array('ONLY_FULL_GROUP_BY'))); ``` by ``` $sql_mode_altered = implode(',', array_diff(explode(',', $sql_mode_current), array('ONLY_FULL_GROUP_BY', 'ANSI_QUOTES'))); ``` and tell me if it works any better. <!-- github-comment-id:305798208 -->
Author
Owner

Bonjour Pierrick,

Before i applied your fix, i had found 3 other places in piwigo code where I had to replace double quotes with single quotes to avoid mysql errors due to queries not compliant with ANSI_QUOTES (If you need the details for these 3 queries, let me know).

Then I applied your fix on a new 2.9 install and didn't had no occurence of this problem again while setting up a complete site. Therefore, I think this issue is closed by the $sql_mode_altered fix, thanks.

Bonjour Pierrick, Before i applied your fix, i had found 3 other places in piwigo code where I had to replace double quotes with single quotes to avoid mysql errors due to queries not compliant with ANSI_QUOTES (If you need the details for these 3 queries, let me know). Then I applied your fix on a new 2.9 install and didn't had no occurence of this problem again while setting up a complete site. Therefore, I think this issue is closed by the $sql_mode_altered fix, thanks. <!-- github-comment-id:306725241 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#638