• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5501: IF allows does not work correctly if the topic does not exist.

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Urgent Closed   patch 4.2.1, 5.0.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

The docco in IfStatements very reasonably says
allows 'X' allows 'Y' is true if web/topic 'X' exists and allows access mode 'Y' for the current user. Web access rights are only checked if there is no topic called 'X'.

unfortuanatly, the change in [[ Item5500]] to the topic creator does not work.

It feels like a case of For want of a Unit test, the feature was lost as i added:

 Fn_IF::test_ALLOWS_and_EXISTS

%IF{"'TemporaryIFTestWebIF.NonExitantLazyFox' allows 'change'" then="1" else="0"}%: '0' at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/Unit/TestCase.pm line 151
    Unit::TestCase::assert_str_equals('Fn_IF=HASH(0xea31f0)', 1, 0, '%IF{"\'TemporaryIFTestWebIF.NonExitantLazyFox\' allows \'chan...') called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/test/unit/Fn_IF.pm line 714
    Fn_IF::test_ALLOWS_and_EXISTS('Fn_IF=HASH(0xea31f0)') called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/Unit/TestRunner.pm line 49
    Unit::TestRunner::__ANON__() called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/CPAN/lib/Error.pm line 379
    eval {...} called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/CPAN/lib/Error.pm line 371
    Error::subs::try('CODE(0x175e360)', 'HASH(0x1b40cb0)') called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/Unit/TestRunner.pm line 55
    Unit::TestRunner::start('Unit::TestRunner=HASH(0x604fd0)', 'Fn_IF.pm') called

and so, I'll be fuxing that for 4.2.1

-- TWiki:Main/SvenDowideit - 04 Apr 2008

This is complicated by the non-specification of what %IF{'NonExistant' ... is evaluating. Is it a web, or is it a topic? especially if neither exist.

my fix changes that from for some reason assuming it is a web, to assuming its a non-existant topic in the current session's web, thus enabling testing as I do above, where I specify the web and topic.

this will require the following test to change.

    push(@tests, {
        test => "'NotAHopeInHellPal' allows 'view'",
        expect => "0"
       });

the fix is:

Index: lib/TWiki/If/Node.pm
===================================================================
--- lib/TWiki/If/Node.pm   (revision 158)
+++ lib/TWiki/If/Node.pm   (working copy)
@@ -62,13 +62,16 @@
         $session->{webName}, $str);
     my $ok = 0;
     if ($session->{store}->topicExists($web, $topic)) {
+        #try the non-precise name as an existant topic first.
         $ok = $session->security->checkAccessPermission(
             uc($mode), $session->{user}, undef, undef, $topic, $web);
     } elsif ($session->{store}->webExists($str)) {
         $ok = $session->security->checkAccessPermission(
             uc($mode), $session->{user}, undef, undef, undef, $str);
+     } elsif ($session->{store}->webExists($web)) {
+        #not an existing topic or web - assume any lone name is a topic without a web specified
+        $ok = $session->security->checkAccessPermission(
+            uc($mode), $session->{user}, undef, undef, $topic, $web);
     } else {
        $ok = 0;
     }
     return $ok ? 1 : 0;
 }
Index: twikiplugins/UnitTestContrib/test/unit/Fn_IF.pm
===================================================================
--- twikiplugins/UnitTestContrib/test/unit/Fn_IF.pm   (revision 16607)
+++ twikiplugins/UnitTestContrib/test/unit/Fn_IF.pm   (working copy)
@@ -672,6 +672,18 @@
             expect => "1"
         });
     push(@tests, {
+            test => '\''.$this->{test_web}.'.NonExitantLazyFox\' allows \'change\'',
+            expect => "1"
+        });
+    push(@tests, {
+            test => '\'NonExistantWeb.WebHome\' allows \'change\'',
+            expect => "0"
+        });
+    push(@tests, {
+            test => '\'NonExistantWeb.NonExitantLazyFox\' allows \'change\'',
+            expect => "0"
+        });
+    push(@tests, {
         test => "istopic 'LazyFox'",
         expect => "0"
        });

What do you think Crawford?

-- TWiki:Main.SvenDowideit - 04 Apr 2008

I agree it should be interpreted as a topic. That's the TWiki naming standard, and%IF should be consistent. Your fix is correct, IMHO.

-- TWiki:Main.CrawfordCurrie - 05 Apr 2008

ItemTemplate
Summary IF allows does not work correctly if the topic does not exist.
ReportedBy TWiki:Main.SvenDowideit
Codebase 4.2.0, ~twiki4
SVN Range TWiki-5.0.0, Thu, 03 Apr 2008, build 16612
AppliesTo Engine
Component

Priority Urgent
CurrentState Closed
WaitingFor

Checkins TWikirev:16641, TWikirev:16642
TargetRelease patch
ReleasedIn 4.2.1, 5.0.0
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2008-08-04 - KennethLavrsen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback