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

XWikiDocument#fromXML fail to parse history of a document saved before the xclasses it depends on

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 5.4.2, 6.0-milestone-1
    • 5.2.1
    • Old Core
    • None
    • Unknown
    • N/A
    • N/A

    Description

      I have some history that is stored right but when loaded into XWikiDocument I lose all objects content basically which makes impossible to get it back. Looks like XWikiDocument#fromXML does not like something in that content.

      Still need to find if it's a toXML or fromXML bug but since I can reproduce that in both 5.2 and 5.4.1 the best would be to support whatever is wrong in that XML in fromXML so not loose all this already saved history.

      Here is an example of XML to reproduce the issue extracted from attachment XAR:

      <?xml version="1.0" encoding="UTF-8"?>
      <xwikidoc>
      <web>Panels</web>
      <name>Applications</name>
      <language></language>
      <defaultLanguage></defaultLanguage>
      <translation>0</translation>
      <parent>Panels.WebHome</parent>
      <creator>xwiki:XWiki.Admin</creator>
      <author>xwiki:XWiki.Admin</author>
      <customClass></customClass>
      <contentAuthor>xwiki:XWiki.Admin</contentAuthor>
      <creationDate>1387301425000</creationDate>
      <date>1385999012000</date>
      <contentUpdateDate>1385999012000</contentUpdateDate>
      <version>1.1</version>
      <title></title>
      <defaultTemplate></defaultTemplate>
      <validationScript></validationScript>
      <comment>Copied from workspacetemplate:Panels.Applications</comment>
      <minorEdit>false</minorEdit>
      <syntaxId>xwiki/2.1</syntaxId>
      <hidden>true</hidden>
      <object>
      <name>Panels.Applications</name>
      <number>0</number>
      <className>Panels.PanelClass</className>
      <guid>a625d8f2-78e4-4903-ba43-20245c683436</guid>
      <property>
      <category>Information</category>
      </property>
      <property>
      <content>{{velocity}}
      #set($discard = $xwiki.ssx.use('Panels.Applications'))
      #set($discard = $xwiki.jsx.use('Panels.Applications'))
      #panelheader($services.localization.render('panels.applications.title'))
      #foreach($uix in $services.uix.getExtensions('org.xwiki.platform.panels.Applications', {'sortByParameter' : 'label'}))
        #set($params = $uix.getParameters())
        #if($"$!params.icon" != '' &amp;&amp; "$!params.label" != '' &amp;&amp; "$!params.target" != '' &amp;&amp; $xwiki.hasAccessLevel('view', $xcontext.user, $params.target))
      (% class="applicationsPanel" %)
      * [[image:$params.icon $params.label&gt;&gt;$params.target]]
        #end
      #end
      #if($xwiki.hasWikiAdminRights())
      ## We need the 3 newlines below to have a separation between the lists
      
      
      
      (% class="applicationsPanel" %)
      * [[image:icon:add $services.localization.render('panels.applications.more')&gt;&gt;XWiki.XWikiPreferences||class="applicationPanelMoreButton" queryString="editor=globaladmin&amp;section=XWiki.AddExtensions"]]
      
      (% class="applicationPanelMoreContainer hidden" %)(((
      (% class="applicationsPanel" %)
      #foreach($uix in $services.uix.getExtensions('org.xwiki.platform.panels.Applications.more', {'sortByParameter' : 'label'}))
        #set($params = $uix.getParameters())
        #if($"$!params.icon" != '' &amp;&amp; "$!params.label" != '' &amp;&amp; "$!params.target" != '')
      (% class="applicationsPanel" %)
      * [[image:$params.icon $params.label&gt;&gt;$params.target]]
        #end
      #end
      )))
      #end
      #panelfooter()
      {{/velocity}}</content>
      </property>
      <property>
      <description>Lists the available applications and provides shortcuts to install new ones or to create your own.</description>
      </property>
      <property>
      <name>Applications</name>
      </property>
      <property>
      <type>view</type>
      </property>
      </object>
      <object>
      <name>Panels.Applications</name>
      <number>0</number>
      <className>XWiki.JavaScriptExtension</className>
      <guid>cad363e5-351e-4456-9559-84ce5c8e5543</guid>
      <property>
      <cache>long</cache>
      </property>
      <property>
      <code>var XWiki = (function(XWiki) {
      
      var panels = XWiki.panels = XWiki.panels || {};
      
      panels.MoreApplicationsButtonListener = Class.create({
        initialize: function(button) {
          this.button = button;
          this.container = button.up('div').down('.applicationPanelMoreContainer');
          this.container.id = 'applicationPanelMoreContainer' + Math.floor(Math.random()*101);
          this.isToggling = false;
      
          this.button.observe('click', function(e) {
            e.stop();
            if (!this.isToggling) {
              this.toggle();
            }
          }.bindAsEventListener(this));
      
          return this;
        },
      
        toggle: function() {
          this.isToggling = true;
          if (this.container.hasClassName('hidden')) {
            this.container.style.display = "none";
            this.container.removeClassName('hidden');
            Effect.BlindDown(this.container.id, {
              duration: 0.1,
              afterFinish: function() {
                this.isToggling = false;
              }.bind(this)
            });
          } else {
            Effect.BlindUp(this.container.id, {
              duration: 0.1,
              // We do this to be able to get our hidden element back, we don't rely on
              // display:none since we don't allow nested style in HTML elements.
              afterFinish: function() {
                this.container.addClassName('hidden');
                this.isToggling = false;
              }.bind(this)
            });
          }
        }
      });
      
      return XWiki;
      }(XWiki || {}));
      
      document.observe('xwiki:dom:loaded', function(e) {
        $$('.applicationPanelMoreButton').each(function(button) {
          new XWiki.panels.MoreApplicationsButtonListener(button);
        });
      });</code>
      </property>
      <property>
      <name>Applications Panel</name>
      </property>
      <property>
      <parse>0</parse>
      </property>
      <property>
      <use>onDemand</use>
      </property>
      </object>
      <object>
      <name>Panels.Applications</name>
      <number>0</number>
      <className>XWiki.StyleSheetExtension</className>
      <guid>b63b9731-79d8-4ac4-aace-b4df1275e717</guid>
      <property>
      <cache>long</cache>
      </property>
      <property>
      <code>ul.applicationsPanel li img {
        float:left;
      }
      
      div.applicationPanelMoreContainer li a {
        font-size: 90%;
        line-height: 16px;
        font-weight: bold;
      }
      
      
      
      </code></property><property><name>Applications Panel</name>
      </property>
      <property>
      <parse>0</parse>
      </property>
      <property>
      <use>onDemand</use>
      </property>
      </object>
      <content>{{include document="Panels.PanelSheet"/}}</content></xwikidoc>
      

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              tmortagne Thomas Mortagne
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: