Page MenuHomePhabricator

Query error in Conpherence when searching for specific user
Closed, ResolvedPublic

Description

I apologize in advance for this one being kinda useless, but I figure it's worth reporting lest other people run into it and search.

STR:

  1. Be me.
  2. Go to https://secure.phabricator.com/conpherence/search/query/advanced/.
  3. Enter epriestley in the Participants input.
  4. Click Execute Query

Expected:
Search results containing 2 rooms: Z1336 General Chat and Z6 epriestley

Actual:

Unhandled Exception ("AphrontQueryException")
#1052: Column 'id' in where clause is ambiguous

My theory is that this is from Z6 being a very old room created from the now-gone Send Message profile action, and it's gotten broken in a migration at some point.

I attempted to repro this with several other usernames with no luck.
I attempted to create a new room with the same name as the single other participant and search for them, also worked fine.

Interestingly, Z6 also Hovercard's for me as Z6: Private Room

I'm happy for Phacility High Command to break into my account here to test this if fixing it is worthwhile.

The query in question:

SELECT conpherence_thread.* FROM `conpherence_thread` conpherence_thread JOIN `conpherence_participant` p ON p.conpherencePHID = conpherence_thread.phid WHERE ((`id` < 367)) AND (p.participantPHID IN ('PHID-USER-ba8aeea1b3fe2853d6bb')) GROUP BY conpherence_thread.id ORDER BY `id` DESC LIMIT 98

Stack Trace:

AphrontBaseMySQLDatabaseConnection::throwQueryCodeException called at [/core/lib/libphutil/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:289]
AphrontBaseMySQLDatabaseConnection::throwQueryException called at [/core/lib/libphutil/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:185]
AphrontBaseMySQLDatabaseConnection::executeRawQuery called at [/core/lib/libphutil/src/xsprintf/queryfx.php:6]
queryfx
call_user_func_array called at [/core/lib/libphutil/src/xsprintf/queryfx.php:11]
queryfx_all called at [/core/lib/phabricator/src/applications/conpherence/query/ConpherenceThreadQuery.php:109]
ConpherenceThreadQuery::loadPage called at [/core/lib/phabricator/src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php:227]
PhabricatorPolicyAwareQuery::execute called at [/core/lib/phabricator/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php:170]
PhabricatorCursorPagedPolicyAwareQuery::executeWithCursorPager called at [/core/lib/phabricator/src/applications/search/engine/PhabricatorApplicationSearchEngine.php:1031]
PhabricatorApplicationSearchEngine::executeQuery called at [/core/lib/phabricator/src/applications/search/controller/PhabricatorApplicationSearchController.php:230]
PhabricatorApplicationSearchController::processSearchRequest called at [/core/lib/phabricator/src/applications/search/controller/PhabricatorApplicationSearchController.php:73]
PhabricatorApplicationSearchController::processRequest called at [/core/lib/phabricator/src/aphront/AphrontController.php:29]
AphrontController::handleRequest called at [/core/lib/phabricator/src/aphront/AphrontController.php:71]
AphrontController::delegateToController called at [/core/lib/phabricator/src/applications/conpherence/controller/ConpherenceRoomListController.php:18]
ConpherenceRoomListController::handleRequest called at [/core/lib/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:237]
phlog called at [/core/lib/phabricator/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:32]
PhabricatorDefaultRequestExceptionHandler::handleRequestException called at [/core/lib/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:644]
AphrontApplicationConfiguration::handleException called at [/core/lib/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:242]
AphrontApplicationConfiguration::processRequest called at [/core/lib/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:149]
AphrontApplicationConfiguration::runHTTPRequest called at [/core/lib/phabricator/webroot/index.php:17]

Event Timeline

I think I figured this one out: it's actually because more than 100 rooms are being filtered. The (`id` < 367) part is being added by pagination code, but won't activate if a user is in less than 100 rooms.

(I'm in >100, most of which are invisible, because a lot of random users send me random messages.)

I can reproduce this by following the same steps and then clicking "Next Page" -- the first page works fine since I can see all the results, but the second page adds the pagination clause.

This should be an easy fix.