[ 
https://issues.apache.org/jira/browse/JSPWIKI-649?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12864614#action_12864614
 ] 

Magnus Lindberg commented on JSPWIKI-649:
-----------------------------------------

Hi Harry, thanks for the information on code formatting.

The scenario is, briefly, that I delete old versions of certain pages, and if 
the version history is not up-to-date, I attempt to delete versions that don't 
exist, and then a NoSuchVersionException is thrown.

A more detailed explanation follows:

I have written a discussion forum plugin.

Each discussion thread (i.e. each topic) is stored in a page with a certain 
suffix.

Each such discussion-thread-storage-page itself contains all version history 
(i.e. all comments for that thread/topic).

Hence only the very last version of such a page is needed.

So, when a new comment is added, the plugin creates a new version of the 
discussion-storage-page,\\
and iterates all old page versions,\\
and deletes them.

Since the version history information provided by 
{{WikiPageProvider.getVersionHistory}} is sometimes out-of-date\\
(because of the bug in {{CachingProvider}}),\\
the plugin sometimes attempts to delete a version of a page that does not exist.

This results in a {{NoSuchVersionException}} from 
{{WikiPageProvider.deleteVersion}}.

(I suppose the cache is refreshed after some seconds, so this is perhaps only 
an issue if two comments are added to a discussion within a short period of 
time.)

***

(It seems JSPWiki 3.0 uses the {{CachingProvider}} no more, so probably only 
the 2.8 branch (and other 2.X perhaps) are affected.)

***

( What I really wish to do is to 1) disable versioning for the relevant pages, 
and 2) also disallow anyone from reading/editing those magic 
discussion-storage-pages.
 -- but these are two separate issues, I suppose; I'd better ask on the user's 
mailing list in case other people are also interested. )


Regards, Magnus



> CachingProvider.deleteVersion leaves a stale m_historyCache
> -----------------------------------------------------------
>
>                 Key: JSPWIKI-649
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-649
>             Project: JSPWiki
>          Issue Type: Bug
>          Components: Core & storage
>    Affects Versions: 2.8.3, 2.8.4
>         Environment: Ubuntu, Sun Java 1.6
>            Reporter: Magnus Lindberg
>            Priority: Minor
>         Attachments: jira-jspwiki-cachingprovider-patch.txt
>
>
> Hi JSPWiki developers,
> The function
>   public void deleteVersion( String pageName, int version )
> in class CachingProvider does not always update the page history cache 
> appropriately.
> As a result, NoSuchVersionException:s can be thrown, if it's later assumed 
> that a page exists,
> because it's present in the (cached) history list.
> Below patch should fix the bug. (Works for me.)
> Regards, Magnus
> <pre>
> Index: src/com/ecyrd/jspwiki/providers/CachingProvider.java
> ===================================================================
> --- src/com/ecyrd/jspwiki/providers/CachingProvider.java      (revision 
> 938415)
> +++ src/com/ecyrd/jspwiki/providers/CachingProvider.java      (working copy)
> @@ -815,10 +815,10 @@
>              {
>                  m_cache.removeEntry( pageName );
>                  m_textCache.removeEntry( pageName );
> -                m_historyCache.removeEntry( pageName );
>              }
>  
>              m_provider.deleteVersion( pageName, version );
> +            m_historyCache.removeEntry( pageName );
>          }
>      }
> </pre>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to