Skip to content
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 PHP 8.1 compatability #1422

Merged
merged 19 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint and Test

on: push

jobs:

lint:
name: Lint and Test
runs-on: ubuntu-22.04
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2

- name: Install NPM dependencies
run: npm install

- name: Install Composer dependencies
run: composer install

- name: Lint
run: npm run lint

- name: Pull Docker Images
run: docker-compose pull wordpress

- name: Test PHP
run: npm run phpunit

- name: Build
run: npm run build
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ before_install:

install:
- npm install
- composer install

script:
- npm run lint
Expand Down
4 changes: 2 additions & 2 deletions alerts/class-alert-type-slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public function alert( $record_id, $recordarr, $alert ) {
'author_icon' => get_avatar_url( $user_id, 16 ),
'author_link' => admin_url( "admin.php?page=wp_stream&user_id=$user_id" ),
'author_name' => trim( "$user->first_name $user->last_name" ),
'fallback' => html_entity_decode( $recordarr['summary'] ),
'fallback' => html_entity_decode( $recordarr['summary'], ENT_COMPAT ),
'fields' => $fields,
'footer' => get_bloginfo( 'name' ),
'footer_icon' => get_site_icon_url( 16, $logo[0], $recordarr['blog_id'] ),
'title' => html_entity_decode( $recordarr['summary'] ),
'title' => html_entity_decode( $recordarr['summary'], ENT_COMPAT ),
'ts' => strtotime( $recordarr['created'] ),
);
if ( array_key_exists( 'object_id', $recordarr ) ) {
Expand Down
2 changes: 1 addition & 1 deletion classes/class-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function get_avatar_src( $size = 80 ) {
}

if ( 1 === preg_match( '/src=([\'"])(.*?)\1/', $img, $matches ) ) {
$src = html_entity_decode( $matches[2] );
$src = html_entity_decode( $matches[2], ENT_COMPAT );
} else {
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions classes/class-filter-input.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ class Filter_Input {
* @var array
*/
public static $filter_callbacks = array(
FILTER_DEFAULT => null,
FILTER_DEFAULT => null,
// Validate.
FILTER_VALIDATE_BOOLEAN => 'is_bool',
FILTER_VALIDATE_EMAIL => 'is_email',
FILTER_VALIDATE_FLOAT => 'is_float',
FILTER_VALIDATE_INT => 'is_int',
FILTER_VALIDATE_IP => array( __CLASS__, 'is_ip_address' ),
FILTER_VALIDATE_REGEXP => array( __CLASS__, 'is_regex' ),
FILTER_VALIDATE_URL => 'wp_http_validate_url',
FILTER_VALIDATE_BOOLEAN => 'is_bool',
FILTER_VALIDATE_EMAIL => 'is_email',
FILTER_VALIDATE_FLOAT => 'is_float',
FILTER_VALIDATE_INT => 'is_int',
FILTER_VALIDATE_IP => array( __CLASS__, 'is_ip_address' ),
FILTER_VALIDATE_REGEXP => array( __CLASS__, 'is_regex' ),
FILTER_VALIDATE_URL => 'wp_http_validate_url',
// Sanitize.
FILTER_SANITIZE_EMAIL => 'sanitize_email',
FILTER_SANITIZE_ENCODED => 'esc_url_raw',
FILTER_SANITIZE_NUMBER_FLOAT => 'floatval',
FILTER_SANITIZE_NUMBER_INT => 'intval',
FILTER_SANITIZE_SPECIAL_CHARS => 'htmlspecialchars',
FILTER_SANITIZE_STRING => 'sanitize_text_field',
FILTER_SANITIZE_URL => 'esc_url_raw',
FILTER_SANITIZE_EMAIL => 'sanitize_email',
FILTER_SANITIZE_ENCODED => 'esc_url_raw',
FILTER_SANITIZE_NUMBER_FLOAT => 'floatval',
FILTER_SANITIZE_NUMBER_INT => 'intval',
FILTER_SANITIZE_SPECIAL_CHARS => 'htmlspecialchars',
FILTER_SANITIZE_FULL_SPECIAL_CHARS => 'sanitize_text_field',
FILTER_SANITIZE_URL => 'esc_url_raw',
// Other.
FILTER_UNSAFE_RAW => null,
FILTER_UNSAFE_RAW => null,
);

/**
Expand Down
6 changes: 3 additions & 3 deletions classes/class-live-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public function enable_live_update() {
check_ajax_referer( $this->user_meta_key . '_nonce', 'nonce' );

$input = array(
'checked' => FILTER_SANITIZE_STRING,
'user' => FILTER_SANITIZE_STRING,
'heartbeat' => FILTER_SANITIZE_STRING,
'checked' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'user' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'heartbeat' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
);

$input = filter_input_array( INPUT_POST, $input );
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
},
"require-dev": {
"automattic/vipwpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"humanmade/mercator": "^1.0",
"johnpbloch/wordpress": "^6.0",
"johnpbloch/wordpress": "^6.2",
"php-coveralls/php-coveralls": "^2.5",
"phpcompatibility/php-compatibility": "^9.3",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^5.7",
"wp-cli/wp-cli-bundle": "^2.6",
"wp-coding-standards/wpcs": "^2.3",
"wp-phpunit/wp-phpunit": "^6.0",
"wp-phpunit/wp-phpunit": "^6.2",
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "2.9.23",
"wpackagist-plugin/jetpack": "10.0",
Expand All @@ -34,7 +36,7 @@
"process-timeout": 600,
"sort-packages": true,
"platform": {
"php": "5.6.20"
"php": "7.4"
},
"allow-plugins": {
"composer/installers": true,
Expand Down