#1956 closed defect (fixed)
Version 0 of wiki page prevents its display.
Reported by: | 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)
Change History (10)
comment:1 by , 19 years ago
Severity: | major → critical |
---|
comment:3 by , 19 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 , 19 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 , 19 years ago
Milestone: | → 0.9 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
This mess is my fault; not sure how to clean it up… :-P
by , 19 years ago
Attachment: | renumber-wiki-version.py added |
---|
Fixup version number of wiki page which starts from version 0
comment:6 by , 19 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 , 19 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
18 18 from trac.db import Table, Column, Index 19 19 20 20 # Database version identifier. Used for automatic upgrades. 21 db_version = 1 321 db_version = 14 22 22 23 23 def __mkreports(reports): 24 24 """Utility function used to create report data in same syntax as the -
trac/upgrades/db14.py
1 def 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:9 by , 19 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,))
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.