You are here: Foswiki>Tasks Web>Item2440 (02 Dec 2009, AndrewJones)Edit Attach

Item2440: Rest handler called twice

Priority: Normal
Current State: No Action Required
Released In:
Target Release: n/a
Applies To: Engine
Reported By: SaschaVetter
Waiting For:
Last Change By: AndrewJones
Hi all,

in the last few weeks I have been migrated a lot of internal plugins from the old "bin-structure" to "rest handler-using" plugins. It's our final step to for the migration from TWiki to Foswiki.

The migration of the first few plugins ran without any problem but now I've got a massive problem and I can't find any solution. The problem is that the function is called every time twice, if I use the browser. If I call the rest function by console it runs only once.

I simplified the plugin code to a minimum and uploaded it to pastbin. The plugin functionality is very simple, it just open a topic, adds an "a" and save the topic again. If I call this plugin by console it runs correctly, but when I call it by browser it will called twice. The debug log says:

| 2009-12-02T09:41:14Z debug | HowToRestTestPlugin: read topic |
| 2009-12-02T09:41:14Z debug | HowToRestTestPlugin: save topic |
| 2009-12-02T09:41:14Z debug | HowToRestTestPlugin: read topic |
| 2009-12-02T09:41:14Z debug | HowToRestTestPlugin: save topic |

I did the following steps without any success:
  • Rename the plugin
  • De- and active the plugin
  • Rename the rest function alias
  • Rename the function name
  • Add a debug message to the initPlugin function and it also get called twice, the debug output was:
| 2009-12-02T09:01:27Z debug | HowToRestTestPlugin: init |
| 2009-12-02T09:01:27Z debug | HowToRestTestPlugin: read topic |
| 2009-12-02T09:01:27Z debug | HowToRestTestPlugin: save topic |
| 2009-12-02T09:01:28Z debug | HowToRestTestPlugin: init |
| 2009-12-02T09:01:28Z debug | HowToRestTestPlugin: read topic |
| 2009-12-02T09:01:28Z debug | HowToRestTestPlugin: save topic |

I've got really no idea who to fix this problem and I'm not sure if it's a foswiki bug or a mistake in my code.

Additional information:
  • FastCGI or mod_perl are installed but not used.
  • Default installation (no core changes)

Following a conversation on IRC I tried to reproduce the problem by using Sascha's test plugin and couldn't. This was on 1.0.8 (SVN install).

-- AndrewJones - 02 Dec 2009

Following to the conversation I installed 1.0.8 on the same server (but a different folder), copied the old users to the latest installation and installed only this one plugin and I got the bug again. The plugin is still called twice and every time the plugin adds two "a" instead the one it should.

Any ideas what could be wrong on with my server configuration? Any parameters I could check?

@ AndrewJones : Thanks for your help!

-- SaschaVetter - 02 Dec 2009

Damn it, I've got the reason for this strange behavior! Firebug and YSlow caused this problem because they are reloading the topic for their analysis and that's why every plugin is running twice.

-- SaschaVetter - 02 Dec 2009

Lol, thats quite a funny problem, although I bet it wasn't funny at the time! Glad you got it sorted smile

-- AndrewJones - 02 Dec 2009

ItemTemplate edit

Summary Rest handler called twice
ReportedBy SaschaVetter
Codebase 1.0.8, 1.0.7
SVN Range
AppliesTo Engine
Priority Normal
CurrentState No Action Required
TargetRelease n/a
Topic revision: r7 - 02 Dec 2009, AndrewJones
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy