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

Release 3.8.0 #1280

Merged
merged 10 commits into from
Aug 31, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ jobs:
env:
WORDPRESS_IMAGE_VERSION: php5.6

- name: Test with PHP 7.2
- name: Test with PHP 7.4
env:
WORDPRESS_IMAGE_VERSION: php7.2
WORDPRESS_IMAGE_VERSION: php7.4

- name: Test with PHP 8.0
env:
WORDPRESS_IMAGE_VERSION: php8.0
# PHP unit tests are broken so we limit to linting for now.
script: npm run lint

- name: Test Release Bundle
script: npm run release
Expand Down
6 changes: 3 additions & 3 deletions alerts/class-alert-trigger-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ public function get_terms_labels( $column ) {
*
* @see Alert_Trigger::get_display_value().
*
* @param string $context The location this data will be displayed in.
* @param Alert $alert Alert being processed.
* @param string $context The location this data will be displayed in.
* @param Alert|null $alert Alert being processed.
*
* @return string
*/
public function get_display_value( $context = 'normal', $alert ) {
public function get_display_value( $context = 'normal', $alert = null ) {
$action = ( ! empty( $alert->alert_meta['trigger_action'] ) ) ? $alert->alert_meta['trigger_action'] : null;

if ( 'post_title' === $context ) {
Expand Down
6 changes: 3 additions & 3 deletions alerts/class-alert-trigger-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ public function save_fields( $alert ) {
*
* @see Alert_Trigger::get_display_value().
*
* @param string $context The location this data will be displayed in.
* @param Alert $alert Alert being processed.
* @param string $context The location this data will be displayed in.
* @param Alert|null $alert Alert being processed.
*
* @return string
*/
public function get_display_value( $context = 'normal', $alert ) {
public function get_display_value( $context = 'normal', $alert = null ) {
$author = ( ! empty( $alert->alert_meta['trigger_author'] ) ) ? $alert->alert_meta['trigger_author'] : null;
if ( empty( $author ) ) {
$author = __( 'Any User', 'stream' );
Expand Down
6 changes: 3 additions & 3 deletions alerts/class-alert-trigger-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ public function get_terms_labels( $column ) {
*
* @see Alert_Trigger::get_display_value().
*
* @param string $context The location this data will be displayed in.
* @param Alert $alert Alert being processed.
* @param string $context The location this data will be displayed in.
* @param Alert|null $alert Alert being processed.
*
* @return string
*/
public function get_display_value( $context = 'normal', $alert ) {
public function get_display_value( $context = 'normal', $alert = null ) {
$context = ( ! empty( $alert->alert_meta['trigger_context'] ) ) ? $alert->alert_meta['trigger_context'] : null;
$connector = ( ! empty( $alert->alert_meta['trigger_connector'] ) ) ? $alert->alert_meta['trigger_connector'] : null;
if ( empty( $context ) && empty( $connector ) ) {
Expand Down
6 changes: 3 additions & 3 deletions classes/class-alert-trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ abstract public function save_fields( $alert );
/**
* Returns the trigger's value for the given alert.
*
* @param string $context The location this data will be displayed in.
* @param Alert $alert Alert being processed.
* @param string $context The location this data will be displayed in.
* @param Alert|null $alert Alert being processed.
* @return string
*/
abstract public function get_display_value( $context = 'normal', $alert );
abstract public function get_display_value( $context = 'normal', $alert = null );

/**
* Allow connectors to determine if their dependencies is satisfied or not
Expand Down
7 changes: 5 additions & 2 deletions classes/class-db-driver-wpdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ public function insert_record( $data ) {
return false;
}

$meta = $data['meta'];
unset( $data['meta'] );
$meta = array();
if ( array_key_exists( 'meta', $data ) ) {
$meta = $data['meta'];
unset( $data['meta'] );
}

$result = $wpdb->insert( $this->table, $data );
if ( ! $result ) {
Expand Down
58 changes: 45 additions & 13 deletions classes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,11 @@ public function insert( $record ) {
*/
$record = apply_filters( 'wp_stream_record_array', $record );

array_walk(
$record,
function( &$value, &$key ) {
if ( ! is_array( $value ) ) {
$value = wp_strip_all_tags( $value );
}
}
);

if ( empty( $record ) ) {
$data = $this->sanitize_record( $record );
if ( empty( $data ) ) {
return false;
}

$fields = array( 'object_id', 'site_id', 'blog_id', 'user_id', 'user_role', 'created', 'summary', 'ip', 'connector', 'context', 'action', 'meta' );
$data = array_intersect_key( $record, array_flip( $fields ) );

$record_id = $this->driver->insert_record( $data );

if ( ! $record_id ) {
Expand All @@ -96,6 +85,49 @@ function( &$value, &$key ) {
return absint( $record_id );
}

/**
* Ensure the record matches our schema.
*
* @param array $record Record to store.
*
* @return array
*/
protected function sanitize_record( $record ) {
if ( ! is_array( $record ) ) {
return array();
}

$record_defaults = array(
'object_id' => null,
'site_id' => null,
'blog_id' => null,
'user_id' => null,
'user_role' => null,
'created' => null,
'summary' => null,
'ip' => null,
'connector' => null,
'context' => null,
'action' => null,
'meta' => array(),
);

// Records can have only these fields.
$record = array_intersect_key( $record, $record_defaults );

// Sanitize all record values.
return array_map(
function( $value ) {
if ( ! is_array( $value ) ) {
return wp_strip_all_tags( $value );
}

return $value;
},
$record
);
}

/**
* Returns array of existing values for requested column.
* Used to fill search filters with only used items, instead of all items.
Expand Down
2 changes: 1 addition & 1 deletion classes/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Plugin {
*
* @const string
*/
const VERSION = '3.7.0';
const VERSION = '3.8.0';

/**
* WP-CLI command
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
"require-dev": {
"automattic/vipwpcs": "^2.0.0",
"humanmade/mercator": "^1.0",
"johnpbloch/wordpress": "^5.4",
"johnpbloch/wordpress": "^5.8",
"php-coveralls/php-coveralls": "^2.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^5.7",
"wp-cli/wp-cli-bundle": "^2.2",
"wp-coding-standards/wpcs": "^2.2",
"wp-cli/wp-cli-bundle": "^2.5",
"wp-coding-standards/wpcs": "^2.3",
"wp-phpunit/wp-phpunit": "^5.4",
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "^2.9.23",
"wpackagist-plugin/jetpack": "^8.7",
"wpackagist-plugin/user-switching": "^1.5.5",
"wpackagist-plugin/easy-digital-downloads": "2.9.23",
"wpackagist-plugin/jetpack": "10.0",
"wpackagist-plugin/user-switching": "1.5.5",
"wpsh/local": "^0.2.3"
},
"config": {
Expand Down
Loading