Log message #4222854

# At Username Text
# Jan 16th 2020, 22:57 challgren @wizardfix check https://github.com/friendsofcake/awesome-cakephp for ones with :strawberry:
# Jan 16th 2020, 22:03 wizardfix *Problem creating and writing to file* This is probably something simple I'm missing. I'm just trying to create a file and write a line of text to it. ```$path = WWW_ROOT . 'files/test_results_ex.csv'; $file = new File($path, true, 0755); $file->write('#ID,Number,Country,Start time,Connect time,End time,Score,URL'); $file->close();```
# Jan 16th 2020, 21:26 ricksaccous is there a fileuploader plugin out there for cakephp4?
# Jan 16th 2020, 20:02 ndm @noel JSON column types are handles by the JSON database types, which encodes/decodes the data accordingly when reading/writing from/to the database. https://github.com/cakephp/cakephp/blob/3.8.8/src/Database/Type/JsonType.php
# Jan 16th 2020, 19:15 noel Actually that's not going to help me.. the value is already incorrectly stored within the entity's `_properties`. So I think the problem is at the point where the query is executed and the entity's properties are hydrated.
# Jan 16th 2020, 18:54 noel Or should I create my own datatype instead?
# Jan 16th 2020, 18:51 slackebot How can I affect this? I want to somehow intercept or overwrite the getter?
# Jan 16th 2020, 18:51 noel So.. the problem I'm having actually seems to be with the entity's getters. The property I'm interested in was defined in the migration as a `json` data type. The value stored in the database is `{"AO":{}}` but the entity defines the property as an array (i.e. `@property array`) and the getter returns the value as `["AO" => []]` as a PHP array structure. Presumably it is performing a `json_decode` in the getter due to the data type of the field.
# Jan 16th 2020, 18:41 jimbo2150 Hm, I don't see much difference with the dependencies with that package. I prefer not to try to revert back to dev for packages as 4 continues shifting over to stable packages. It is not affecting anything major, just wondering if anyone else was seeing that issue. Thanks @challgren
# Jan 16th 2020, 18:41 noel Wish I'd found this comment about 2 days ago: `// JSON API as generated by NeoMerx. When things look off, start debugging here`
# Jan 16th 2020, 18:28 challgren But if I switch it back to ^4.0 it does the upgrade and then downgrade
# Jan 16th 2020, 18:27 challgren But I am using a dev debugkit version
# Jan 16th 2020, 18:27 challgren @jimbo2150 doesn’t happen on my project today
# Jan 16th 2020, 18:21 jimbo2150 Happened again, upgrading then downgrading again with Composer with default CakePHP 4 setup. Still not sure what is going on...
# Jan 16th 2020, 18:20 noel I think the problem I'm having is to with the Entity. So my viewVar contains an entity. If I do a get on the property I want from the entity it is returning an incorrect value. It's confusing because as I understand it crud-json-api is supposed to get it's data from the BodyParserMiddleware... but I don't think it's doing that. I think instead it is getting it from the entity.
# Jan 16th 2020, 18:19 challgren Ughh I have to learn lararel I fought tooth and nail to use CakePHP
# Jan 16th 2020, 17:40 challgren We are already slaves to the machines!
# Jan 16th 2020, 17:36 ndm That's how the machines will take over
# Jan 16th 2020, 17:35 ndm Yeah, initially the traits were kinda cumbersome at times when digging through the code, luckily PhpStorm got better at it, so that it now also knows where a trait is being used, and basically inherits the inheritors for code completion and stuff, and so I don't really complain about it...
# Jan 16th 2020, 17:28 admad We unfortunately drank a bit too much of the "composition over inheritance" coolaid when traits were new in PHP
# Jan 16th 2020, 17:28 ndm I mean, the aliasing itself is pretty easy to understand, but that it can affect other use statements is really funky
# Jan 16th 2020, 17:26 admad @ndm i do know theoretically about trait method aliasing. In practice it does create for "fun" code reading as you found out :)
# Jan 16th 2020, 17:22 noel I'm getting this error during xdebug session – but it's not being reported anywhere else (like logs etc.) `Aura\Intl\Exception: Package 'debug_kit' with locale 'en_US' is not registered.` Any ideas what it's about?
# Jan 16th 2020, 17:06 ndm You just have to love PHP :upside_down_face:
# Jan 16th 2020, 17:00 shoe I just saw that same thing the other day, and yes, it was news to me.
# Jan 16th 2020, 17:00 neon1024 I’ve seen it before in other Cake files, but never investigated it
# Jan 16th 2020, 16:58 ndm And by minute I mean I dumbfoundedly digged through the code for 20 minutes, not knowing what the hell is going on
# Jan 16th 2020, 16:56 ndm Ok, honestly, who here knew that separate `use` statements for traits seem to handled the same as using a single `use` statement and a comma separated list of traits, therefore allowing to alias methods of traits in other `use` statements? https://github.com/cakephp/migrations/blob/2.4.1/src/Command/Migrate.php#L24-L26 That really threw me off for a minute, as `execute` is a method of `CommandTrait`.
# Jan 16th 2020, 16:55 alexmax I use VSCode + PHP Intelliphense now, and it works great, but when I was having the worst of the issues I think I was either using no linter or `php -l` which doesn't catch those issues.
# Jan 16th 2020, 16:50 dereuromark you dont use en IDE? then this doesnt happen usually :)
# Jan 16th 2020, 16:47 alexmax `Exception` vs `\Exception` is the worst.
# Jan 16th 2020, 16:47 alexmax if I had a dollar for every time I've been caught out by catching a non-existant class because of namespace treachery...
# Jan 16th 2020, 16:45 shoe @ndm NAMESPACES!!! ha! I apparently didn’t add the proper namespace for the ForbiddenException when I tried that earlier. You’re right that does work now. Thank you!
# Jan 16th 2020, 16:38 ndm It will work, as the authorization middleware wraps all following middlewares in a `try...catch`, and catch all exceptions. The redirect handler would need to be configured accordingly to catch `\Authorization\Exception\ForbiddenException` exceptions, as by default it only handles `\Authorization\Exception\MissingIdentityException`. All non configured exceptions will be rethrown.
# Jan 16th 2020, 16:34 shoe https://book.cakephp.org/authorization/2/en/request-authorization-middleware.html
# Jan 16th 2020, 16:34 shoe But that won’t work when using the request authorization middleware, will it?
# Jan 16th 2020, 16:33 ndm By default it uses the exception handler, which will just rethrow the catched exception
# Jan 16th 2020, 16:32 ndm That is handled through the authorization middleware https://book.cakephp.org/authorization/2/en/middleware.html#handling-unauthorized-requests
# Jan 16th 2020, 16:28 slackebot the Request Authorization, but I’m probably missing something really obvious :)
# Jan 16th 2020, 16:28 shoe When using the Authorization plugin, and specifically using the Request Authorization Middleware is it possible to redirect the user if the user is unauthorized, rather than throwing the ForbiddenException error?The regular Authorization Middleware has an “unauthorizedHandler” which can be used to redirect, but I’m basically using a roles based authentication limiting access to various controllers / actions and see no similar option for
# Jan 16th 2020, 15:39 rudy1976s @neon1024 nice idea I will try test and see what happens !