Index: core/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentAccessBridge.java =================================================================== --- core/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentAccessBridge.java (revision 23543) +++ core/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentAccessBridge.java (working copy) @@ -168,16 +168,31 @@ */ public boolean exists(String documentName) { - boolean exists = false; - try { - XWikiContext xcontext = getContext(); - XWikiDocument doc = xcontext.getWiki().getDocument(documentName, xcontext); - exists = (!doc.isNew()); - } catch (XWikiException e) { - // If we failed to get the document we consider it doesn't exist. - // Note that this can happen when the storage subsystem is down for example. + XWikiContext xcontext = getContext(); + XWikiDocument doc = new XWikiDocument(); + doc.setFullName(documentName, xcontext); + String cDatabase = xcontext.getDatabase(); + //first lets try the pageExistCache, XWiki.exists yields false if error + //so might as well just implement it here. + try{ + if(doc.getDatabase() != null){ + xcontext.setDatabase(doc.getDatabase()); + } + return xcontext.getWiki().getStore().exists(doc, xcontext); + + }catch (XWikiException e) { + try { + doc = xcontext.getWiki().getDocument(doc, xcontext); + return !doc.isNew(); + + } catch (XWikiException f) { + // If we failed to get the document we consider it doesn't exist. + // Note that this can happen when the storage subsystem is down for example. + return false; + } + }finally{ + xcontext.setDatabase(cDatabase); } - return exists; } /**