In order to reproduce, we can use the example of the rights class & object.
Steps to reproduce:
- create a simple panel, containing the following code (listing all users of all rights objects of the current page):
- set this panel on a page or space
- add a rights object on the page, by setting rights to some user on the page only (using administration for a non-terminal page or the Edit->rights for a terminal page)
- render the page in view mode
- the list of users of the right object is rendered graphically in the panel
Debugging shows that the variable isInRenderingEngine from line https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-12.10.5/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java#L3437 is false for panels and true for documents content, thus the difference in behaviour. Not sure if it's intended or not (and the rules for writing panels are different than what I did), but feels like a bug to me.