Log message #4193067

# At Username Text
# Jul 14th 2019, 16:05 admad For append strategy yes but not for default replace
# Jul 14th 2019, 16:05 roberto.conterosito Yes but I've introduced a primary key, different from the "user_id" and "role_id" key pair, necessary for other scopes. Anyway I think I've found another workaround (just for now). Every BTM has it's own collection and every Item is own errors, I will merge save errors with collection's single items errors to display the global situation about a single save transaction.
# Jul 14th 2019, 16:04 ndm I don't think the association prevents that, the marshaller will probably because of duplicate IDs, but other than that it should work... also when using the append strategy it could happen.
# Jul 14th 2019, 16:01 admad You won't be able to save duplicate pairs even if you want using the belongsToMany association
# Jul 14th 2019, 16:00 admad I am pretty sure belongs to many fK pairs are unique by default.
# Jul 14th 2019, 15:59 roberto.conterosito @ndm thank you for your detailed answer! Anyway I've tried this solution but I'm still not able to catch errors (always empty getErrors() received from my entity). Now I'm going to debug the global validation process hoping to found a good solution (I'd like to use validation out from "rule builder").
# Jul 14th 2019, 15:37 slackebot entities in the saving process. Like: ``` [ 'username' => 'foo', // ... 'roles' => [ [ 'id' => 1, '_joinData' => [] ], [ 'id' => 2, '_joinData' => [] ], // ... ], ] ```
# Jul 14th 2019, 15:37 slackebot table entities (https://github.com/cakephp/cakephp/blob/3.8.1/src/ORM/Association/BelongsToMany.php#L831-L834), they will hold possible errors, but these entities are being discarded on saving failure (https://github.com/cakephp/cakephp/blob/3.8.1/src/ORM/Association/BelongsToMany.php#L851-L857). I think you can workaround this by injecting `_joinData` keys with empty arrays in your data before patching, that way the ORM doesn't have to create the
# Jul 14th 2019, 15:37 ndm @roberto.conterosito Currently that only works for non-atomic operations (I don't really know the reasoning behind that, @lorenzo may know), and for entities where the `_joinTable` property already exists and holds an entity itself, which is usually the case when you're creating/updating additional join table data. When you just associate a `belongsToMany` record (being it a new, or an existing one), then the ORM will implicitly create new join
# Jul 14th 2019, 12:58 roberto.conterosito Hi, I'm trying to see errors associated to my "belongsToMany" rule. I've "Users, UsersRoles and Roles" tables. In the "UsersRolesTable" I've added new rule, isUnique, based on "role_id" and "user_id". When I try to save new users with duplicated role_id/user_id, save fails but $user->getErrors() is empty. I'm not able to understand how to retrieve belongsToMany entity errors.
# Jul 14th 2019, 12:36 roberto.conterosito Hi, did you solve this problem? I'm looking for a solution related to this issues. I'm not able to understand how to get errors from BTM. In details, I'm trying to get errors from "isUnique" role based on foreign keys fields.
# Jul 14th 2019, 09:33 ndm @mrfeedback If you want to output custom, non-view based content, then prepare and return a response instance. If you want to use views but invoke rendering manually, set `$this->autoRender = false;`, or return the response returned by `$this->render()`. https://book.cakephp.org/3.0/en/controllers/request-response.html#response https://book.cakephp.org/3.0/en/controllers.html#rendering-a-view
# Jul 14th 2019, 07:57 mrfeedback `$this->viewBuilder()->enableAutoLayout(false);` this still execpts an action template
# Jul 14th 2019, 07:47 mrfeedback it seems like i am blind. i do not find a reference on how to avoid rendering a template in a controller action. could me somebody please share the link
# Jul 14th 2019, 07:30 mrfeedback @niel.archer thanks. yeah i did then a similar approach. then i realized that data in table was encoded twice which then lead to strange results. by saying that -> i now need to convert data within the existing tables in order to obtain usable results
# Jul 13th 2019, 23:05 niel.archer i.e. create a new entry in your DataSources for latin1 and only use that connection for the tables affected
# Jul 13th 2019, 23:04 niel.archer @mrfeedback No idea about per table, but you could use a separate connection with the encoding set to what you need for that connection.
# Jul 13th 2019, 19:34 mrfeedback is there a way to define encoding per table? in my case my application accesses data from an older app which saved content in latin 1 when i get it with the new app it retrives it as utf8 which is broken. so i need to fetch it in latin1 i guess. now i want to fetch it in latin1 and then store it in utf8 in another table. any ideas?
# Jul 13th 2019, 03:33 bgrinter Hi - I'm trying to use the csvView and I've following the instructions in the readme but I'm getting `The layout file Layout/csv/default.ctp can not be found or does not exist` Added to routes.php `Router::extensions('csv');` Application.php ` $this->addPlugin('CsvView');`
# Jul 13th 2019, 03:07 challgren CakePHP 3.8.1 released!!! https://github.com/cakephp/cakephp/releases/tag/3.8.1
# Jul 12th 2019, 21:10 noel Are those current? I checked a few months ago and those training pages were all broken on the CakePHP site.
# Jul 12th 2019, 19:16 sjorgefabi How are the Cakephp training courses carried out? Do you have downloadable videos and subtitles?
# Jul 12th 2019, 17:06 admad @daniel.upshaw validation is already decoupled from models. It's even has its separate package https://github.com/cakephp/validation
# Jul 12th 2019, 16:49 ricksaccous @daniel.upshaw you can already use validators with arrays
# Jul 12th 2019, 16:11 daniel.upshaw Otherwise it's some untapped potential
# Jul 12th 2019, 16:11 daniel.upshaw I think it would be worth a refactor to decouple the validation elements from the models, keeping it API-compatible
# Jul 12th 2019, 16:06 daniel.upshaw Eg `(new Validator(['rule' => 'latitude']))->validate($inputVar)`
# Jul 12th 2019, 16:06 daniel.upshaw I know that there are built-in PHP functions like `filter_var` and other ways, but the Validator fundamental system should ideally be able to be used outside the context of models
# Jul 12th 2019, 16:02 daniel.upshaw Whoops, I had the wrong library there lol
# Jul 12th 2019, 15:59 daniel.upshaw There is the concept of "shapes"
# Jul 12th 2019, 15:58 daniel.upshaw Perhaps like `(new Validator(['rule' => 'int']))`
# Jul 12th 2019, 15:58 daniel.upshaw That's the `Validator` class constructor
# Jul 12th 2019, 15:57 slackebot 'required' => false, 'min' => false, 'max' => false, 'pattern' => false ]; $this->constraints = empty($constraints) ? self::$defaultConstraints : $constraints + $assumedFalseValues; }```
# Jul 12th 2019, 15:57 daniel.upshaw ``` /** * @param array $constraints Associative array of constraints to enforce. * Accepts the following keys: "required", "min", * "max", and "pattern". If a key is not * provided, the constraint will assume false. */ public function __construct(array $constraints = null) { static $assumedFalseValues = [
# Jul 12th 2019, 15:56 daniel.upshaw Should be interesting
# Jul 12th 2019, 15:56 daniel.upshaw I'm trying to construct the minimum amount of code to validate a variable using CakePHP methods
# Jul 12th 2019, 15:39 ricksaccous yeah i got routes ironed out a lot easier when i just stopped using resource routing, i didn't want all the magic in my case anyway
# Jul 12th 2019, 15:22 waspinator I was trying `bake policy UsersTable`
# Jul 12th 2019, 15:21 waspinator oh yeah, thanks
# Jul 12th 2019, 15:19 ndm Baking should work... like `bake policy --type=table Users`
# Jul 12th 2019, 15:15 waspinator I had to manually create a `UsersTablePolicy.php` to get things to work