Skip to content

Inline use of implode in generatedWhereClause

Sven Oos requested to merge SO-replace-string-array-in-sql-statement into master

Fixes one of #747 (closed) Fixes bug introduced in !1178 (merged)

What does this MR do?

Replaces the use of a criteria in prepared statements that use JOINs and use IN conditions.

Before:

return $this->db->fetchAll('
    SELECT foo
    FROM   t1 JOIN t2 ON t1.x = t2.y
    WHERE  bar IN(:b)
', [
    ':b' => implode(',', $bars)
]);

After:

return $this->db->fetchAll('
    SELECT foo
    FROM   t1 JOIN t2 ON t1.x = t2.y
    WHERE  bar IN(' . implode(',', $bars) . ')
');

How confident are you it won't break things if deployed?

very

Links to related issues

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined #foodsharing-beta channel at https://slackin.yunity.org
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
  • Once your MR has been merged, you are responsible to update the #foodsharing-beta Slack channel about what has been changed here. They will test your work in different browsers, roles or other settings
Edited by Chris Oelmueller

Merge request reports