Skip to content

Commit 58e2e57

Browse files
authored
Merge pull request #1218 from xwp/release/3.6.1
Release 3.6.1
2 parents 88b7840 + 36080f1 commit 58e2e57

37 files changed

+3745
-1433
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.env
12
.idea
23
.DS_Store
34
/node_modules/

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ jobs:
99

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

1521
- name: Test with PHP 5.6
1622
env:
@@ -61,6 +67,8 @@ before_install:
6167
- docker-compose pull wordpress
6268
- nvm install
6369
- nvm use
70+
# Lock to Composer version 1 for now.
71+
- composer self-update --1
6472

6573
install:
6674
- npm install

.vscode/launch.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"type": "php",
77
"request": "launch",
88
"port": 9000,
9+
"ignore": [
10+
"vendor/"
11+
],
912
"pathMappings": {
1013
"/var/www/html/wp-content/plugins/stream-src": "${workspaceRoot}",
1114
"/var/www/html/wp-content/plugins/stream": "${workspaceRoot}/build",

classes/class-admin.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function __construct( $plugin ) {
143143
add_filter( 'role_has_cap', array( $this, 'filter_role_caps' ), 10, 3 );
144144

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

149149
$this->disable_access = ( $option ) ? false : true;
@@ -746,10 +746,11 @@ public function purge_scheduled_action() {
746746
return;
747747
}
748748

749+
$defaults = $this->plugin->settings->get_defaults();
749750
if ( is_multisite() && $this->plugin->is_network_activated() ) {
750-
$options = (array) get_site_option( 'wp_stream_network', array() );
751+
$options = (array) get_site_option( 'wp_stream_network', $defaults );
751752
} else {
752-
$options = (array) get_option( 'wp_stream', array() );
753+
$options = (array) get_option( 'wp_stream', $defaults );
753754
}
754755

755756
if ( ! empty( $options['general_keep_records_indefinitely'] ) || ! isset( $options['general_records_ttl'] ) ) {

classes/class-install.php

-87
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ public function __construct( $plugin ) {
7171
$this->db_version = $this->get_db_version();
7272
$this->stream_url = self_admin_url( $this->plugin->admin->admin_parent_page . '&page=' . $this->plugin->admin->settings_page_slug );
7373

74-
// Check DB and display an admin notice if there are tables missing.
75-
add_action( 'init', array( $this, 'verify_db' ) );
76-
77-
// Install the plugin.
78-
add_action( 'wp_stream_before_db_notices', array( $this, 'check' ) );
79-
8074
register_activation_hook( $this->plugin->locations['plugin'], array( $this, 'check' ) );
8175
}
8276

@@ -137,87 +131,6 @@ public function check() {
137131
$this->update_db_option();
138132
}
139133

140-
/**
141-
* Verify that the required DB tables exists
142-
*
143-
* @return void
144-
*/
145-
public function verify_db() {
146-
/**
147-
* Filter will halt install() if set to true
148-
*
149-
* @param bool
150-
*
151-
* @return bool
152-
*/
153-
if ( apply_filters( 'wp_stream_no_tables', false ) ) {
154-
return;
155-
}
156-
157-
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
158-
require_once ABSPATH . '/wp-admin/includes/plugin.php';
159-
}
160-
161-
/**
162-
* Fires before admin notices are triggered for missing database tables.
163-
*/
164-
do_action( 'wp_stream_before_db_notices' );
165-
166-
global $wpdb;
167-
168-
$database_message = '';
169-
$uninstall_message = '';
170-
171-
// Check if all needed DB is present.
172-
$missing_tables = array();
173-
174-
foreach ( $this->plugin->db->get_table_names() as $table_name ) {
175-
$table_search = $wpdb->get_var(
176-
$wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name )
177-
);
178-
if ( $table_search !== $table_name ) {
179-
$missing_tables[] = $table_name;
180-
}
181-
}
182-
183-
if ( $missing_tables ) {
184-
$database_message .= sprintf(
185-
'%s <strong>%s</strong>',
186-
_n(
187-
'The following table is not present in the WordPress database:',
188-
'The following tables are not present in the WordPress database:',
189-
count( $missing_tables ),
190-
'stream'
191-
),
192-
esc_html( implode( ', ', $missing_tables ) )
193-
);
194-
}
195-
196-
if ( $this->plugin->is_network_activated() && current_user_can( 'manage_network_plugins' ) ) {
197-
$uninstall_message = sprintf(
198-
/* translators: %#$s: HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">") */
199-
__( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
200-
'<a href="' . network_admin_url( 'plugins.php#stream' ) . '">',
201-
'</a>'
202-
);
203-
} elseif ( current_user_can( 'activate_plugins' ) ) {
204-
$uninstall_message = sprintf(
205-
/* translators: %#$s: HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">") */
206-
__( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
207-
'<a href="' . admin_url( 'plugins.php#stream' ) . '">',
208-
'</a>'
209-
);
210-
}
211-
212-
if ( ! empty( $database_message ) ) {
213-
$this->plugin->admin->notice( $database_message );
214-
215-
if ( ! empty( $uninstall_message ) ) {
216-
$this->plugin->admin->notice( $uninstall_message );
217-
}
218-
}
219-
}
220-
221134
/**
222135
* Register a routine to be called when stream or a stream connector has been updated
223136
* It works by comparing the current version with the version previously stored in the database.

classes/class-list-table.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,11 @@ public function column_default( $item, $column_name ) {
389389
* Registers new Columns to be inserted into the table. The cell contents of this column is set
390390
* below with 'wp_stream_insert_column_default_'
391391
*
392+
* @param array $new_columns Columns injected in the table.
393+
*
392394
* @return array
393395
*/
394-
$new_columns = array();
395-
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns );
396+
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', array() );
396397

397398
if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
398399
foreach ( $inserted_columns as $column_title ) {
@@ -404,21 +405,20 @@ public function column_default( $item, $column_name ) {
404405
* Also, note that the action name must include the $column_title registered
405406
* with wp_stream_register_column_defaults
406407
*/
407-
if ( $column_title === $column_name && has_filter( "wp_stream_insert_column_default_{$column_title}" ) ) {
408+
if ( $column_title === $column_name ) {
408409
/**
409410
* Allows for the addition of content under a specified column.
410411
*
411-
* @param object $record Contents of the row
412+
* @param string $out Column content.
413+
* @param object $record Record with row content.
414+
* @param string $column_name Column name.
412415
*
413416
* @return string
414417
*/
415-
$out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $column_name, $record );
416-
} else {
417-
$out = $column_name;
418+
$out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $out, $record, $column_name );
419+
break;
418420
}
419421
}
420-
} else {
421-
$out = $column_name;
422422
}
423423
}
424424

classes/class-plugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Plugin {
1818
*
1919
* @const string
2020
*/
21-
const VERSION = '3.6.0';
21+
const VERSION = '3.6.1';
2222

2323
/**
2424
* WP-CLI command

classes/class-query.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function query( $args ) {
229229
/**
230230
* BUILD THE FINAL QUERY
231231
*/
232-
$query = "SELECT SQL_CALC_FOUND_ROWS {$select}
232+
$query = "SELECT {$select}
233233
FROM $wpdb->stream
234234
{$join}
235235
WHERE 1=1 {$where}
@@ -246,12 +246,29 @@ public function query( $args ) {
246246
*/
247247
$query = apply_filters( 'wp_stream_db_query', $query, $args );
248248

249-
$result = array();
249+
// Build result count query.
250+
$count_query = "SELECT COUNT(*) as found
251+
FROM $wpdb->stream
252+
{$join}
253+
WHERE 1=1 {$where}";
254+
255+
/**
256+
* Filter allows the result count query to be modified before execution.
257+
*
258+
* @param string $query
259+
* @param array $args
260+
*
261+
* @return string
262+
*/
263+
$count_query = apply_filters( 'wp_stream_db_count_query', $count_query, $args );
264+
250265
/**
251266
* QUERY THE DATABASE FOR RESULTS
252267
*/
253-
$result['items'] = $wpdb->get_results( $query ); // @codingStandardsIgnoreLine $query already prepared
254-
$result['count'] = $result['items'] ? absint( $wpdb->get_var( 'SELECT FOUND_ROWS()' ) ) : 0;
268+
$result = array(
269+
'items' => $wpdb->get_results( $query ), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
270+
'count' => absint( $wpdb->get_var( $count_query ) ), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
271+
);
255272

256273
return $result;
257274
}

composer.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,26 @@
66
"license": "GPL-2.0-or-later",
77
"repositories": [
88
{
9-
"type":"composer",
10-
"url":"https://wpackagist.org"
9+
"type": "composer",
10+
"url": "https://wpackagist.org"
1111
}
1212
],
1313
"require": {
1414
"composer/installers": "~1.0"
1515
},
1616
"require-dev": {
17-
"johnpbloch/wordpress": "^5.4",
1817
"automattic/vipwpcs": "^2.0.0",
18+
"humanmade/mercator": "^1.0",
19+
"johnpbloch/wordpress": "^5.4",
1920
"php-coveralls/php-coveralls": "^2.1",
2021
"phpunit/phpunit": "^5.7",
2122
"wp-cli/wp-cli-bundle": "^2.2",
2223
"wp-coding-standards/wpcs": "^2.2",
2324
"wp-phpunit/wp-phpunit": "^5.4",
24-
"wpsh/local": "^0.2.3",
2525
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
2626
"wpackagist-plugin/easy-digital-downloads": "^2.9.23",
27-
"wpackagist-plugin/user-switching": "^1.5.5"
27+
"wpackagist-plugin/user-switching": "^1.5.5",
28+
"wpsh/local": "^0.2.3"
2829
},
2930
"config": {
3031
"process-timeout": 600,
@@ -36,7 +37,8 @@
3637
"extra": {
3738
"wordpress-install-dir": "local/public",
3839
"installer-paths": {
39-
"local/public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
40+
"local/public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
41+
"local/public/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"]
4042
}
4143
},
4244
"scripts": {

0 commit comments

Comments
 (0)