Opened 6 years ago

Closed 4 years ago

#4051 closed defect (fixed)

[Patch] BackLinksMacro

Reported by: anonymous Owned by: trapanator
Priority: normal Component: BackLinksMacro
Severity: normal Keywords:
Cc: Trac Release: 0.10


SQL in 0.11 version looks for explicit wiki links but not simple CamelCase references to thispage.

Revised query as shown below:

if thispage:
    sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % thispage
    sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\' ' % thispage
    sql += 'OR w1.text LIKE \'%%%s%%\')' % thispage

The plugin works for me now in 0.11 with sqlite3.

Attachments (2)

BackLink.5.CamelCase.Fix.patch (1.7 KB) - added by butterflow 5 years ago.
BackLink.5.CamelCase.Fix.2.patch (1.8 KB) - added by butterflow 5 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 6 years ago by anonymous

That's great. Thanks for submitting the fix! Tested and working on 0.11b with sqlite3.

comment:2 Changed 5 years ago by anonymous

Here's a patch for the 0.10 version. The primary difference between this patch and the code above is that this patch filters out things that use the !NoLinkHere syntax.

---   2008-01-31 15:39:26.000000000 -0500
+++        2009-02-06 23:43:41.000000000 -0500
@@ -19,8 +19,12 @@
                  '(SELECT name, MAX(version) AS VERSION FROM WIKI GROUP BY NAME) w2 ' + \
                  'WHERE w1.version = w2.version AND = '
        if thispage:
-                       sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % (unicode(thispage, "utf-8").encode ("utf-8"))
-                       sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\')' % (unicode (thispage, "utf-8").encode ("utf-8"))
+            utf8 = unicode(thispage, "utf-8").encode("utf-8")
+            sql += 'AND (w1.text LIKE \'%%[wiki:%s %%\' ' % utf8 
+            sql += 'OR w1.text LIKE \'%%[wiki:%s]%%\' ' % utf8 
+            if thispage[1:].lower() != thispage[1:]:
+                sql += "OR replace(w1.text, '!%s', '') LIKE '%%%s%%' " % (utf8, utf8) 
+            sql += ')'
        buf = StringIO()
        buf.write('<hr style="width: 10%; padding: 0; margin: 2em 0 1em 0;"/>')

comment:3 Changed 5 years ago by butterflow

Improved the fix for camel case TracLinks

Changed 5 years ago by butterflow

Changed 5 years ago by butterflow

comment:4 Changed 5 years ago by anonymous

  • Summary changed from BackLinksMacro to [Patch] BackLinksMacro

comment:5 Changed 4 years ago by trapanator

  • Resolution set to fixed
  • Status changed from new to closed

I've got your suggestions and I fixed in r7509

Thank you.

Add Comment

Modify Ticket

as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from trapanator. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.