Page MenuHomePhabricator

Cannot delete page due to foreign key constraint on recentchanges
Closed, ResolvedPublic

Description

Author: 25albert+mw

Description:
Trying to delete a page leads to the following message:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: update or delete on "page" violates foreign key constraint "recentchanges_rc_cur_id_fkey" on "recentchanges" DETAIL: Key (page_id)=(24) is still referenced from table "recentchanges". in /usr/share/mediawiki/includes/db/DatabasePostgres.php on line 580

Warning: pg_query() [function.pg-query]: Query failed: ERROR: current transaction is aborted, commands ignored until end of transaction block in /usr/share/mediawiki/includes/db/DatabasePostgres.php on line 580

I indeed have a constraint in the recentchanges table, which probably need to be corrected:

ALTER TABLE mediawiki.recentchanges

ADD CONSTRAINT recentchanges_rc_cur_id_fkey FOREIGN KEY (rc_cur_id)
    REFERENCES mediawiki.page (page_id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE NO ACTION;

Version: 1.15.x
Severity: normal

Details

Reference
bz24780

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:08 PM
bzimport set Reference to bz24780.
bzimport added a subscriber: Unknown Object (MLST).

25albert+mw wrote:

In the meantime, I found this bug mentioned for Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517237

The fix suggested there appears to work. I did the following (only changing the ON DELETE action):

ALTER TABLE mediawiki.recentchanges DROP CONSTRAINT recentchanges_rc_cur_id_fkey;

ALTER TABLE mediawiki.recentchanges

ADD CONSTRAINT recentchanges_rc_cur_id_fkey FOREIGN KEY (rc_cur_id)
    REFERENCES mediawiki.page (page_id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE SET NULL;

The constraint was fixed in r15697, so the fix made it into 1.8.

But it seems there is no update for it. Does anyone still has an old MediaWiki installation that needs to be updated to test?

karun.84 wrote:

This has been fixed in r15697.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.