Page MenuHomePhabricator

Value inserted into ipb_parent_block_id is 0 if a block with autoblock enabled is updated
Open, Needs TriagePublicBUG REPORT

Description

An autoblock is a block against an IP address, spawned from a block against a user account. For an autoblock, the ipb_parent_block_id column holds the ID of the block that spawned it.

All other blocks should have ipb_parent_block_id = null.

However, if a (non-auto)block is updated, it is re-saved with ipb_parent_block_id set to 0.

The bug seems to come from this line: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/9ba56ccb3b85175da3de36e6b9f9c0a30c007d1f/includes/block/DatabaseBlock.php#463


Example from itwiki:

> SELECT COUNT(*) FROM ipblocks WHERE ipb_parent_block_id = 0;
+----------+
| COUNT(*) |
+----------+
|      898 |
+----------+

> SELECT COUNT(*) FROM ipblocks WHERE ipb_parent_block_id = 0 AND ipb_user != 0;
+----------+
| COUNT(*) |
+----------+
|      842 |
+----------+

The first case shouldn't be possible, because no blocks have ipb_id = 0, and the second shouldn't be possible because all blocks against a user account (i.e. ipb_user is nonzero) should have ipb_parent_block_id = null.

Event Timeline

Niharika changed the subtype of this task from "Task" to "Bug Report".

Change 696544 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/core@master] DatabaseBlock: don't save parent block id as 0

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