开发者

Controller in Kohana 3 does not appear to work, but has in the background

My client is finding that when they hit delete nothing happens, but if they it it agai开发者_Python百科n they get the error that that 'id' doesn't exist anymore.

I find that hard to believe because it's actually leaving the page and then being redirected back to the post.

The link in the view:

<h4>Current Logo Image <span class='del'>
 (<?= HTML::anchor("playlist/imgdelete/$playlist->id/$logo->type", 'delete'); ?>)
</span></h4>

The controller process:

public function action_imgdelete($id, $type)
{
    DB::delete('images')->where('playlist_id', '=', $id)
                        ->where('type', '=', $type)->execute();
    Message::success('Image deleted');
    Request::current()->redirect("playlist/edit/$id");
}

Does anyone know how this can be possible?


This could be due to a double chokehold cache between Kohana and your browser of choice.

The delete action will have occurred, but because of the aggressiveness, the cache of the page will not show any change. Hitting again will be invalid since you've already performed the action, but nothing has visually registered on your end.

You can get around this by putting in the no-cache header tag in your template:

<meta http-equiv="cache-control" content="no-cache" />

The default cache life set by Kohana is a minute:

/**
 * @var  integer  Default lifetime for caching, in seconds, 
 *                 used by [Kohana::cache]. Set by [Kohana::init]
 */
public static $cache_life = 60;

You can tweak it from system/classes/kohana/core.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜