Last modified: 2012-08-04 20:48:38 UTC
Created attachment 4513 [details] Patch for includes/filerepo/LocalFile.php. System: -------------------------------------------------------------- *MediaWiki 1.11.0 + bug 12365 fixed. *PostgreSQL 8.2.5 *FreeBSD/pc98 4.7R Appears: ------------------------------------------------------------- In some pattern I can't delete images. OK: Upload new image -> Delete it. OK: Upload new image -> Replace image -> Delete old image -> Delete image. NG: Upload new image -> Replace image -> Delete ALL images (with oldimage). Backtrace: ----------------------------------------------------------- 内部処理エラー A database error has occurred Query: DELETE FROM image WHERE img_name = 'En_ban.png' Function: LocalFileDeleteBatch::doDBDeletes Error: 1 ERROR: update or delete on table "image" violates foreign key constraint "oldimage_oi_name_fkey" on table "oldimage" DETAIL: Key (img_name)=(En_ban.png) is still referenced from table "oldimage". Backtrace: #0 /home/cory/mediawiki-1.11.0/includes/Database.php(795): DatabasePostgres->reportQueryError('ERROR: update ...', 1, 'DELETE FROM ima...', 'LocalFileDelete...', false) #1 /home/cory/mediawiki-1.11.0/includes/Database.php(1828): Database->query('DELETE FROM ima...', 'LocalFileDelete...') #2 /home/cory/mediawiki-1.11.0/includes/filerepo/LocalFile.php(1257): Database->delete('image', Array, 'LocalFileDelete...') #3 /home/cory/mediawiki-1.11.0/includes/filerepo/LocalFile.php(1325): LocalFileDeleteBatch->doDBDeletes() #4 /home/cory/mediawiki-1.11.0/includes/filerepo/LocalFile.php(874): LocalFileDeleteBatch->execute() #5 /home/cory/mediawiki-1.11.0/includes/FileDeleteForm.php(75): LocalFile->delete('for test.') #6 /home/cory/mediawiki-1.11.0/includes/ImagePage.php(491): FileDeleteForm->execute() #7 /home/cory/mediawiki-1.11.0/includes/Wiki.php(397): ImagePage->delete() #8 /home/cory/mediawiki-1.11.0/includes/Wiki.php(48): MediaWiki->performAction(Object(OutputPage), Object(ImagePage), Object(Title), Object(User), Object(WebRequest)) #9 /home/cory/mediawiki-1.11.0/index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest)) #10 {main} Cause: --------------------------------------------------------------- In MySQL, oldimage table is NOT related to image table. But in PostgreSQL, oldimage table is related to image table. maintenance/tables.sql (MySQL) CREATE TABLE /*$wgDBprefix*/oldimage ( oi_name varchar(255) binary NOT NULL default '', maintenance/postgres/tables.sql (PostgreSQL) CREATE TABLE oldimage ( oi_name TEXT NOT NULL REFERENCES image(img_name), And deleting process written in includes/filerepo/LocalFile.php, tring to delete image table at first, but on PostgreSQL systems can't delete it because related data is still active. Solution: ------------------------------------------------------------ Please patch for includes/filerepo/LocalFile.php, and try it. # This document written in Japanese, please see: 日本語の解説をこちらに書いておきます→http://www.cory.to/kn/kn080106
Thanks for the patch, applied in r30801.