Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#1956 closed defect (fixed)

Version 0 of wiki page prevents its display.

Reported by: Markus Tacker <m@…> Owned by: Christopher Lenz
Priority: normal Milestone: 0.9
Component: wiki system Version: devel
Severity: critical Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Some wiki pages (dated 2005-08-02 15:39 and earlier) which have been created with trunk have an initial value of 0 as version. These pages are not displayed in the wiki.

Attachments (1)

renumber-wiki-version.py (1.0 KB ) - added by Shunichi Goto <gotoh@…> 17 years ago.
Fixup version number of wiki page which starts from version 0

Download all attachments as: .zip

Change History (10)

comment:1 by vivek@…, 17 years ago

Severity: majorcritical

I have some older pages from july which have never been updated since they were created, and those do not appear. They all have the highest revision number = 0. Pages which have been updated show up just fine. svn update version of trac from about 15 minutes ago still has this problem.

comment:2 by anonymous, 17 years ago

This is probably due to [2071].

comment:3 by anonymous, 17 years ago

workaround:

run sqlite project/db/trac.db then issue these commands:

begin;
update wiki set version=1 where version=0 and name in (select name from wiki group by name having max(version)=0);
commit;

Perhaps the trac-admin upgrade command should/could do this for you?

comment:4 by anonymous, 17 years ago

This looks to be an issue only for people using the development version after the wiki code refactor and prior to [2071]. I don't think the current trac production release creates wiki pages at version 0. In light of that, I think a small script to correct bad pages would be the best solution.

comment:5 by Christopher Lenz, 17 years ago

Milestone: 0.9
Owner: changed from Jonas Borgström to Christopher Lenz
Status: newassigned

This mess is my fault; not sure how to clean it up… :-P

by Shunichi Goto <gotoh@…>, 17 years ago

Attachment: renumber-wiki-version.py added

Fixup version number of wiki page which starts from version 0

comment:6 by Shunichi Goto <gotoh@…>, 17 years ago

This problem bother me, too. I made fixup (renumbering) script, attached. Use like this:

  python renumber-wiki-version.py /var/trac/projects/myproj

Note: Do not forget backup before use it.

comment:7 by Matthew Good, 17 years ago

Yeah, I'd actually written a similar script of my own. This can pretty easily be added to Trac so that it's done by trac-admin upgrade, though I'm debating whether it should go into a new db-version upgrade script, or as a separate IEnvironmentSetupParticipant. It doesn't really seem necessary to create a new DB version, since this may not actually be necessary for some users, although otherwise we'll need to check for any Wiki pages with version 0 every time the evironment is loaded. Perhaps we should have some recommended manner (maybe via the system table) that scripts can keep track that they're only run once.

I'll include the possible patch for the db-version method here since it's short and we can discuss if there's a good way to convert it to an IEnvironmentSetupParticipant.

  • trac/db_default.py

     
    1818from trac.db import Table, Column, Index
    1919
    2020# Database version identifier. Used for automatic upgrades.
    21 db_version = 13
     21db_version = 14
    2222
    2323def __mkreports(reports):
    2424    """Utility function used to create report data in same syntax as the
  • trac/upgrades/db14.py

     
     1def do_upgrade(env, ver, cursor):
     2    cursor.execute('select name, version from wiki where name in '
     3                   '(select name from wiki  where version = 0) order by name,'
     4                   ' version desc')
     5    cursor.executemany('update wiki set version = version + 1 where name = %s '
     6                       'and version = %s',
     7                       [tuple(row) for row in cursor.fetchall()])
     8

comment:8 by Christopher Lenz, 17 years ago

Resolution: fixed
Status: assignedclosed

Patch applied in [2186].

comment:9 by Emmanuel Blot, 17 years ago

if you get the following error while executing Shunichi Goto 's script:

Traceback (most recent call last):
  File "renumber-wiki-version.py", line 25, in ?
    cursor.execute('SELECT version FROM wiki WHERE name = %s ORDER BY version DESC', page)
  File "/local/engine/trac/trac/db.py", line 178, in execute
    sql = sql % tuple(['?'] * len(args))
TypeError: not all arguments converted during string formatting

replace line 25 with

cursor.execute('SELECT version FROM wiki WHERE name = %s ORDER BY version DESC', (page,))

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz 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.