Page MenuHomePhabricator

sql files of extension CreditsSource failing on unit tests due to default on text column
Closed, ResolvedPublic

Description

I assume that the new strict mysql setting in CI is breaking the tests of CreditsSource

Fatal error: Uncaught exception 'Wikimedia\Rdbms\DBQueryError' with message 'A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Query: CREATE TABLE IF NOT EXISTS `revsrc` (
 revsrc_revid        int unsigned NOT NULL,
 revsrc_srcworkid    int unsigned NOT NULL,
 revsrc_timestamp    binary(14) NOT NULL,
 revsrc_user         int unsigned NOT NULL,
 revsrc_user_text    text NOT NULL,
 revsrc_comment      text NOT NULL DEFAULT ''
 ) ENGINE=InnoDB, DEFAULT CHARSET=binary

Function: Wikimedia\Rdbms\Database::sourceFile( /workspace/src/extensions/CreditsSource/includes/../schema/mysql/CreditsSource.sql )
Error: 1101 BLOB/TEXT column 'revsrc_comment' can't have a default value (/workspace/db/quibble-mysql-f6gyqz7s/socket)
' in /workspace/src/includes/libs/rdbms/database/Database.php:1587

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 6 2019, 7:28 PM
jcrespo added a subscriber: jcrespo.Apr 8 2019, 7:49 AM
Before MariaDB 10.2.1, BLOB and TEXT columns could not be assigned a DEFAULT value. This restriction was lifted in MariaDB 10.2.1.

The restriction affects also all versions of MySQL, although 8.0 allows using an expression as a default (not a literal).

Mediawiki has to support MySQL/MariaDB 5.5, so this wouldn't be accepted on core or any bundled extension, however I think in an optional extension this would be accepted if it is documented. For comparison, the current database on WMF production is MariaDB 10.1, so I am not sure you will have a wide audience. On the good practices side, NULL would be preferred to DEFAULT '', and handle the null values on the application, as that is the right way to handle unknown/invalid values.

I need a way to pass the tests on CI, so a newer version for this extension is needed or a change to the sql file. I have no idea if that is possible or if the empty string is needed and prefered over null

hashar added a subscriber: hashar.Apr 9 2019, 9:59 PM

Note that CreditsSource is used on Wikivoyage wikis:

wmf-config/InitialiseSettings.php
'wmgUseCreditsSource' => [
    'default' => false,
    'wikivoyage' => true,
],

The database field has been there as is since at least 2012. The comment field might not even be used, or if it is, I have no idea how :-/

@hashar here we have a bug:

root@db1070[enwikivoyage]> show create table revsrc\G
*************************** 1. row ***************************
       Table: revsrc
Create Table: CREATE TABLE `revsrc` (
  `revsrc_revid` int(11) NOT NULL,
  `revsrc_srcworkid` int(11) NOT NULL,
  `revsrc_timestamp` binary(14) NOT NULL,
  `revsrc_user` int(11) NOT NULL,
  `revsrc_user_text` varbinary(255) NOT NULL,
  `revsrc_comment` blob NOT NULL,
  UNIQUE KEY `revsrc_rs_unique` (`revsrc_revid`,`revsrc_srcworkid`),
  KEY `revsrc_revid_index` (`revsrc_revid`),
  KEY `revsrc_timestamp_index` (`revsrc_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=binary ROW_FORMAT=COMPRESSED

Change 502843 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/CreditsSource@master] Remove default value from database field revsrc_comment

https://gerrit.wikimedia.org/r/502843

Change 502843 merged by jenkins-bot:
[mediawiki/extensions/CreditsSource@master] Remove default value from database field revsrc_comment

https://gerrit.wikimedia.org/r/502843

Umherirrender closed this task as Resolved.Apr 11 2019, 3:41 PM
Umherirrender triaged this task as Medium priority.