WantedPages Broken

This workaround page will hopefully help you if you find the WantedPages function of a version 1.1.6.4 wiki installation.

Symptoms

The list of WantedPages, for a wiki where there are more than one known "wanted pages", incorrectly displays only the first wanted page with a "wanted count" of the total of all wanted pages counts together.

Cause

Analysis
Running the following query against the database (v1.1.6.4 schema, may apply to others) should return the data which is expected for the WantedPages function (assumes you used the wikka_ prefix for your tables).

SELECT DISTINCT wikka_links.to_tag as tag, count(wikka_links.from_tag) as count
FROM wikka_links LEFT JOIN wikka_pages on wikka_links.to_tag = wikka_pages.tag
WHERE wikka_pages.tag IS NULL GROUP BY wikka_links.to_tag ORDER BY count desc;


If this doesn't match what the WantedPages is displaying there is a problem.

Technical explanation:
The query which provides the base data for the WantedPages functionality, found in the libs/Wakka.class.php file, is grouping by tag in the current query. Because one of the tables involved in the query (wikka_pages) actually has a column with this name MySQL performs the grouping on the table column instead of the aliased wikka_links.to_tag column.

Applies To

Wikka version 1.1.6.4 for certain; also for older versions in the 1.1.6.x line. The current development trunk (as of 2008-05-20) resolves this issue by using a column alias which doesn't overlap with an existing column name. Check out bug #309 on the wiki bug tracker.

Solution

A modification to the libs/Wakka.class.php LoadWantedPages() function will resolve this issue.

Locate the following line of code (should be around 710 if you haven't already modded the file):

function LoadWantedPages() { return $this->LoadAll("select distinct ".$this->config["table_prefix"]."links.to_tag as tag,count(".$this->config["table_prefix"]."links.from_tag) as count from ".$this->config["table_prefix"]."links left join ".$this->config["table_prefix"]."pages on ".$this->config["table_prefix"]."links.to_tag = ".$this->config["table_prefix"]."pages.tag where ".$this->config["table_prefix"]."pages.tag is NULL group by tag order by count desc"); }


Replace it with the following:

function LoadWantedPages() { return $this->LoadAll("select distinct ".$this->config["table_prefix"]."links.to_tag as tag,count(".$this->config["table_prefix"]."links.from_tag) as count from ".$this->config["table_prefix"]."links left join ".$this->config["table_prefix"]."pages on ".$this->config["table_prefix"]."links.to_tag = ".$this->config["table_prefix"]."pages.tag where ".$this->config["table_prefix"]."pages.tag is NULL group by ".$this->config["table_prefix"]."links.to_tag order by count desc"); }


Ready to go!


CategoryWorkaround
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki