Good time of day, there was a strange problem. In order: there is an admin panel, there is a user part, both have approximately the same save code, after changing data from the form, but in the admin part, after saving absolutely nothing comes, the white page and the code stops, no validation errors, no debugging, anywhere . The next part of the code, after model-> save, is not executed at all. The problem appeared after moving to version 3.6 Code:

public function edit($alias = null) { if (!$alias) { throw new NotFoundException(__('Неверная ссылка')); } $link = $this->Links->findByAlias($alias)->first(); if (!$link) { throw new NotFoundException(__('Неверная ссылка')); } $bundles = $this->Links->Bundles ->find('list', [ 'keyField' => 'id', 'valueField' => 'title' ]) ->where(['user_id' => $link->user_id]); $this->set('bundles', $bundles); if ($this->request->is(['post', 'put'])) { $link = $this->Links->patchEntity($link, $this->request->getData()); if ($this->Links->save($link)) { $this->Flash->success(__('The Link has been updated.')); return $this->redirect(['action' => 'edit', $alias]); } else { //debug( $link->errors() ); $this->Flash->error(__('Oops! There are mistakes in the form. Please make the correction.')); } } $this->set('link', $link); } 

Here is what is written in error.log

 Warning: The connection is going to be closed but there is an active transaction. 

This problem occurs with most models in the admin panel.

  • one
    that is, in fact, it simply drops to save , and does not write anything to the log, with debug enabled in the config? Admin and the rest work through one connection? - teran
  • @teran, yes, that's right, only deletion and user model work (save, delete, etc.), and custom models do not work - kosh
  • And from which version did they migrate? Compare what returns getData in the admin and where it works. Plus, in the admin area, it is possible that some events are hung on save / delete, etc. MB there that falls? - teran
  • @teran, in my opinion from version 3.3, checked everything through debugger getdata, compared the answer after patchEntity, and if there are events somewhere that are hung, I don’t know which way to dig, can I contact you somehow? - kosh

1 answer 1

Problem solved. There was a hidden beforeSave method that killed the entire save process.