SID-00507: Strange Calc Behavior
| Status: |
Answered |
TWiki version: |
4.3.1 |
Perl version: |
|
| Category: |
CategoryPlugins |
Server OS: |
|
Last update: |
16 years ago |
I am trying to port a calc function that I wrote for TWIKI 4.1 over to 4.3 and it no longer works correctly.
Basically, I have an automated time sheet system that generates a link to a Twiki page every week.
The system works fine if you are in the Main web but if the user goes to another web it says it can't find a page that exists.
I traced it down to the retrieval of the week variable.
First I set a calc variable for the week number:
CALC{" $SET( week, $INT($IF($REPLACE(0%SERVERTIME{$day}%0000,-5,5)==0, $REPLACE(00%SERVERTIME{$day}%,1,3), %SERVERTIME{$day}%)/8) )"}%%CALC{"$SET(week, $IF( $GET(week) == 4 ,3 , $GET(week) ))"}%%CALC{" $SET( week, $INT($GET(week)+1) )"}%
Then I try to check and see if the page exists, if it does then I simply return a link to it and hide some other content using a div tag, if it doesn't then I return a div object that shows some content so I can do something else:
%CALC{$IF($EXISTS(%USERNAME%%SERVERTIME{"$mon$ye"}%W$GET(week)),%ICON{"index"}% %USERNAME%%SERVERTIME{$mon$ye}%W$GET(week)<div style="display:none;">, <div>)}%
This works just fine if I am in the main web, but if I navigate to another Web it says it can no longer find the page. I found out the reason was beceause of the calc variable "week". If I remove that and instead manually specify the number it should return it can always find the page regardless of what web I am in.
Does anyone have a clue as to what's happening here?
Update: So it turns out that if I have an explicit reference to the topic in question anywhere in the topic I am editing this problem goes away.
For example, if the code I showed above results in MyNameAug09W4 twiki will calim that the topic doesn't exist (even though it does). If I simply write Main.MyNameAug09W4 right below the code then all instances of MyNameAug09W4 apear as valid links (in other words Twiki acknoledges thier existance.
I never had this problem in 4.1. Is this a bug, or am I doing somthing wrong?
--
GregGardinier - 2009-08-26
Discussion and Answer
Likely related to
TWikibug:Item3889
. Fix: Use a full
Web.PageName specifier, e.g.
$EXISTS(%WEB%.%USERNAME%%SERVERTIME{"$mon$ye"}%W$GET(week))
--
PeterThoeny - 2009-08-27
Seems to be answered.
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2009-10-02
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.