Page MenuHomePhabricator

Convert spoofuser.su_legal from BOOL to TINYINT
Open, Needs TriagePublic

Description

The column spoofuser.su_legal is defined as BOOL in mysql, sqlite and postgres.

But the BOOL is only a alias for tinyint(1) in mysql and that field allows to store numbers.
The numbers fails for postgres.

Per T257755#6863029 all bools should be converted to numbers

Bools are also not working with the abstract database layer, there are converts to integer in Database::addQuotes (and DatabasePostgres)

CI with postgres fails as well:

23:16:11 1) SpoofUserTest::testRecord
23:16:11 Wikimedia\Rdbms\DBQueryError: Error 42804: ERROR:  column "su_legal" is of type boolean but expression is of type integer
23:16:11 LINE 1: ...ed,su_legal,su_error) VALUES ('UserFoo','v2:USERFOO',1,NULL)
23:16:11                                                                 ^
23:16:11 HINT:  You will need to rewrite or cast the expression.
23:16:11 
23:16:11 Function: SpoofUser::batchRecord
23:16:11 Query: INSERT INTO "unittest_spoofuser" (su_name,su_normalized,su_legal,su_error) VALUES ('UserFoo','v2:USERFOO',1,NULL)
23:16:11 
23:16:11 
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:1799
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:1783
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:1758
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:1302
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:2530
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:2510
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:3541
23:16:11 /workspace/src/includes/libs/rdbms/database/Database.php:3516
23:16:11 /workspace/src/includes/libs/rdbms/database/DBConnRef.php:68
23:16:11 /workspace/src/includes/libs/rdbms/database/DBConnRef.php:484
23:16:11 /workspace/src/extensions/AntiSpoof/includes/SpoofUser.php:160
23:16:11 /workspace/src/extensions/AntiSpoof/includes/SpoofUser.php:124
23:16:11 /workspace/src/extensions/AntiSpoof/tests/phpunit/SpoofUserTest.php:31
23:16:11 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:452