Logs for #cakephp

Page 48 of 36,922, showing 100 records out of 3,692,143 total, starting on record 4,701, ending on 4,800

# At Username Text
# May 21st 2021, 14:53 rajesh We are migrating Cakephp 2.10 from php 5.6 to 7.3 - we are generating cookies through default CakePHP method Security::cipher() And current active users having cookies generated from php 5.6 (we have approx 200K Active users) now issue is that we can't get cookies correct values those set in php 5.6 at new server 7.3
# May 21st 2021, 14:22 caseyw You're totally right. What was done is there is a service class that's fully tested. The middleware instantiates it, and runs a method passing Req/Resp. All that was mocked and tested and it's good to go. It essentially modifies the request to add the attribute and that's it. We have test around it as well. I don't want to mess with any internals, but thought there might be an easy way in the configRequest to pass attributes.
# May 21st 2021, 14:22 slackebot Maybe that's more difficult than I expected? That makes me wonder, does it make more sense for testability to change it from attributes to parameters?
# May 21st 2021, 14:16 ndm I wouldn't fiddle with internals in an integration, until there's a specific technical need for it.
# May 21st 2021, 14:15 ndm Well, apparently it does need it, given that the attribute is missing ;)
# May 21st 2021, 14:14 caseyw In this case it's being set in middleware, but the test doesn't need the middleware to run. I was hoping to be able to simply set the attribute when I construct the request in the test :)
# May 21st 2021, 14:00 ndm If it's present in a regular web request, then I'd generally expect that it's present in a simulated test request too.
# May 21st 2021, 13:59 ndm I'd say that depends on where that attribute is being set.
# May 21st 2021, 13:56 caseyw Greetings, I have a question about a unit test in 3.9. In a controller we're making use of $this->getRequest()->getAttribute('example') - In an integration test we can't figure out how to populate the attribute field for the request. Any ideas on passing it in the test?
# May 21st 2021, 11:49 paolo.bragagni ok thanks. lot of work to do
# May 21st 2021, 11:47 ndm Build your own application template, that's not a workaround, but a perfectly acceptable solution. Check out other's app templates, like https://github.com/markstory/cakephp-typescript-react
# May 21st 2021, 11:46 paolo.bragagni I know so I have to find a workaround
# May 21st 2021, 11:45 ndm There is no application baking anymore, custom app skeletons look like `cakephp/app` now.
# May 21st 2021, 11:44 paolo.bragagni go for easier :)
# May 21st 2021, 11:44 paolo.bragagni and I had my new app with my settings/template/configuration
# May 21st 2021, 11:43 paolo.bragagni in cake2 I didi cake bake project --skel Templates/myskel myapp
# May 21st 2021, 11:43 ndm Again, what's _better_ and _easier_ depends, you have to try it.
# May 21st 2021, 11:42 paolo.bragagni but I'm OPEN to better and easiest solutions
# May 21st 2021, 11:41 paolo.bragagni in my idea is to use composer create-project to inizialize my app and the use the plugin where I put all my changes/configurations etc..
# May 21st 2021, 11:40 paolo.bragagni it auto generate, but if I copy cakephp/app I have the same for all my apps
# May 21st 2021, 11:39 ndm Unless you hard-code it, that would get auto-generate, just like when you install the default CakePHP application template (assuming you'd use `composer create-project` to initialize your custom template).
# May 21st 2021, 11:38 paolo.bragagni I can overwrite my cakephp/app ??
# May 21st 2021, 11:38 paolo.bragagni the application has some sort of id salt id etc?
# May 21st 2021, 11:38 ndm You should give it a try and see hot it works for you.
# May 21st 2021, 11:37 ndm That all depends on what possible needs to be maintained, there's no one size fits all solution. However, generally I'd suggest an application template as the basis, as trying to cram all sorts of boilerplate code into plugins can easily turn into a hot mess.
# May 21st 2021, 11:37 paolo.bragagni (I meand I have to port all work done for cake2.. but at least I knw how to do..)
# May 21st 2021, 11:36 paolo.bragagni I've already made a bake theme to build all my modified actions and views
# May 21st 2021, 11:35 paolo.bragagni but which is the more simple way?
# May 21st 2021, 11:35 paolo.bragagni yes this is sure
# May 21st 2021, 11:34 kevin.pfeifer if you want my hot topic on that: If it works and you (and your co-workers) can work with it then keep it as simple as possible and not "search for the right way" too hard
# May 21st 2021, 11:33 paolo.bragagni I'm porting the same work that I mede some years ago with cake2
# May 21st 2021, 11:33 paolo.bragagni then when I have to build a new app I copy cakephp/app ?
# May 21st 2021, 11:33 neon1024 I think what you’re doing is a bit too bespoke for a ‘right way’
# May 21st 2021, 11:32 paolo.bragagni but it is the right way?
# May 21st 2021, 11:32 paolo.bragagni yes it is an idea
# May 21st 2021, 11:32 paolo.bragagni yes, we have smartcard and access to an oauth2 server authentication
# May 21st 2021, 11:32 ndm You might want to consider a custom application template, eg fork `cakephp/app` and maintain it according to your needs.
# May 21st 2021, 11:31 neon1024 Sounds like OAuth :thinking_face:
# May 21st 2021, 11:31 neon1024 So some kind of common way of authenticating?
# May 21st 2021, 11:31 paolo.bragagni some plugins internally developed
# May 21st 2021, 11:31 paolo.bragagni ssme template
# May 21st 2021, 11:31 paolo.bragagni same kind of authenticator
# May 21st 2021, 11:30 paolo.bragagni same kinfd of autentication and authorization
# May 21st 2021, 11:30 paolo.bragagni I need something more
# May 21st 2021, 11:29 neon1024 If you are going to be duplicating the same code many times, then there might be a better approach
# May 21st 2021, 11:28 neon1024 Wouldn’t that just be a framework and a coding standard?
# May 21st 2021, 11:28 paolo.bragagni so that my group of programmers use same structure
# May 21st 2021, 11:28 slackebot Command sent from Slack by neon1024:
# May 21st 2021, 11:28 slackebot !xy
# May 21st 2021, 11:28 paolo.bragagni I want to make an 'internal' skeleton
# May 21st 2021, 11:27 neon1024 @paolo.bragagni Are you building a multiple tenant application?
# May 21st 2021, 11:19 paolo.bragagni I'm only searching best method
# May 21st 2021, 11:18 paolo.bragagni Ssme template etc
# May 21st 2021, 11:18 neon1024 I am trying to test when my `delete()` fails, and I’m caught between using an Integration test where I’m not sure how to mock the Table::delete() or a Unit test where I cannot assert the Flash messages. Any tips?
# May 21st 2021, 11:18 paolo.bragagni I have to build many apps all of them eith same authandauth
# May 21st 2021, 11:12 ndm :upside_down_face:
# May 21st 2021, 11:11 steinkel lol, what @ndm said
# May 21st 2021, 11:11 steinkel @paolo.bragagni if your're aiming to create a plugin to handle these items, remember you can inject middlewares from the plugin and handle all configuration so your main app will be "clea"
# May 21st 2021, 11:11 ndm That can be summed up as adding middleware, which is also possible from within your plugin's `Plugin` class, it has a `middleware()` method too. However depending on the specific middleware, you might need to add it using `insertAfter()`/`insertBefore()` as otherwise they will be appended after all application level middlewares. Plugins can also add other plugins in their bootstrap, but they need to obtain and use the plugin
# May 21st 2021, 11:11 slackebot collection directly to do that, like ```$plugins = \Cake\Core\Plugin::getCollection(); $plugins->add($plugins->create('Authentication'));``` To modify controllers you'd probably have to use events, like `Controller.initialize` (which is equivalent to `beforeFilter()`). Whether it makes sense to move this all into a plugin... that would be a different question :)
# May 21st 2021, 11:02 paolo.bragagni etc etc
# May 21st 2021, 11:02 paolo.bragagni some changes in middleware
# May 21st 2021, 11:01 paolo.bragagni then $this->addPlugin('Authentication');
# May 21st 2021, 11:01 paolo.bragagni etc etc
# May 21st 2021, 11:01 paolo.bragagni in class Application I've implemented AuthenticationServiceProviderInterface, AuthorizationServiceProviderInterface
# May 21st 2021, 11:00 paolo.bragagni (for authentication)
# May 21st 2021, 11:00 paolo.bragagni in application I add //Authentication use Authentication\AuthenticationService; use Authentication\AuthenticationServiceInterface; use Authentication\AuthenticationServiceProviderInterface; use Authentication\Identifier\IdentifierInterface; use Authentication\Middleware\AuthenticationMiddleware;
# May 21st 2021, 10:59 paolo.bragagni I simply follow the guide for Authorization and Authentication
# May 21st 2021, 10:58 ndm Depends on what exactly you change in `Application` and `AppController` I guess.
# May 21st 2021, 10:47 paolo.bragagni (sorry for my english)
# May 21st 2021, 10:47 paolo.bragagni but how to keep 'src' as clean as possible and put all 'my' changes in my plugin?
# May 21st 2021, 10:46 paolo.bragagni right now I build my authenticator componentI put it in src/authenticator etc.. then I follow the guide and change something in Application.php and AppController.php
# May 21st 2021, 10:44 paolo.bragagni that have the skeleton of my app with authentication and authorization etc
# May 21st 2021, 10:43 paolo.bragagni the idea is to bake the new application, install 'my' plugin
# May 21st 2021, 10:42 paolo.bragagni I'fd like to use m plugin as 'base' for authentication and authorization to keep the APP as clean as possible
# May 21st 2021, 09:59 ndm The former would also avoid problems with your modifier, as only the ORM query builder will nest complex count queries.
# May 21st 2021, 09:58 ndm If you don't need to use any ORM features for your count query, then your best bet might be to use the lower level database query builder instead of the ORM one. Another workaround could be to dynamically load the table with a different alias, and unload the behavior on that alias.
# May 21st 2021, 09:47 ndm There probably is no overly straightforward way, as it applies for all queries of table, and joins and formatters for translations are being added in the `Model.beforeFind` event.
# May 21st 2021, 09:44 thomas465 oh, neat, what about a clean way of disabling translations where they are not needed ?
# May 21st 2021, 09:43 ndm @thomas465 You can use the query builder's `counter()` method to define a custom count query. https://book.cakephp.org/4/en/orm/query-builder.html#returning-the-total-count-of-records
# May 21st 2021, 09:40 paolo.bragagni it works!! great!
# May 21st 2021, 09:40 ndm I don't think so, IIRC that's only required on application level.
# May 21st 2021, 09:38 paolo.bragagni no 'authorization' path somewhere in my plugin template?
# May 21st 2021, 09:38 thomas465 sorry, fails with ` Syntax error or access violation: 1234 Incorrect usage/placement of ‘SQL_NO_CACHE’`
# May 21st 2021, 09:38 thomas465 Regarding pagination, i have a rather large query that i need paginated, the problem is that the count method in the Paginator uses the complete query, including translation tables. It always fails when giving the query a modifier like ```$query = $query->where(['Products.is_active' => true])->select([ 'id', 'name', 'children_count'], false)->modifier('sql_no_cache');``` fails with ```SELECT (COUNT(*)) AS `count` FROM
# May 21st 2021, 09:38 slackebot (SELECT sql_no_cache `Products`.`id` AS `Produ```
# May 21st 2021, 09:34 ndm See also https://book.cakephp.org/bake/2/en/development.html#creating-a-bake-theme
# May 21st 2021, 09:33 ndm Given the paths in the authorization plugin, the path inside your theme plugin should be `templates/bake/policy.twig` and `templates/bake/element/entity_methods.twig`.
# May 21st 2021, 09:31 paolo.bragagni (and I'd like to insert the modified twig policy template in a plugin)
# May 21st 2021, 09:30 paolo.bragagni I'd like to insert something in before method and add all my standard actions
# May 21st 2021, 09:29 paolo.bragagni I have to modify the template
# May 21st 2021, 09:21 ndm @paolo.bragagni Do you plan to modify the templates? If not, then you don't need to touch them.
# May 21st 2021, 08:43 paolo.bragagni and I'd like to put the policy.twig and entity_methods.twig inside a plugin
# May 21st 2021, 08:43 paolo.bragagni found this https://github.com/cakephp/authorization/issues/138 but doesnt work in cakephp 4
# May 21st 2021, 07:14 paolo.bragagni Hi there is a way to bake a authorization policy taking the template from a plugin?
# May 20th 2021, 23:56 khalil And I can't find one that works with 4.2
# May 20th 2021, 23:55 khalil There are a couple that work with 3.x
# May 20th 2021, 23:55 khalil Guys is there any datatables plugin that works with cake 4.2 ?
# May 20th 2021, 23:10 ndm no problem
# May 20th 2021, 23:02 khalil Sorry for wasting your time!