-
Notifications
You must be signed in to change notification settings - Fork 332
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
FIX undefined index error in CMS #2845
FIX undefined index error in CMS #2845
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this is great.
Just a small change.
d0b2b30
to
1e959f4
Compare
code/Model/SiteTree.php
Outdated
// This method has to be implemented here to satisfy the CMSPreviewable interface. | ||
// See the actual implementation in CMSEditLinkExtension. | ||
return $this->extend('CMSEditLink')[0]; | ||
return $this->extend('CMSEditLink') ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return $this->extend('CMSEditLink') ?? ''; | |
return $this->extend('CMSEditLink')[0] ?? ''; |
Still need to get the 0th result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops haha 😅
With the CMS 4.12 update functionality was altered to utilise an Extension to obtain the CMS Edit link for a page, rather than having SiteTree do it internally. Unfortunately the default return case for `extend` (see Extensible) is an _empty_ array. This leave code potentially referencing an array offset that doesn't exist ([0]). PHP 8 is less forgiving that it's predecessors on this kind of behaviour. We should check that the responses from extensions exist before trying to reference them.
1e959f4
to
e200364
Compare
Is there anything left to do here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I got distracted and lost sight of this. Thank you for submitting it!
Thanks for restarting the automated test run, it's a relief to see it all pass :) |
With the CMS 4.12 update functionality was altered to utilise an Extension to obtain the CMS Edit link for a page, rather than having SiteTree do it internally. Unfortunately the default return case for
extend
(see Extensible) is an empty array. This leaves code potentially referencing an array offset that doesn't exist ([0]). PHP 8 is less forgiving than its predecessors on this kind of behaviour. We should check that the responses from extensions exist before trying to reference them.