Page MenuHomePhabricator

Defaults for integer columns in cu_changes need to be updated from strings
Closed, DeclinedPublic

Description

My cu_changes table according to the command '.schema cu_changes' produces

CREATE TABLE cu_changes (
 cuc_id INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,
 cuc_namespace INTEGER NOT NULL default '0',
 cuc_title TEXT  NOT NULL default '',
 cuc_user INTEGER NOT NULL DEFAULT 0,
 cuc_user_text TEXT NOT NULL DEFAULT '',
 cuc_actor INTEGER  NOT NULL DEFAULT 0,
 cuc_actiontext TEXT  NOT NULL default '',
 cuc_comment TEXT  NOT NULL default '',
 cuc_comment_id INTEGER  NOT NULL DEFAULT 0,
 cuc_minor INTEGER NOT NULL default '0',
 cuc_page_id INTEGER  NOT NULL default '0',
 cuc_this_oldid INTEGER  NOT NULL default '0',
 cuc_last_oldid INTEGER  NOT NULL default '0',
 cuc_type INTEGER  NOT NULL default '0',
 cuc_timestamp TEXT NOT NULL default '',
 cuc_ip TEXT NULL default '',
 cuc_ip_hex TEXT default NULL,
 cuc_xff TEXT  NULL default '',
 cuc_xff_hex TEXT default NULL,
 cuc_agent TEXT  default NULL,
 cuc_private BLOB default NULL
 );

A number of INTEGER columns have their defaults as string values representing 0. The values need to be fixed to be the literal number 0 and any entries that have the wrong value need to be fixed.

This comes from CheckUser using mysql SQL code to make the SQLite DB. This used string 0's as the defaults.

Event Timeline

This comes from CheckUser using mysql SQL code to make the SQLite DB.

I guess that has been fixed by https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CheckUser/+/758077.

Sure, but instances using sqlite that were created before that change won't have their defaults updated. I'm thinking something in Hooks.php for cuc_type as that wasn't included in the list of setDefaults in Hooks.php.

All returns from the database are strings. If the database does not convert a wrongly given default, that sounds like a bug there. Mysql has accept the default, because it can cast the string 0 to a numeric 0.

Misunderstood how mediawiki returns values from the DB. Local testing suggests sqlite does this fix already, so all should be fine. Closing as declined.