Ticket #1877 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

Take only last version of wiki pages

Reported by: ebzao+trac@ebzao.info Assigned to: anonymous
Priority: normal Component: WantedPagesPlugin
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

Change History

08/01/07 14:12:07 changed by jfrancis

  • owner changed from jfrancis to anonymous.
  • status changed from new to assigned.

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

10/30/07 00:39:24 changed by anonymous

  • status changed from assigned to closed.
  • resolution set to fixed.

integrated in [2725]. It took a while, but hey, I'm lazy

12/09/07 22:34:21 changed by kamil@kamilkisiel.net

  • status changed from closed to reopened.
  • resolution deleted.

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))

12/11/07 01:47:34 changed by jfrancis

  • status changed from reopened to closed.
  • resolution set to fixed.

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]


Add/Change #1877 (Take only last version of wiki pages)




Change Properties
Action