# Deprecate api.XWiki#getSpacePreferenceFor() methods using space as String

**URL:** <https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912>\
**Category:** Development\
**Tags:** vote\
**Created:** [August 29, 2022, 8:32am UTC](https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912 "2022-08-29T08:32:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![acotiuga](https://forum.xwiki.org/user_avatar/forum.xwiki.org/acotiuga/32/3815_2.png) [@acotiuga](https://forum.xwiki.org/u/acotiuga)\
**Post date:** [August 29, 2022, 8:32am UTC](https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912/1 "2022-08-29T08:32:50Z")

</div>

I propose that we deprecate and move to the legacy modules the `api.XWiki#getSpacePreferenceFor(String, String)` ([xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/XWiki.java at master · xwiki/xwiki-platform · GitHub](https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/XWiki.java#L1163)) and `api.XWiki#getSpacePreferenceFor(String, String, String)` ([xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/XWiki.java at master · xwiki/xwiki-platform · GitHub](https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/XWiki.java#L1178)).

The main reason is that these methods are using spaces as String and, in the context of the Nested Spaces structure (since XWiki 7.2), the spaces are not properly resolved, meaning that a String **A.B** will be considered a single space named **A.B** instead of a space hierarchy with space **A** as a parent of space **B**.  
Moreover, these methods are calling the method `xwiki.XWiki#getSpacePreference(String, String, String, XWikiContext)` ([xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java at master · xwiki/xwiki-platform · GitHub](https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java#L2947)), which is also deprecated since 7.4M1.  
Finally, in the xwiki-platform project, there are only 2 occurrences of these methods:

- in 2 deprecated methods of **XWikiCompatibilityAspect.aj** [xwiki-platform/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-oldcore/src/main/aspect/com/xpn/xwiki/api/XWikiCompatibilityAspect.aj at df8bd49b5a4d87a427002c6535fb5b1746ff117a · xwiki/xwiki-platform · GitHub](https://github.com/xwiki/xwiki-platform/blob/df8bd49b5a4d87a427002c6535fb5b1746ff117a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-oldcore/src/main/aspect/com/xpn/xwiki/api/XWikiCompatibilityAspect.aj#L540)
- in `layoutvars.vm` where the panels variables are set.

This vote is open for one week: it will be closed on Friday, September 2nd.

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [August 29, 2022, 8:38am UTC](https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912/2 "2022-08-29T08:38:20Z")

</div>

+1

---

<div class="post-metadata">

**Author:** ![mleduc](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mleduc/32/2328_2.png) [@mleduc](https://forum.xwiki.org/u/mleduc)\
**Post date:** [August 29, 2022, 8:38am UTC](https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912/3 "2022-08-29T08:38:32Z")

</div>

+1, Thanks

---

<div class="post-metadata">

**Author:** ![mflorea](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mflorea/32/49_2.png) [@mflorea](https://forum.xwiki.org/u/mflorea)\
**Post date:** [August 29, 2022, 1:43pm UTC](https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912/4 "2022-08-29T13:43:32Z")

</div>

+1

Thanks,  
Marius

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [August 30, 2022, 9:53am UTC](https://forum.xwiki.org/t/deprecate-api-xwiki-getspacepreferencefor-methods-using-space-as-string/10912/5 "2022-08-30T09:53:21Z")

</div>

+1
