-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Update Core to comply to coding standards #8
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
Conversation
phpcs.xml.dist
Outdated
|
|
||
| <!-- | ||
| phpcbf -.-standard=phpcs8.xml.dist -.-report-summary -.-report-source -.-report-full=./20170926-11-phpcbf-all-incl-new-sniffs.txt -.-basepath=I:/000_GitHub/WP_test_suite/ | ||
| --> |
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.
The above 3 line comment should be removed, or updated to reference a suggested command line example, e.g. phpcbf --standard=phpcs.xml.dist --report-summary --report-source
| 'https://github.com/WordPress/gutenberg' ); ?></p> | ||
| 'https://github.com/WordPress/gutenberg' | ||
| ); | ||
| ?> |
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.
The indent doesn't seem right here.
| exit; | ||
|
|
||
| /** | ||
| /** |
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.
Nope.
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.
| 'timeout' => 120, | ||
| 'httpversion' => '1.1', | ||
| ) | ||
| ); |
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.
What rule are we following here? Should this be more like this:
$response = wp_remote_get(
admin_url( 'upgrade.php?step=1' ),
array(
'timeout' => 120,
'httpversion' => '1.1',
)
);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.
Yeah, that looks wrong. Can you report it to the WPCS repo?
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.
I can, but I wasn't sure if that's a rule we have because it's all over the code base now. Or should I create one for discussion first?
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.
If it doesn't look right, it's probably a bug. ;)
| $id, array( | ||
| 'send' => false, | ||
| 'delete' => true, | ||
| ) |
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.
See above, another example:
echo get_media_item(
$id,
array(
'send' => false,
'delete' => true,
)
);
src/wp-admin/edit-tag-form.php
Outdated
| if ( 'category' == $taxonomy ) { | ||
| /** | ||
| * Fires before the Edit Category form. | ||
| * Fires before the Edit Category form. |
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.
This probably needs manual fixing, there's actually a space before the tab but now it's after the tab. 🤔
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.
| case 'pages': $('#page-filters').slideDown(); break; | ||
| } | ||
| }); | ||
| }); |
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.
Same as above, the extra whitespaces don't get removed, just moved after the tab.
| <?php | ||
| /* translators: %s: importer slug */ | ||
| printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' ); | ||
| ?> |
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.
That's too much indentation.
tools/i18n/extract.php
Outdated
| @@ -9,7 +9,7 @@ | |||
| */ | |||
| class StringExtractor { | |||
|
|
|||
| var $rules = array( | |||
| var $rules = array( | |||
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 sure if we have to update tools/i18n/ here too. 🤷♂️
Did you run the tests manually?
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.
That's the expected behaviour, but it looks a bit weird. Move the $comment_prefix declaration above $rules, or add a blank line between them.
Run what tests manually?
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.
I meant the whole tools/i18n directory.
The tests in https://core.trac.wordpress.org/browser/trunk/tools/i18n/t.
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.
Given that I've never opened that directory before... no. Why doesn't it run in Travis?
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.
I was never a fan of having that directory on core.trac at all. For me the canonical source is still https://i18n.trac.wordpress.org/browser/tools.
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.
Let's just external one of them.
313b7c3 to
7d9dc4f
Compare
…site-icon Custom properties, site-icon file
…WP_Scripts::localize()`.
This function was previously already problematic as it does not do proper input validation, and it has already received tweaks related to PHP 8.0 in [50408] / #52534, which also introduced a `_doing_it_wrong()` notice and added tests.
The short of it is:
* The function expects to receive an `array` for the `$l10n` parameter;
* ...but silently supported the parameter being passed as a `string`;
* ...and would expect PHP to gracefully handle everything else or throw appropriate warnings/errors.
In the previous fix, a `_doing_it_wrong()` notice was added for any non-array inputs. The function would also cause a PHP native "Cannot use a scalar value as an array" warning (PHP < 8.0) or error (PHP 8.0+) for all scalar values, except `false`.
PHP 8.1 deprecated autovivification from `false` to `array`, so now `false` starts throwing an "Automatic conversion of false to array is deprecated" notice.
By rights, the function should just throw an exception when a non-array/string input is received, but that would be a backward compatibility break.
So the current change will maintain the previous behavior, but will prevent both the "Cannot use a scalar value as an array" warning/error as well as the "Automatic conversion of false to array" deprecation notice for invalid inputs.
Invalid inputs ''will'' still receive a `_doing_it_wrong()` notice, which is the reason this fix is considered acceptable.
Includes:
* Adding a test passing an empty array.
* Adding a test to the data provider for a `null` input to make sure that the function will not throw a PHP 8.1 "passing null to non-nullable" notice.
This solves the following PHP 8.1 test error:
{{{
Tests_Dependencies_Scripts::test_wp_localize_script_data_formats with data set #8 (false, '[""]')
Automatic conversion of false to array is deprecated
/var/www/src/wp-includes/class.wp-scripts.php:514
/var/www/src/wp-includes/functions.wp-scripts.php:221
/var/www/tests/phpunit/tests/dependencies/scripts.php:1447
/var/www/vendor/bin/phpunit:123
}}}
Reference: [https://www.php.net/manual/en/migration81.deprecated.php#migration81.deprecated.core.autovivification-false PHP Manual: PHP 8.1 Deprecations: Autovivification from false].
Follow-up to [7970], [18464], [18490], [19217], [50408].
Props jrf, costdev.
See #55656.
git-svn-id: https://develop.svn.wordpress.org/trunk@54142 602fd350-edb4-49c9-b593-d223f7449a82
…updates Test updates.
See the Trac ticket.