Skip to content

Commit

Permalink
Merge pull request #1218 from xwp/release/3.6.1
Browse files Browse the repository at this point in the history
Release 3.6.1
  • Loading branch information
kasparsd authored Feb 11, 2021
2 parents 88b7840 + 36080f1 commit 58e2e57
Show file tree
Hide file tree
Showing 37 changed files with 3,745 additions and 1,433 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.idea
.DS_Store
/node_modules/
Expand Down
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ jobs:

- stage: test
name: Default Test
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
after_script:
- test -f ./tests/reports/clover.xml && composer test-report || true
- ./cc-test-reporter format-coverage --input-type clover tests/reports/clover.xml --output tests/reports/codeclimate.json
- ./cc-test-reporter upload-coverage --input tests/reports/codeclimate.json

- name: Test with PHP 5.6
env:
Expand Down Expand Up @@ -61,6 +67,8 @@ before_install:
- docker-compose pull wordpress
- nvm install
- nvm use
# Lock to Composer version 1 for now.
- composer self-update --1

install:
- npm install
Expand Down
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"type": "php",
"request": "launch",
"port": 9000,
"ignore": [
"vendor/"
],
"pathMappings": {
"/var/www/html/wp-content/plugins/stream-src": "${workspaceRoot}",
"/var/www/html/wp-content/plugins/stream": "${workspaceRoot}/build",
Expand Down
7 changes: 4 additions & 3 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function __construct( $plugin ) {
add_filter( 'role_has_cap', array( $this, 'filter_role_caps' ), 10, 3 );

if ( is_multisite() && $plugin->is_network_activated() && ! is_network_admin() ) {
$options = (array) get_site_option( 'wp_stream_network', array() );
$options = (array) get_site_option( 'wp_stream_network', $plugin->settings->get_defaults() );
$option = isset( $options['general_site_access'] ) ? absint( $options['general_site_access'] ) : 1;

$this->disable_access = ( $option ) ? false : true;
Expand Down Expand Up @@ -746,10 +746,11 @@ public function purge_scheduled_action() {
return;
}

$defaults = $this->plugin->settings->get_defaults();
if ( is_multisite() && $this->plugin->is_network_activated() ) {
$options = (array) get_site_option( 'wp_stream_network', array() );
$options = (array) get_site_option( 'wp_stream_network', $defaults );
} else {
$options = (array) get_option( 'wp_stream', array() );
$options = (array) get_option( 'wp_stream', $defaults );
}

if ( ! empty( $options['general_keep_records_indefinitely'] ) || ! isset( $options['general_records_ttl'] ) ) {
Expand Down
87 changes: 0 additions & 87 deletions classes/class-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ public function __construct( $plugin ) {
$this->db_version = $this->get_db_version();
$this->stream_url = self_admin_url( $this->plugin->admin->admin_parent_page . '&page=' . $this->plugin->admin->settings_page_slug );

// Check DB and display an admin notice if there are tables missing.
add_action( 'init', array( $this, 'verify_db' ) );

// Install the plugin.
add_action( 'wp_stream_before_db_notices', array( $this, 'check' ) );

register_activation_hook( $this->plugin->locations['plugin'], array( $this, 'check' ) );
}

Expand Down Expand Up @@ -137,87 +131,6 @@ public function check() {
$this->update_db_option();
}

/**
* Verify that the required DB tables exists
*
* @return void
*/
public function verify_db() {
/**
* Filter will halt install() if set to true
*
* @param bool
*
* @return bool
*/
if ( apply_filters( 'wp_stream_no_tables', false ) ) {
return;
}

if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}

/**
* Fires before admin notices are triggered for missing database tables.
*/
do_action( 'wp_stream_before_db_notices' );

global $wpdb;

$database_message = '';
$uninstall_message = '';

// Check if all needed DB is present.
$missing_tables = array();

foreach ( $this->plugin->db->get_table_names() as $table_name ) {
$table_search = $wpdb->get_var(
$wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name )
);
if ( $table_search !== $table_name ) {
$missing_tables[] = $table_name;
}
}

if ( $missing_tables ) {
$database_message .= sprintf(
'%s <strong>%s</strong>',
_n(
'The following table is not present in the WordPress database:',
'The following tables are not present in the WordPress database:',
count( $missing_tables ),
'stream'
),
esc_html( implode( ', ', $missing_tables ) )
);
}

if ( $this->plugin->is_network_activated() && current_user_can( 'manage_network_plugins' ) ) {
$uninstall_message = sprintf(
/* translators: %#$s: HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">") */
__( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
'<a href="' . network_admin_url( 'plugins.php#stream' ) . '">',
'</a>'
);
} elseif ( current_user_can( 'activate_plugins' ) ) {
$uninstall_message = sprintf(
/* translators: %#$s: HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">") */
__( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
'<a href="' . admin_url( 'plugins.php#stream' ) . '">',
'</a>'
);
}

if ( ! empty( $database_message ) ) {
$this->plugin->admin->notice( $database_message );

if ( ! empty( $uninstall_message ) ) {
$this->plugin->admin->notice( $uninstall_message );
}
}
}

/**
* Register a routine to be called when stream or a stream connector has been updated
* It works by comparing the current version with the version previously stored in the database.
Expand Down
18 changes: 9 additions & 9 deletions classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,11 @@ public function column_default( $item, $column_name ) {
* Registers new Columns to be inserted into the table. The cell contents of this column is set
* below with 'wp_stream_insert_column_default_'
*
* @param array $new_columns Columns injected in the table.
*
* @return array
*/
$new_columns = array();
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns );
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', array() );

if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
foreach ( $inserted_columns as $column_title ) {
Expand All @@ -404,21 +405,20 @@ public function column_default( $item, $column_name ) {
* Also, note that the action name must include the $column_title registered
* with wp_stream_register_column_defaults
*/
if ( $column_title === $column_name && has_filter( "wp_stream_insert_column_default_{$column_title}" ) ) {
if ( $column_title === $column_name ) {
/**
* Allows for the addition of content under a specified column.
*
* @param object $record Contents of the row
* @param string $out Column content.
* @param object $record Record with row content.
* @param string $column_name Column name.
*
* @return string
*/
$out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $column_name, $record );
} else {
$out = $column_name;
$out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $out, $record, $column_name );
break;
}
}
} else {
$out = $column_name;
}
}

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.6.0';
const VERSION = '3.6.1';

/**
* WP-CLI command
Expand Down
25 changes: 21 additions & 4 deletions classes/class-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function query( $args ) {
/**
* BUILD THE FINAL QUERY
*/
$query = "SELECT SQL_CALC_FOUND_ROWS {$select}
$query = "SELECT {$select}
FROM $wpdb->stream
{$join}
WHERE 1=1 {$where}
Expand All @@ -246,12 +246,29 @@ public function query( $args ) {
*/
$query = apply_filters( 'wp_stream_db_query', $query, $args );

$result = array();
// Build result count query.
$count_query = "SELECT COUNT(*) as found
FROM $wpdb->stream
{$join}
WHERE 1=1 {$where}";

/**
* Filter allows the result count query to be modified before execution.
*
* @param string $query
* @param array $args
*
* @return string
*/
$count_query = apply_filters( 'wp_stream_db_count_query', $count_query, $args );

/**
* QUERY THE DATABASE FOR RESULTS
*/
$result['items'] = $wpdb->get_results( $query ); // @codingStandardsIgnoreLine $query already prepared
$result['count'] = $result['items'] ? absint( $wpdb->get_var( 'SELECT FOUND_ROWS()' ) ) : 0;
$result = array(
'items' => $wpdb->get_results( $query ), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
'count' => absint( $wpdb->get_var( $count_query ) ), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
);

return $result;
}
Expand Down
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
"license": "GPL-2.0-or-later",
"repositories": [
{
"type":"composer",
"url":"https://wpackagist.org"
"type": "composer",
"url": "https://wpackagist.org"
}
],
"require": {
"composer/installers": "~1.0"
},
"require-dev": {
"johnpbloch/wordpress": "^5.4",
"automattic/vipwpcs": "^2.0.0",
"humanmade/mercator": "^1.0",
"johnpbloch/wordpress": "^5.4",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5.7",
"wp-cli/wp-cli-bundle": "^2.2",
"wp-coding-standards/wpcs": "^2.2",
"wp-phpunit/wp-phpunit": "^5.4",
"wpsh/local": "^0.2.3",
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "^2.9.23",
"wpackagist-plugin/user-switching": "^1.5.5"
"wpackagist-plugin/user-switching": "^1.5.5",
"wpsh/local": "^0.2.3"
},
"config": {
"process-timeout": 600,
Expand All @@ -36,7 +37,8 @@
"extra": {
"wordpress-install-dir": "local/public",
"installer-paths": {
"local/public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
"local/public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
"local/public/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"]
}
},
"scripts": {
Expand Down
Loading

0 comments on commit 58e2e57

Please sign in to comment.