Last modified: 2010-05-15 15:38:18 UTC
When removing an outgoing link from an article A, linking to article B (A->B), the corresponding record in the "pagelinks" table seems to *only* be removed if there exists no link from B to a (B->A). If I have a link from article B to article A, and another one in article A linking to article B, and I try to remove the one on page A linking to B, it will not be removed from the pagelinks table. I seem to find no way to fix this.
Works for me; tested on REL1_5 and HEAD current. 1) Create page [[A]] with text "link to [[b]]" 2) Create page [[B]] with text "link to [[a]" mysql> select page_namespace as ns,page_title,pl_from,pl_namespace, pl_title from page,pagelinks where page_id=pl_from and page_namespace=0 and page_title in ('A','B'); +----+------------+---------+--------------+----------+ | ns | page_title | pl_from | pl_namespace | pl_title | +----+------------+---------+--------------+----------+ | 0 | B | 6391 | 0 | A | | 0 | A | 6390 | 0 | B | +----+------------+---------+--------------+----------+ 3) Edit [[A]], change text to "remove link" and save. mysql> select page_namespace as ns,page_title,pl_from,pl_namespace, pl_title from page,pagelinks where page_id=pl_from and page_namespace=0 and page_title in ('A','B'); +----+------------+---------+--------------+----------+ | ns | page_title | pl_from | pl_namespace | pl_title | +----+------------+---------+--------------+----------+ | 0 | B | 6391 | 0 | A | +----+------------+---------+--------------+----------+
obviously that's: 2) Create page [[B]] with text "link to [[a]]"
I suppose it must have something to do with the fact that I'm trying to create an extension at the moment. It is supposed to get a list of all ingoing and outgoing links for the current article, much like the respective MediaWiki "special pages", and list them in a separate box on the same page with the article itself, so that the user may click on them without having to go to the special pages. I'm setting up my extension via parser hook: $wgParser->setHook("contextbar" , "contextbarHook"); Would this be the correct thing to do, or should it be hooked into the MediaWiki system in some other location, in order not to interfere with any database or other update activity? I can't seem to figure out just why the record (A->B) won't get deleted from the database, unless I remove the incoming link (B->A) first, and then do a manual update on the page (A).
Most likely your extension causes it to do a lookup of the page for the link, which causes it to be listed in the outgoing links when the link cache is saved into the pagelinks table on edit. Try disabling the link cache ($wgLinkCache) while you run your lookups, or try to otherwise avoid it.
Hi Brion! That was exactly what caused the problem. Your suggestion fixed it like a charm. Thanks again!