私はCakePHP内でCupcake Forumプラグインを使用しています。希望の投稿を選択し、投稿を削除するためのフォームを送信するためのフォームがあります。フォームデータは、明らかに、POSTとGETメソッドを同時に使用して、「トピック」コントローラ内の「中程度の」関数に送信されています。関数はまず、送信されたデータがPOSTかどうかを確認します。しかし、データが受信されると、それはGETであることが示されます。仲間のプログラマーであり、私は他人の内部コードを完全に変更したくないのですが、両方の方法でデータがどのように送信され、GETとして受信されているか把握できません。プラグインのコードは次のとおりです。フォーラム内の投稿は削除できません。 (CakePHP)
-------------- moderate.ctp(表示)------------------ ---
<?php echo $form->create('Post', array('url' => array('controller' => 'topics', 'action' => 'moderate', $topic['Topic']['slug']))); ?>
------------- topics_controller.php(コントローラ)-------
public function moderate($id) {
if ($this->RequestHandler->isGet()){
$this->log('Is GET!');
}
$user_id = $this->Auth->user('id');
$topic = $this->Topic->getTopicForViewing($id, $user_id, 'id');
// Access
$this->Toolbar->verifyAccess(array(
'exists' => $topic,
'permission' => $topic['ForumCategory']['accessRead'],
'moderate' => $topic['Topic']['forum_category_id']
));
$this->log('ID: '.$id.'\n');
if ($this->RequestHandler->isPost()){
$this->log('Is POST!');
}
if ($this->RequestHandler->isGet()){
$this->log('Is GET!');
}
$this->log($this->RequestHandler->getReferer());
$this->log(serialize($this->data));
// Processing
if ($this->RequestHandler->isPost()) {
$this->log('INSIDE POST!');
if (!empty($this->data['Post']['items'])) {
$items = $this->data['Post']['items'];
$action = $this->data['Post']['action'];
foreach ($items as $post_id) {
$this->log('Action: '.$action.'\n');
$this->log('PostID: '.$post_id.'\n');
if (is_numeric($post_id)) {
if ($action == 'delete') {
$this->Topic->Post->destroy($post_id);
$this->Session->setFlash(sprintf(__d('forum', 'A total of %d post(s) have been permanently deleted', true), count($items)));
}
}
}
}
}
我々ログのチェックが追加されました。これは 'Is GET!'の結果を示します。 Cakeのログファイルに保存されます。このメソッドはGETなので、 'if($ this-> RequestHandler-> isPost())'という文は決して真ではありません。したがって、提出された投稿は削除されません。何が足りないの?