Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-232

Problem with cache in Downloadrev and ImagePlugin

    XMLWordPrintable

Details

    Description

      There is a problem with DownloadRev and ImagePlugin. The cache seems to store a wrong version.
      To reproduce

      1/ Upload an image called test.jpg
      2/ Update with a different image called also test.jpg
      3/ View history

      Both images will be the same in the thumbnail
      If you remove the width parameters from the downloadrev url you will get the right image. This proves the problem is in the cache

      The following code in com.xpn.xwiki.plugin.image.ImagePlugin

      public XWikiAttachment downloadAttachment(XWikiAttachment attachment, XWikiContext context) {

      int height = 0;
      int width = 0;
      XWikiAttachment attachmentClone = null;
      try {
      String sheight = context.getRequest().getParameter("height");
      String swidth = context.getRequest().getParameter("width");

      if (sheight!=null)
      height = Integer.parseInt(sheight);
      if (swidth!=null)
      width = Integer.parseInt(swidth);

      attachmentClone = (XWikiAttachment) attachment.clone();
      String key = attachmentClone.getId() + "" + attachmentClone.getVersion() + "" + TYPE_PNG + "" + width + "" + height;

      Calculates the "key" of the cache. The version is included, so there should be no overlap.
      I suspect the version is wrong in the attachementClone object which leads the key to be the same for each version

      Attachments

        Activity

          People

            chungnv Nguyen Viet Chung
            ludovic Ludovic Dubost
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: