Site:Developer stuff/Fix redirects
From Feast upon the Word (http://feastupontheword.org). Copyright, Feast upon the Word.
This script was used to fix the problem that when I added the redirect pages through the back-end I didn't properly set the flag "cur_is_redirect" at the time. For the version of wikimedia at the time, that must not have mattered. In the current version, that failure means that the redirect pages aren't treated as redirects.
This script will update cur_is_redirect to 1 for those cases where the text begins with #redirect but cur_is_redirect is stet to zero.
--first some checks... SELECT count(*) FROM `cur` WHERE `cur_text` like '#REDIRECT%' and `cur_is_redirect`=1 68 SELECT count(*) FROM `cur` WHERE `cur_text` like '#REDIRECT%' and `cur_is_redirect`=0 43360 SELECT count(*) FROM `cur` WHERE `cur_text` not like '#REDIRECT%' and `cur_is_redirect`=1 0 select * from cur where cur_text like '#REDIRECT%' and cur_is_redirect=0 Update cur set cur_is_redirect=1 where cur_text like '#REDIRECT%' and cur_is_redirect=0 --43360 (Query took 14.6187 sec) ---Not sure why there is both a page table and a cur table. I don't recall a page table in previous version select count(*) from cur a, page b where a.`cur_id`=b.page_id and a.cur_is_redirect<>b.page_is_redirect --43358 (it would seem it should be 43359--since I just fixed 1 but not 2 pages manually.) select count(*) from cur a, page b where a.`cur_id`=b.page_id and a.cur_is_redirect=1 and b.page_is_redirect=0 --43358 UPDATE page b INNER JOIN cur a ON a.cur_id=b.page_id SET b.page_is_redirect=1 where b.page_is_redirect=0 and a.cur_is_redirect=1 --Affected rows: 43358 (Query took 7.6943 sec)