@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.

Provide more help around GRANT errors, particularly for missing TEMPORARY TABLE permission

Summary:
Fixes T13622. Figuring out what permissions we have seems difficult, so address this a bit more narrowly:

- Make the "access denied" error message a bit more helpful.
- Tailor error handling for the "CREATE TEMPORARY TABLE" statement.

Test Plan:
- Created a new user, granted them "SELECT ON *.*" but not "CREATE TEMPORARY TABLE", ran `bin/storage upgrade --force --apply phabricator:20210215.changeset.02.phid-populate.php`.
- Before: fairly opaque error.
- After: fairly useful error.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13622

Differential Revision: https://secure.phabricator.com/D21608

+24 -7
+14 -6
resources/sql/autopatches/20210215.changeset.02.phid-populate.php
··· 11 11 12 12 $temporary_table = 'tmp_20210215_changeset_id_map'; 13 13 14 - queryfx( 15 - $conn, 16 - 'CREATE TEMPORARY TABLE %T ( 17 - changeset_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 18 - changeset_phid VARBINARY(64) NOT NULL)', 19 - $temporary_table); 14 + try { 15 + queryfx( 16 + $conn, 17 + 'CREATE TEMPORARY TABLE %T ( 18 + changeset_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 19 + changeset_phid VARBINARY(64) NOT NULL)', 20 + $temporary_table); 21 + } catch (AphrontAccessDeniedQueryException $ex) { 22 + throw new PhutilProxyException( 23 + pht( 24 + 'Failed to "CREATE TEMPORARY TABLE". You may need to "GRANT" the '. 25 + 'current MySQL user this permission.'), 26 + $ex); 27 + } 20 28 21 29 $table_iterator = id(new LiskRawMigrationIterator($conn, $table_name)) 22 30 ->setPageSize($chunk_size);
+10 -1
src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
··· 347 347 case 1142: // Access denied to table 348 348 case 1143: // Access denied to column 349 349 case 1227: // Access denied (e.g., no SUPER for SHOW SLAVE STATUS). 350 - throw new AphrontAccessDeniedQueryException($message); 350 + 351 + // See T13622. Try to help users figure out that this is a GRANT 352 + // problem. 353 + 354 + $more = pht( 355 + 'This error usually indicates that you need to "GRANT" the '. 356 + 'MySQL user additional permissions. See "GRANT" in the MySQL '. 357 + 'manual for help.'); 358 + 359 + throw new AphrontAccessDeniedQueryException("{$message}\n\n{$more}"); 351 360 case 1045: // Access denied (auth) 352 361 throw new AphrontInvalidCredentialsQueryException($message); 353 362 case 1146: // No such table