PluginProbe
Stream – Activity Log & Audit Trail / 4.0.2
Stream – Activity Log & Audit Trail v4.0.2
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-cli.php +4 -11 trunk4.0.2 View file →
@@ -123,11 +123,9 @@
123 123
124 124 $query_args[ $key ] = $value;
125 125 }
126 126
127 - // Pass fields as an array so the query builder can validate each
128 - // column against its allowlist (column names cannot be prepared).
129 - $query_args['fields'] = $fields;
127 + $query_args['fields'] = implode( ',', $fields );
130 128
131 129 $records = wp_stream_get_instance()->db->query( $query_args );
132 130
133 131 // Make structure Formatter compatible.
@@ -210,9 +208,9 @@
210 208 private function csv_format( $records ) {
211 209 $output = fopen( 'php://output', 'w' ); // @codingStandardsIgnoreLine Clever output for WP CLI using php://output
212 210
213 211 foreach ( $records as $line ) {
214 - fputcsv( $output, $line, ',', '"', '\\' );
212 + fputcsv( $output, $line );
215 213 }
216 214
217 215 fclose( $output ); // @codingStandardsIgnoreLine
218 216 }
@@ -222,11 +220,9 @@
222 220 *
223 221 * @return void
224 222 */
225 223 private function connection() {
226 - global $wpdb;
227 -
228 - wp_stream_get_instance()->db->query(
224 + $query = wp_stream_get_instance()->db->query(
229 225 array(
230 226 'records_per_page' => 1,
231 227 'fields' => 'created',
232 228 )
@@ -231,12 +227,9 @@
231 227 'fields' => 'created',
232 228 )
233 229 );
234 230
235 - // An empty result set is valid (e.g. a fresh site with no logged
236 - // activity yet); only a genuine database error means the site is
237 - // disconnected.
238 - if ( ! empty( $wpdb->last_error ) ) {
231 + if ( ! $query ) {
239 232 \WP_CLI::error( esc_html__( 'SITE IS DISCONNECTED', 'stream' ) );
240 233 }
241 234 }
242 235 }