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.- If it helps to think of it differently (since I find my own wording a little difficult to follow), imagine the following scenario:
- Create a wiki page and on it reference two or more pages which do not currently exist in your wiki.
- Save the page, then go to the WantedPages page of your wiki.
- If you only see one of the wanted pages listed (and possibly the count looks too high), you probably have this problem.
- -- AjHill
Cause
AnalysisRunning 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;
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