-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blog post preview in admin throws 500 #169
Comments
Another way to fix it would be to set the property to an empty array in `PostFormFactory::buildPost()`. Close #169
Another way to fix it would be to set the property to an empty array in `PostFormFactory::buildPost()`. Close #169
Reopening, this time it's |
Are you able to create failing test case? We should found this kind of bugs with phpstan latte |
I may try to, need to understand the tests structure first though :-) |
If you will not understand it, just try to describe it to me :) I tried to figure it out from the code, but I can't find the problem myself, because in this presenter templates there is no usage of this control |
Okay, thanks, I'll try to describe it first and then if you're going to write a test I'll use that as a reference next time. First things first, this is going to be about the "Component with name 'articleHeaderIcons' does not exist" fixed in #190, I think that's what you're interested in this time, but I wanted to make sure we're on the same page. Maybe the root cause is the same as for "Missing template file" fixed in 7c59931. I have a simple & stupid blog where you can write a blog post and click a "Preview" button and it will load the blog post into an iframe. The edit/preview form is created here: michalspacek.cz/site/app/Admin/Presenters/BlogPresenter.php Lines 54 to 68 in e1362ca
And this is the "Preview" click handler michalspacek.cz/site/app/Form/PostFormFactory.php Lines 122 to 124 in e1362ca
Note the
This is how it's passed to that method in the first code snippet above:
So we're kind of still in the same presenter where you don't see the What I'll do in the michalspacek.cz/site/app/Articles/Blog/BlogPostPreview.php Lines 29 to 32 in e1362ca
I'll switch the template file for something else while technically still being in the old presenter. And then the template response is sent with
I want the preview to behave exactly like it should, meaning require authentication etc., but look exactly like it would look when viewed. It definitely can be written in a different way maybe but here we are 😅 So it could be described as a control that's used in a I've realized there's a collector for finding |
Uff 🤪😅 I have to read this again and again and again :D but still it is hard to resolve some variables / paths which are set to template if it is sent to some other services etc. We have covered only some simple (štandard / most common) ways :) |
Yeah, I'll see if I can change it somehow. |
Fixed by #200 |
Do you think this could help? efabrica-team/phpstan-latte#424 |
Not sure it would help in this very specific case. Looking at the previous issues here, the problem is more that the whole template is not analyzed, don't get distracted that this time the problem was in |
Then maybe this one :) efabrica-team/phpstan-latte#425 But you are right, this is very specific case. |
Yeah, efabrica-team/phpstan-latte#425 looks more like it. But I could also add a unit/something test that I think would also help, but I just didn't think/know I need one before I started using PHPStan Latte :-) |
To avoid all blog post preview errors. This test successfully detects all the issues reported in #169.
To avoid all blog post preview errors. This test successfully detects all the issues reported in #169.
To avoid all blog post preview errors. This test successfully detects all the issues reported in #169.
To avoid all blog post preview errors. This test successfully detects all the issues reported in #169.
There are some hardcoded paths in the config that are hard to change and are needed for rendering the blog post template: - SRI extension path to CSS, JS etc. - SVG icons paths These could be set in the test with ```php $this->sriConfig->setLocalPrefix((object)['path' => __DIR__ . '/../../../public/www.michalspacek.cz']); PrivateProperty::setValue($this->svgIconNodeFactory, 'iconsDir', __DIR__ . '/../../../node_modules/humbleicons/icons'); ``` but the you get "Cannot modify readonly property Spaze\SvgIcons\Nodes\IconNodeFactory::$iconsDir" Creating a custom template where neither SRI nor SVG icons are needed would be possible but then things like "Component with name 'articleHeaderIcons' does not exist" from #169 would not be tested.
…e repository checkout There are some hardcoded paths in the config that are hard to change and are needed for rendering the blog post template: - SRI extension path to CSS, JS etc. - SVG icons paths These could be set in the test with ```php $this->sriConfig->setLocalPrefix((object)['path' => __DIR__ . '/../../../public/www.michalspacek.cz']); PrivateProperty::setValue($this->svgIconNodeFactory, 'iconsDir', __DIR__ . '/../../../node_modules/humbleicons/icons'); ``` but the you get "Cannot modify readonly property Spaze\SvgIcons\Nodes\IconNodeFactory::$iconsDir" Creating a custom template where neither SRI nor SVG icons are needed would be possible but then things like "Component with name 'articleHeaderIcons' does not exist" from #169 would not be tested.
…e repository checkout There are some hardcoded paths in the config that are hard to change and are needed for rendering the blog post template: - SRI extension path to CSS, JS etc. - SVG icons paths These could be set in the test with ```php $this->sriConfig->setLocalPrefix((object)['path' => __DIR__ . '/../../../public/www.michalspacek.cz']); PrivateProperty::setValue($this->svgIconNodeFactory, 'iconsDir', __DIR__ . '/../../../node_modules/humbleicons/icons'); ``` but the you get "Cannot modify readonly property Spaze\SvgIcons\Nodes\IconNodeFactory::$iconsDir" Creating a custom template where neither SRI nor SVG icons are needed would be possible but then things like "Component with name 'articleHeaderIcons' does not exist" from #169 would not be tested.
…e repository checkout There are some hardcoded paths in the config that are hard to change and are needed for rendering the blog post template: - SRI extension path to CSS, JS etc. - SVG icons paths These could be set/overwritten in the test with ```php $this->sriConfig->setLocalPrefix((object)['path' => __DIR__ . '/../../../public/www.michalspacek.cz']); PrivateProperty::setValue($this->svgIconNodeFactory, 'iconsDir', __DIR__ . '/../../../node_modules/humbleicons/icons'); ``` But then you get "Cannot modify readonly property Spaze\SvgIcons\Nodes\IconNodeFactory::$iconsDir" Creating a custom template where neither SRI nor SVG icons are needed would be possible but then things like "Component with name 'articleHeaderIcons' does not exist" from #169 would not be tested.
To avoid all blog post preview errors. This test successfully detects all the issues reported in #169.
I've added a unit/integration test in #203 that tests this functionality by just trying to render the template so there should be no more bugs in this part of the app (someone please remind me of this in a year or two). |
Typed property MichalSpacekCz\Articles\Blog\BlogPost::$edits must not be accessed before initialization
File:
.../Articles/Blog/BlogPostPreview.php:34
A regression introduced in #137 commit 18b1d2a, here:
The text was updated successfully, but these errors were encountered: