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

佐手、 提交于 2019-12-24 20:26:50

问题


My client is finding that when they hit delete nothing happens, but if they it it again 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?


回答1:


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



来源:https://stackoverflow.com/questions/6771088/controller-in-kohana-3-does-not-appear-to-work-but-has-in-the-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!