mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Make a Feed query construction less clever/sneaky for new qsprintf() semantics
Summary: Ref T13216. Ref T13217. Currently, we build this query in a weird way so we end up with `(1, 2, 3)` on both 32-bit and 64-bit systems. I can't reproduce the string-vs-int MySQL key issue on any system I have access to, so just simplify this and format as `('1', '2', '3')` instead. The issue this is working around is that MySQL would (I think?) sometimes appear to do something goofy and miss the key if you formatted the query with strings. I never really nailed this down and could have either been mistaken about it or it could be fixed in all modern versions of MySQL. Until we have better evidence to the contrary, assume MySQL is smart enough to handle this sensibly now. Test Plan: Ran daemons with Feed publish workers, no longer received query warnings. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13217, T13216 Differential Revision: https://secure.phabricator.com/D19837
This commit is contained in:
parent
8b550ce2cd
commit
88189f723f
1 changed files with 10 additions and 12 deletions
|
@ -64,22 +64,20 @@ final class PhabricatorFeedQuery
|
|||
}
|
||||
|
||||
if ($this->chronologicalKeys !== null) {
|
||||
// NOTE: We want to use integers in the query so we can take advantage
|
||||
// of keys, but can't use %d on 32-bit systems. Make sure all the keys
|
||||
// are integers and then format them raw.
|
||||
// NOTE: We can't use "%d" to format these large integers on 32-bit
|
||||
// systems. Historically, we formatted these into integers in an
|
||||
// awkward way because MySQL could sometimes (?) fail to use the proper
|
||||
// keys if the values were formatted as strings instead of integers.
|
||||
|
||||
$keys = $this->chronologicalKeys;
|
||||
foreach ($keys as $key) {
|
||||
if (!ctype_digit($key)) {
|
||||
throw new Exception(
|
||||
pht("Key '%s' is not a valid chronological key!", $key));
|
||||
}
|
||||
}
|
||||
// After the "qsprintf()" update to use PhutilQueryString, we can no
|
||||
// longer do this in a sneaky way. However, the MySQL key issue also
|
||||
// no longer appears to reproduce across several systems. So: just use
|
||||
// strings until problems turn up?
|
||||
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'ref.chronologicalKey IN (%LQ)',
|
||||
$keys);
|
||||
'ref.chronologicalKey IN (%Ls)',
|
||||
$this->chronologicalKeys);
|
||||
}
|
||||
|
||||
// NOTE: We may not have 64-bit PHP, so do the shifts in MySQL instead.
|
||||
|
|
Loading…
Reference in a new issue