Cake doesn't call the actions twice, normally.

I don't know if this is any help but I had a similar problem a while
ago. It was down to a "normal" image tag on the view template:

<img src="img/whatver.png" />

Called from /posts/edit/123, this resulted in a query for /posts/edit/
123/img/whatver.png which called the action again. Had to scan the
access logs for this one, it was driving me crazy.

A similar problem on another site (a css file this time, but the same
concept) messed up all of the sessions.

My solution (apart from fixing the offending tags) was to add this to /
app/webroot/.htaccess

# Do not route missing asset requests through cake
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !img/uploads/
RewriteRule ^/?((img|js|css|swf)/.*)$ - [R=404,L]

The 'uploads' one is the exception as it was dynamically generated, so
I needed normal cake handling. Everything else gets a 404 directly if
it doesn't exist.

On some Apache servers the [R=404] thing fails, so I created an
error.php in webroot containing `<?php header("HTTP/1.0 404 Not
Found"); ?>` and changed the line to

RewriteRule ^/?((img|js|css|swf)/.*)$ error.php [L]

hth
grigri



On Dec 18, 1:30 pm, WebbedIT <[email protected]> wrote:
> Could really do with some help with this.
>
> I added some log calls to my edit action and clicked to edit two
> different records, checked the log and found the following ...
>
> 2008-12-18 13:25:57 Debug: Edit form displayed for record # 6815
> 2008-12-18 13:25:58 Debug: Edit form displayed for record # 6815
> 2008-12-18 13:27:42 Debug: Edit form displayed for record # 877
> 2008-12-18 13:27:43 Debug: Edit form displayed for record # 877
>
> Why is CakePHP calling the actions twice?  Surely this is not normal
> behaviour?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to