[ 
http://jira.xwiki.org/jira/browse/XWIKI-2051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_22613
 ] 

Thomas Mortagne commented on XWIKI-2051:
----------------------------------------

The description does not contains a good example. The real test would be to use 
a class which is not on the current wiki (I wrote it for everyone to be able to 
test the problem easily but I had the problem in another case).

In fact even if Object.get don't use the correct XWikiDocument it does not 
change anything as the XWikiDocument methods does not take into account the 
document. So the minimum fix would be to modify BaseObject initialisation to 
contains class prefixed full name (wiki:Space.ClassDoc) in place of just full 
name.

But anyway the fact that BaseObject does not contains wiki information or at 
least document prefixed full name will surely create problems latter I think.

> Can't get properties values from a document's object from another wiki
> ----------------------------------------------------------------------
>
>                 Key: XWIKI-2051
>                 URL: http://jira.xwiki.org/jira/browse/XWIKI-2051
>             Project: XWiki Core
>          Issue Type: Bug
>          Components: APIs
>    Affects Versions: 1.2.1, 1.3 M1
>            Reporter: Thomas Mortagne
>             Fix For: 1.3 M2
>
>
> To reproduce, create a user "toto" on main wiki and execute the following 
> code in a any wiki except main wiki
> {code}
> #set ($document = $xwiki.getDocument("xwiki:XWiki.toto"))
> #set ($object = $document.getObject("XWiki.XWikiUsers"))
> $object.first_name
> {code}
> This will print nothing.
> The problem is that Object.get(String) reload the XWikiDocument before trying 
> to get object field value. To reload the document it uses 
> getCollection().getName(); that contains "XWiki.toto"
>  and not "xwiki:XWiki.toto" so the wrong document is loaded and when it try 
> to get field value, an empty String is returned because field or object does 
> not exist.
> {code}
>     public java.lang.Object get(String name)
>     {
>         String docname = getCollection().getName();
>         try {
>             XWikiDocument doc = 
> getXWikiContext().getWiki().getDocument(docname, getXWikiContext());
>             return doc.display(name, this.getBaseObject(), getXWikiContext());
>         } catch (XWikiException e) {
>             return null;
>         }
>     }
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.xwiki.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to