# |
May 7th 2021, 08:33 |
erwane |
@kevin.pfeifer do you have a doc about using npm packages in (cake)php project please ? |
# |
May 6th 2021, 20:16 |
scsmith |
@admad prefect. thank you. |
# |
May 6th 2021, 20:13 |
admad |
@scsmith `$this->getController()->loadModel()` will give you the default model instance. |
# |
May 6th 2021, 19:29 |
greg138 |
How was it getting that, and what error do you get when you try it now? |
# |
May 6th 2021, 19:15 |
scsmith |
In CakePHP 3.x we had a component that access the controllers primary model through the modelClass. In CakePHP 4.x is there another way to get this information? |
# |
May 6th 2021, 16:08 |
neon1024 |
Ah well, it can be tomorrows problem :wave: |
# |
May 6th 2021, 16:06 |
neon1024 |
Just some really odd test case issues. Like if you use the `IntergrationTestTrait`, use `configRequest` in your `setUp` and call `enableCsrfToken` then `post()`, you get an error because the cookie isn’t set. When `enableCsrfToken` docblock says it sets the cookie. I suppose it can set it and not send it :thinking_face: |
# |
May 6th 2021, 16:00 |
neon1024 |
Thankfully a bit of regex and search and replace have got me most of the way so far |
# |
May 6th 2021, 15:59 |
neon1024 |
I sure hope it works! I have gone up to 4.0.10, so have the 4.1 and 4.2 upgrades still on the horizon |
# |
May 6th 2021, 15:55 |
ndm |
Could be for the better, trying to get rector to work was a pain everytime I tried it, that thing seems to break like clockwork, at least for me :upside_down_face: |
# |
May 6th 2021, 15:51 |
neon1024 |
I had some issues with the upgrade tool crashing for Symfony Console ProgressBar class, so couldn’t get through all the automation :( |
# |
May 6th 2021, 15:51 |
neon1024 |
This is probably an edge-case as I am upgrading from Cake 3.9 :) |
# |
May 6th 2021, 15:50 |
ndm |
Ah, guess that only happens when the token is wrong... |
# |
May 6th 2021, 15:50 |
ndm |
Looking at the source, it doesn't seem that debug tokens are supported... not sure what to make of that. https://github.com/cakephp/cakephp/blob/master/src/TestSuite/IntegrationTestTrait.php#L652 |
# |
May 6th 2021, 15:50 |
neon1024 |
Seems it’s a session issue :) |
# |
May 6th 2021, 15:49 |
neon1024 |
// Fixate sessionid early on, as php7.2+ // does not allow the sessionid to be set after stdout // has been written to. session_id(‘cli’); |
# |
May 6th 2021, 15:46 |
neon1024 |
I see it here also https://book.cakephp.org/4/en/development/testing.html#testing-actions-protected-by-csrfcomponent-or-securitycomponent |
# |
May 6th 2021, 15:45 |
erwane |
opened an issue : https://github.com/composer/installers/issues/488 I don't found any solution for composer 2 parallel install and version check. |
# |
May 6th 2021, 15:40 |
neon1024 |
Anyone know why I see `Invalid security debug token` in my unit test when I am calling `$this->enableSecurityToken();` specifically for this? |
# |
May 6th 2021, 14:48 |
neon1024 |
THen if it’s null, it says it needs to be called, rather than telling you to load it |
# |
May 6th 2021, 14:48 |
neon1024 |
Good shout. Form->unlockField leads to trying to use the FormProtector |
# |
May 6th 2021, 14:46 |
neon1024 |
Cool, thanks @ndm I need to head into a meeting now, but that’s a great thread for me to investigate! |
# |
May 6th 2021, 14:46 |
ndm |
I'd say the error message is a bit misleading, as just calling `create()` will not create a form protector instance, it must be a `POST` form, and the request must contain the form token created by the form protection component. |
# |
May 6th 2021, 14:44 |
neon1024 |
Ah, sorry. My mistake, this method is not Crud |
# |
May 6th 2021, 14:44 |
ndm |
I think it's required to be able to unlock anything |
# |
May 6th 2021, 14:43 |
neon1024 |
I am using Crud though, so _it_ may have loaded it |
# |
May 6th 2021, 14:43 |
neon1024 |
I don’t believe so |
# |
May 6th 2021, 14:43 |
ndm |
*the form protection component |
# |
May 6th 2021, 14:43 |
ndm |
Do you actually have the form protector loaded? |
# |
May 6th 2021, 14:42 |
ndm |
I don't think so. |
# |
May 6th 2021, 14:41 |
neon1024 |
Does the new Csrf MIddleware need a token even for get rquest? |
# |
May 6th 2021, 14:37 |
neon1024 |
It’s a modelless form I wonder if that has upset it |
# |
May 6th 2021, 14:36 |
neon1024 |
I do call unlockField, but it’s between create() and end() |
# |
May 6th 2021, 14:33 |
ndm |
Check the stacktrace, it means `FormHelper::getFormProtector()` was invoked before `FormHelper::create()`. You possibly forgot to invoke `create()`, or accidentally invoked `unlockField()` or `submit()` before `create()`. |
# |
May 6th 2021, 14:23 |
neon1024 |
As I don’t see it here https://book.cakephp.org/4/en/controllers/components/form-protection.html |
# |
May 6th 2021, 14:23 |
neon1024 |
Or is there a docs page which explains what this is? |
# |
May 6th 2021, 14:19 |
neon1024 |
First? First what? First line? |
# |
May 6th 2021, 14:18 |
neon1024 |
`FormHelper::create() must be called first for FormProtector instance to be created` |
# |
May 6th 2021, 14:18 |
neon1024 |
Anyone know what this means? |
# |
May 6th 2021, 13:29 |
admad |
I am glad we ditched composer/installers :) |
# |
May 6th 2021, 13:22 |
erwane |
The problem come from "async" install. composer prepare package list and download/install all at same time. I can't retrive real "installed package" when composer/installers return the path. |