Return-Path: Delivered-To: apmail-incubator-jspwiki-dev-archive@locus.apache.org Received: (qmail 3245 invoked from network); 28 Jan 2008 09:07:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jan 2008 09:07:55 -0000 Received: (qmail 49420 invoked by uid 500); 28 Jan 2008 09:07:46 -0000 Delivered-To: apmail-incubator-jspwiki-dev-archive@incubator.apache.org Received: (qmail 49410 invoked by uid 500); 28 Jan 2008 09:07:46 -0000 Mailing-List: contact jspwiki-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jspwiki-dev@incubator.apache.org Delivered-To: mailing list jspwiki-dev@incubator.apache.org Received: (qmail 49397 invoked by uid 99); 28 Jan 2008 09:07:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jan 2008 01:07:46 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jan 2008 09:07:27 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 149A7714208 for ; Mon, 28 Jan 2008 01:07:34 -0800 (PST) Message-ID: <29855757.1201511254057.JavaMail.jira@brutus> Date: Mon, 28 Jan 2008 01:07:34 -0800 (PST) From: "Janne Jalkanen (JIRA)" To: jspwiki-dev@incubator.apache.org Subject: [jira] Commented: (JSPWIKI-167) Confusing PageRenamerTest interaction with WikiContext In-Reply-To: <7358350.1201499134108.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JSPWIKI-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563087#action_12563087 ] Janne Jalkanen commented on JSPWIKI-167: ---------------------------------------- By the way... WikiContext.getPage() is guaranteed to always return a valid WikiPage. We have lots of code which assumes this, so not doing that is probably going to be pretty deadly all over the code. > Confusing PageRenamerTest interaction with WikiContext > ------------------------------------------------------ > > Key: JSPWIKI-167 > URL: https://issues.apache.org/jira/browse/JSPWIKI-167 > Project: JSPWiki > Issue Type: Bug > Components: Core & storage > Affects Versions: 2.6.1 > Environment: All > Reporter: Andrew Jaquith > Assignee: Janne Jalkanen > Priority: Minor > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > In testing some 3.0-related brach code, I noticed something very odd in the way PageRenamerTest, PageRenamer, and WikiContext interact. > The symptoms: PageRenamer.testReferrerNoWikiName() kept failing. > The test lines that are strange are these (lines 171-186): > {code} > m_engine.saveText("Test","foo"); > m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]"); > WikiPage p = m_engine.getPage("TestPage"); > WikiContext context = new WikiContext(m_engine, p); > m_engine.renamePage(context, "Test", "TestPage", true); > {code} > This seems straightforward enough -- when we save a page that has references in it, all of the pages that refer to it should update their references. > But there are some weird things going on. I can't figure out why 'p' is getting assigned page 'TestPage,'... it's a page that doesn't exist. Interestingly, when using a debugger to see what 'context' contains, its page property is set to page "Main". That's because 'TestPage' doesn't exist, and the default is to substitute the "Main" page. This is important! Hold on for why... > Now then, moving over to PageRenamer, we have a private method updateReferrerOnRename with the following signature: > {code} > private void updateReferrerOnRename(WikiContext context, String oldName, String newName, boolean changeReferrer, String referrerName) > {code} > The "context" parameter is the same context supplied to renamePage() above. Thus, the context that's passed, in this particular test case, will have the page "Main" associated with it. > Further down in updateReferrerOnRename() is this snippet: > {code} > if (context.getPage() != null) > { > (lots of magic happens where the references are updated and the page is re-saved...) > } > {code} > Now then, here's the thing that's bothering me. The 'context' variable doesn't have anything to do with either the page that's being renamed or to the pages that refer to the renamed page. Moreover, if the context's getPage() happens to return null, then renaming the page won't update references to it, even though the page will actually be renamed! This is bizarre. > This particular case is strange because of the line: > {code} > WikiPage p = m_engine.getPage("TestPage") > {code} > If we'd specified the original page ("Test"), then everything would've magically worked ok. And in the current JSPWiki scheme of things, even specifying a non-existent page ("TestPage") works ok, because the WikiContext will magically default to page "Main". But this, it seems to me, is more accidental than deliberate. > What if WikiContexts aren't guaranteed to return a WikiPage from getPage()? It is one of those hypothetical (3.0 branch) cases that caused my test case to fail. > Am I missing something here? I must be... -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.