XWIKI-10177: Possible nullpoiter exception when acessing subwiki before main wiki

(cherry picked from commit ec20b11d68c99e4eee308b3c8b1c33f38bdbb4e6)