Skip to content

5.x: Entity save error message hidden if domain rules #18241

Open
@dereuromark

Description

@dereuromark

Description

When doing a save operation with associations, the error message on the assocs can be hidden completely.

            $data['orders'] = ['_ids' => $orderIds];
            $data['deposits'] = ['_ids' => $depositIds];
            $invoice = $this->Invoices->patchEntity($invoice, $data);
            if ($this->Invoices->save($invoice, ['associated' => ['Orders', 'Deposits']])) {

Just returns false, nothing else. Even a saveOrFail() here would only return

Cake\ORM\Exception\PersistenceFailedException: Entity save failure.

After a lot of debugging, setting 'atomic' => false into it revealed the message suddenly:

Cake\ORM\Exception\PersistenceFailedException: Entity save failure. Found the following errors (orders.0._joinData.order_id._isUnique: "This value is already in use").
/vendor/cakephp/cakephp/src/ORM/Table.php:1985

I wonder if there isnt a better way of combining assoc issues into the primary error, so the actual issue is visible for local dev and debugging, but also when logging e.g. on prod.

Right now, with default atomic true those would always be invisible it seems.

CakePHP Version

5.0

PHP Version

8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy