#1877 closed enhancement (fixed)
Take only last version of wiki pages
| Reported by: | Owned by: | anonymous | |
|---|---|---|---|
| Priority: | normal | Component: | WantedPagesMacro |
| Severity: | minor | Keywords: | |
| Cc: | Trac Release: | 0.10 |
Description
Hi,
I've made this little patch to take only last version of wiki pages when searching for wanted pages. I think it's non-sense to make links used only in old version of wiki pages.
Perhaps there is a better SQL query to have this, I haven't found it ;-)
Index: wanted_pages.py
===================================================================
--- wanted_pages.py (révision 2539)
+++ wanted_pages.py (copie de travail)
@@ -13,7 +13,7 @@
fancy_re = re.compile(FANCY)
exclude_re = re.compile(EXCLUDE)
-wiki_sql = "SELECT name, text FROM wiki ORDER BY version"
+wiki_sql = "SELECT name, text FROM wiki ORDER BY version DESC"
ticket_sql= """SELECT id, description FROM ticket
UNION
SELECT ticket, newvalue FROM ticket_change WHERE field='comment'
@@ -55,11 +55,14 @@
def buildWikiText(self, showReferrers=False):
texts = [] # list of referrer link, wiki-able text tuples
wantedPages = {} # referrers indexed by page
+ wikiPages = [] # list of wikiPages seen
db = self.env.get_db_cnx()
for name, text in exec_wiki_sql(db):
- self.index[name] = name
- texts.append(('[wiki:%s]' % name, text))
+ if name not in wikiPages:
+ wikiPages.append(name)
+ self.index[name] = name
+ texts.append(('[wiki:%s]' % name, text))
for id, text in exec_ticket_sql(db):
texts.append(('#%s' % id, text))
Attachments (0)
Change History (5)
comment:1 Changed 18 years ago by
| Owner: | changed from Justin Francis to anonymous |
|---|---|
| Status: | new → assigned |
comment:2 Changed 18 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
integrated in [2725]. It took a while, but hey, I'm lazy
comment:3 Changed 18 years ago by
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
The implemented version is incorrect. The indentation level on the last two lines of the fix is wrong, so the plugin still adds all pages. Currently it looks like this:
if name not in wikiPages:
wikiPages.append(name)
self.index[name] = name
texts.append(('[wiki:%s]' % name, text))
but it should look like this:
if name not in wikiPages:
wikiPages.append(name)
self.index[name] = name
texts.append(('[wiki:%s]' % name, text))
comment:4 Changed 18 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Hmmmm. It appears it was my mistake. My editor inserted tabs when I needed space-tabs. There was a mixture of spaces and tabs that resulted in this code still running, but exactly was it was before.
In any case, it has been fixed in [2873]
comment:5 Changed 12 years ago by
| Component: | WantedPagesPlugin → WantedPagesMacro |
|---|
Renaming plugin from WantedPagesPlugin to WantedPagesMacro.



Thanks for patch. I'll write some unit tests to expose the bug and integrate the patch in the next week.