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
Remove potential for fatals on front end. #187
Conversation
This could probably do with some tests but because I wasn't able to figure out how best to do so. The ratings are always set in the tests due to these lines simple-local-avatars/tests/phpunit/SimpleLocalAvatarsTest.php Lines 22 to 29 in bcfd173
I think an E2E test could be most reliable to ensure against the fatal when visiting the front end, with a test that the string |
*/ | ||
public function admin_init() { | ||
public function define_avatar_ratings() { | ||
$this->avatar_ratings = array( | ||
'G' => __( 'G — Suitable for all audiences', ), |
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.
@peterwilsoncc Can we make these strings translatable?
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.
Not the keys, they're used by WP for determining the rating of an avatar. The values are the strings displayed to the user.
It's the equivalent of this code in core. https://github.com/WordPress/wordpress-develop/blob/1111d2b9e6d71bb5506e18940518cc96adbbdb97/src/wp-admin/options-discussion.php#L249-L258
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.
@peterwilsoncc Can you add a comment? I can see someone can make them translatable.
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.
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.
@peterwilsoncc thanks for the fix. I have created ticket #188 to handle fatal in a Cypress test. We can work on it separately.
Description of the Change
This ensures
Simple_Local_Avatars::$avatar_ratings
is always defined on the front end to account for themes using avatars.It also fixes a deprecation warning in PHP 8.0
Closes #186
How to test the Change
PG
(anything other thanG
rated should work)* I was reliably able to reproduce the bug using TT1 but I think it would happen on all themes when viewing the front end while logged in due to the admin bar been displayed.
Changelog Entry
Credits
Props @peterwilsoncc, @Rottinator.
Checklist: