Log message #4193090

# At Username Text
# Jul 15th 2019, 08:17 neon1024 Most of the ones I’ve read about implement a generic keyword like ‘data’, ‘results’ or similar
# Jul 15th 2019, 08:16 neon1024 Usually to differentiate data from meta, pagination and other data which might be in the response
# Jul 15th 2019, 08:16 neon1024 Most standards implement a top level dimension
# Jul 15th 2019, 08:16 neon1024 I think it’s the opposite actually
# Jul 15th 2019, 08:15 conehead Okay thank you. Gonna try that. Was hoping this was an option I could pass to `_serialize`. I think this is quite common for REST apis
# Jul 15th 2019, 08:13 neon1024 You could drop serialize and use a json template to customise the output if you wanted
# Jul 15th 2019, 08:13 conehead Anyone using lots of json response? Can I get rid of the top level object with a single line? ` '_serialize' => ['users'],` always creates the `users` property. But as I only got this one property, I want to get rid of it
# Jul 15th 2019, 08:11 conehead ;)
# Jul 15th 2019, 08:07 neon1024 Or Fridays Dave didn’t at any rate :slightly_smiling_face:
# Jul 15th 2019, 08:07 neon1024 Looks like I have no idea how to use `in_array()` :flushed:
# Jul 15th 2019, 07:47 neon1024 Oh yes of course ndm mentioned execution order, I should check that
# Jul 15th 2019, 07:47 neon1024 I tried using `$this->Auth->setConfig('unauthorizedRedirect', ['prefix' => 'admin', 'controller' => 'Dashboards', 'action' => 'home']);` and it doesn’t seem to work
# Jul 15th 2019, 07:47 neon1024 So, rolling back to Monday. How can I set the Auth unauthorizedRedirect dynamically?
# Jul 15th 2019, 02:26 markstory @davorminchorov Also check php’s memory_limit ini value as it can be different than the container memory.
# Jul 15th 2019, 01:58 nuzulfikrie hi all, any solution that checks for number of login of user ? limit only one browser session per tab - if we have multiple of sessions, will redirect the user to the tab that user chooses. similar like whatsapp web
# Jul 14th 2019, 19:32 ndm @davorminchorov Install xdebug or something similar that will provide you with a proper stacktrace for fatal errors.
# Jul 14th 2019, 19:01 davorminchorov Anyone here ever got the error: `Allowed memory size of 786432000 bytes exhausted (tried to allocate 16384 bytes)`? How can I debug it to figure out why it is happening? I have allocated 4 GB on my docker instance but it seems that it is not enough. I am assuming that it has to do with bad application code.
# Jul 14th 2019, 16:14 roberto.conterosito You're not wrong, probably I've to rethink this specific scenario.
# Jul 14th 2019, 16:12 admad If the join table has extra fields than usually the answer to all problems is use use hasMany with the join table instead.
# Jul 14th 2019, 16:11 roberto.conterosito Anyway, really thank you very much for you availability guys! :slightly_smiling_face:
# Jul 14th 2019, 16:08 roberto.conterosito @admad I'm working on porting of an old application (written in Cake 2.*) with it's own workflow system, necessary to handle some audit operation on every table, and this column is required (anyway I've multiple columns on this many-to-many, is a custom scenario that I've to manage in this case).
# Jul 14th 2019, 16:07 admad @roberto.conterosito if the join table doesn't have extra fields besides the fK fields what's the point of extra primary key field
# Jul 14th 2019, 16:06 roberto.conterosito In my scenario I'm using "append" saveStrategy. But I've used "replace" too to do more tests, the behaviour is always the same.
# 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?