fix: [taxonomies] enabling breaks on POST request if named parameters aren't used

pull/7733/head
iglocska 2021-09-07 14:16:45 +02:00
parent dbc8882b7f
commit f7e4f0a69b
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 12 additions and 11 deletions

View File

@ -341,19 +341,20 @@ class TaxonomiesController extends AppController
if ((!$this->_isSiteAdmin() && !$this->userRole['perm_tagger'])) {
throw new NotFoundException(__('You don\'t have permission to do that.'));
}
if (
$this->request->is('get') &&
(
empty($this->request->params['named']['taxonomy_id']) ||
if ($this->request->is('get')) {
if (empty($taxonomy_id) && !empty($this->request->params['named']['taxonomy_id'])) {
$taxonomy_id = $this->request->params['named']['taxonomy_id'];
}
if (
empty($taxonomy_id) ||
empty($this->request->params['named']['name'])
)
) {
throw new MethodNotAllowedException(__('Taxonomy ID or tag name must be provided.'));
) {
throw new MethodNotAllowedException(__('Taxonomy ID or tag name must be provided.'));
} else {
$this->request->data['Taxonomy']['taxonomy_id'] = $taxonomy_id;
$this->request->data['Taxonomy']['name'] = $this->request->params['named']['name'];
}
} else {
$this->request->data['Taxonomy']['taxonomy_id'] = $this->request->params['named']['taxonomy_id'];
$this->request->data['Taxonomy']['name'] = $this->request->params['named']['name'];
}
if ($this->request->is('post')) {
if ($taxonomy_id) {
$result = $this->Taxonomy->addTags($taxonomy_id);
} else {