Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

#3294 closed defect (fixed)

[PATCH] Trac fails to set HDF var `wiki.page_name` when viewing `WikiStart` page

Reported by: maxb1@… Owned by: Christian Boos
Priority: normal Milestone: 0.10
Component: wiki system Version: devel
Severity: trivial Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Trac fails to set the HDF variable wiki.page_name when viewing the WikiStart page.

This can trip up plugins such as wiki macros, or force them to insert an unnecessary special case.

The problem occurs because code in trac/wiki/web_ui.py tries to re-implement the _set_title function as a special case for WikiStart, and omits part of the functionality (setting wiki.page_name). The fix is to simply make use of _set_title unconditionally, and then tweak the results as a special case for WikiStart:

Index: trac/wiki/web_ui.py
===================================================================
--- trac/wiki/web_ui.py (revision 3431)
+++ trac/wiki/web_ui.py (working copy)
@@ -398,11 +398,9 @@
     def _render_view(self, req, db, page):
         req.perm.assert_permission('WIKI_VIEW')

+        page_name = self._set_title(req, page, '')
         if page.name == 'WikiStart':
             req.hdf['title'] = ''
-            page_name = 'WikiStart'
-        else:
-            page_name = self._set_title(req, page, '')

         version = req.args.get('version')
         if version:

Attachments (0)

Change History (2)

comment:1 by Christian Boos, 19 years ago

Milestone: 0.10
Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

The problem with using the HDF's wiki.page_name for retrieving the page name is that you'll get either "WikiStart" or "Wiki Start", depending on the value of the [wiki] split_page_names option.

A more reliable way to get that information in milestone:0.10 would be to parse the value of the HDF's wiki.current_href key:

    current_href = req.hdf.get('wiki.current_href')
    current_page = current_href[current_href.find('/wiki/')+6:]

comment:2 by Christian Boos, 19 years ago

Milestone: 0.10
Resolution: fixed
Severity: normaltrivial
Status: assignedclosed

Patch applied in r3432, as it simplifies the code a bit. But again, don't rely on wiki.page_name for the TracHAcks:TocMacro.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.