@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+10 -12
+10 -12
src/applications/feed/query/PhabricatorFeedQuery.php
··· 64 64 } 65 65 66 66 if ($this->chronologicalKeys !== null) { 67 - // NOTE: We want to use integers in the query so we can take advantage 68 - // of keys, but can't use %d on 32-bit systems. Make sure all the keys 69 - // are integers and then format them raw. 67 + // NOTE: We can't use "%d" to format these large integers on 32-bit 68 + // systems. Historically, we formatted these into integers in an 69 + // awkward way because MySQL could sometimes (?) fail to use the proper 70 + // keys if the values were formatted as strings instead of integers. 70 71 71 - $keys = $this->chronologicalKeys; 72 - foreach ($keys as $key) { 73 - if (!ctype_digit($key)) { 74 - throw new Exception( 75 - pht("Key '%s' is not a valid chronological key!", $key)); 76 - } 77 - } 72 + // After the "qsprintf()" update to use PhutilQueryString, we can no 73 + // longer do this in a sneaky way. However, the MySQL key issue also 74 + // no longer appears to reproduce across several systems. So: just use 75 + // strings until problems turn up? 78 76 79 77 $where[] = qsprintf( 80 78 $conn, 81 - 'ref.chronologicalKey IN (%LQ)', 82 - $keys); 79 + 'ref.chronologicalKey IN (%Ls)', 80 + $this->chronologicalKeys); 83 81 } 84 82 85 83 // NOTE: We may not have 64-bit PHP, so do the shifts in MySQL instead.