PluginProbe
Stream – Activity Log & Audit Trail / 3.4.2
Stream – Activity Log & Audit Trail v3.4.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-install.php +69 -34 3.0.43.4.2 View file →
@@ -3,8 +3,9 @@
3 3
4 4 class Install {
5 5 /**
6 6 * Hold Plugin class
7 + *
7 8 * @var Plugin
8 9 */
9 10 public $plugin;
10 11
@@ -75,10 +76,8 @@
75 76 *
76 77 * @return void
77 78 */
78 79 public function check() {
79 - global $wpdb;
80 -
81 80 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
82 81 return;
83 82 }
84 83
@@ -83,9 +82,8 @@
83 82 }
84 83
85 84 if ( empty( $this->db_version ) ) {
86 85 $this->install( $this->plugin->get_version() );
87 -
88 86 return;
89 87 }
90 88
91 89 if ( $this->plugin->get_version() === $this->db_version ) {
@@ -91,22 +89,38 @@
91 89 if ( $this->plugin->get_version() === $this->db_version ) {
92 90 return;
93 91 }
94 92
95 - $update = isset( $_REQUEST['wp_stream_update'] ) ? $_REQUEST['wp_stream_update'] : null;
93 + $update = null;
94 + if ( isset( $_REQUEST['wp_stream_update'] ) && wp_verify_nonce( 'wp_stream_update_db' ) ) {
95 + $update = esc_attr( $_REQUEST['wp_stream_update'] );
96 + }
96 97
97 98 if ( ! $update ) {
98 99 $this->update_required = true;
99 - $this->success_db = $this->update( $this->db_version, $this->plugin->get_version(), array( 'type' => 'auto' ) );
100 - } elseif ( 'update_and_continue' === $update ) {
101 - $this->success_db = $this->update( $this->db_version, $this->plugin->get_version(), array( 'type' => 'user' ) );
100 + $this->success_db = $this->update(
101 + $this->db_version,
102 + $this->plugin->get_version(),
103 + array(
104 + 'type' => 'auto',
105 + )
106 + );
102 107 }
103 108
109 + if ( 'update_and_continue' === $update ) {
110 + $this->success_db = $this->update(
111 + $this->db_version,
112 + $this->plugin->get_version(),
113 + array(
114 + 'type' => 'user',
115 + )
116 + );
117 + }
118 +
104 119 $versions = $this->db_update_versions();
105 120
106 - if ( version_compare( end( $versions ), $this->db_version, '>' ) ) {
121 + if ( ! $this->success_db && version_compare( end( $versions ), $this->db_version, '>' ) ) {
107 122 add_action( 'all_admin_notices', array( $this, 'update_notice_hook' ) );
108 -
109 123 return;
110 124 }
111 125
112 126 $this->update_db_option();
@@ -129,9 +143,9 @@
129 143 return;
130 144 }
131 145
132 146 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
133 - require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
147 + require_once ABSPATH . '/wp-admin/includes/plugin.php';
134 148 }
135 149
136 150 /**
137 151 * Fires before admin notices are triggered for missing database tables.
@@ -167,12 +181,22 @@
167 181 esc_html( implode( ', ', $missing_tables ) )
168 182 );
169 183 }
170 184
171 - if ( is_plugin_active_for_network( $this->plugin->locations['plugin'] ) && current_user_can( 'manage_network_plugins' ) ) {
172 - $uninstall_message = sprintf( __( 'Please <a href="%s">uninstall</a> the Stream plugin and activate it again.', 'stream' ), network_admin_url( 'plugins.php#stream' ) );
185 + if ( $this->plugin->is_network_activated() && current_user_can( 'manage_network_plugins' ) ) {
186 + $uninstall_message = sprintf(
187 + // translators: Placeholders refer to HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">")
188 + __( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
189 + '<a href="' . network_admin_url( 'plugins.php#stream' ) . '">',
190 + '</a>'
191 + );
173 192 } elseif ( current_user_can( 'activate_plugins' ) ) {
174 - $uninstall_message = sprintf( __( 'Please <a href="%s">uninstall</a> the Stream plugin and activate it again.', 'stream' ), admin_url( 'plugins.php#stream' ) );
193 + $uninstall_message = sprintf(
194 + // translators: Placeholders refer to HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">")
195 + __( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
196 + '<a href="' . admin_url( 'plugins.php#stream' ) . '">',
197 + '</a>'
198 + );
175 199 }
176 200
177 201 if ( ! empty( $database_message ) ) {
178 202 $this->plugin->admin->notice( $database_message );
@@ -199,9 +223,9 @@
199 223 }
200 224
201 225 $plugin = plugin_basename( $file );
202 226
203 - if ( is_plugin_active_for_network( $plugin ) ) {
227 + if ( $this->plugin->is_network_activated() ) {
204 228 $current_versions = get_site_option( $this->option_key . '_connectors', array() );
205 229 $network = true;
206 230 } elseif ( is_plugin_active( $plugin ) ) {
207 231 $current_versions = get_option( $this->option_key . '_connectors', array() );
@@ -220,10 +244,8 @@
220 244 update_site_option( $this->option_key . '_registered_connectors', $current_versions );
221 245 } else {
222 246 update_option( $this->option_key . '_registered_connectors', $current_versions );
223 247 }
224 -
225 - return;
226 248 }
227 249
228 250 /**
229 251 * @return string
@@ -239,9 +261,9 @@
239 261 if ( $this->success_db ) {
240 262 $success_op = update_site_option( $this->option_key, $this->plugin->get_version() );
241 263 }
242 264
243 - if ( ! empty( $this->success_db ) && ! empty( $success_op ) ) {
265 + if ( ! empty( $this->success_db ) ) {
244 266 return;
245 267 }
246 268
247 269 wp_die(
@@ -265,9 +287,12 @@
265 287 if ( ! current_user_can( $this->plugin->admin->view_cap ) ) {
266 288 return;
267 289 }
268 290
269 - $update = isset( $_REQUEST['wp_stream_update'] ) ? $_REQUEST['wp_stream_update'] : null;
291 + $update = null;
292 + if ( isset( $_REQUEST['wp_stream_update'] ) && wp_verify_nonce( 'wp_stream_update_db' ) ) {
293 + $update = esc_attr( $_REQUEST['wp_stream_update'] );
294 + }
270 295
271 296 if ( ! $update ) {
272 297 $this->prompt_update();
273 298
@@ -289,15 +314,15 @@
289 314 */
290 315 public function prompt_update() {
291 316 ?>
292 317 <div class="error">
293 - <form method="post" action="<?php echo esc_url( remove_query_arg( 'wp_stream_update' ) ) ?>">
294 - <?php wp_nonce_field( 'wp_stream_update_db' ) ?>
318 + <form method="post" action="<?php echo esc_url( remove_query_arg( 'wp_stream_update' ) ); ?>">
319 + <?php wp_nonce_field( 'wp_stream_update_db' ); ?>
295 320 <input type="hidden" name="wp_stream_update" value="update_and_continue"/>
296 - <p><strong><?php esc_html_e( 'Stream Database Update Required', 'stream' ) ?></strong></p>
297 - <p><?php esc_html_e( 'Stream has updated! Before we send you on your way, we need to update your database to the newest version.', 'stream' ) ?></p>
298 - <p><?php esc_html_e( 'This process could take a little while, so please be patient.', 'stream' ) ?></p>
299 - <?php submit_button( esc_html__( 'Update Database', 'stream' ), 'primary', 'stream-update-db-submit' ) ?>
321 + <p><strong><?php esc_html_e( 'Stream Database Update Required', 'stream' ); ?></strong></p>
322 + <p><?php esc_html_e( 'Stream has updated! Before we send you on your way, we need to update your database to the newest version.', 'stream' ); ?></p>
323 + <p><?php esc_html_e( 'This process could take a little while, so please be patient.', 'stream' ); ?></p>
324 + <?php submit_button( esc_html__( 'Update Database', 'stream' ), 'primary', 'stream-update-db-submit' ); ?>
300 325 </form>
301 326 </div>
302 327 <?php
303 328 }
@@ -313,12 +338,21 @@
313 338
314 339 $this->update_db_option();
315 340 ?>
316 341 <div class="updated">
317 - <form method="post" action="<?php echo esc_url( remove_query_arg( 'wp_stream_update' ) ) ?>" style="display:inline;">
318 - <p><strong><?php esc_html_e( 'Update Complete', 'stream' ) ?></strong></p>
319 - <p><?php esc_html_e( sprintf( 'Your Stream database has been successfully updated from %1$s to %2$s!', esc_html( $this->db_version ), esc_html( $this->plugin->get_version() ) ), 'stream' ) ?></p>
320 - <?php submit_button( esc_html__( 'Continue', 'stream' ), 'secondary', false ) ?>
342 + <form method="post" action="<?php echo esc_url( remove_query_arg( 'wp_stream_update' ) ); ?>" style="display:inline;">
343 + <p><strong><?php esc_html_e( 'Update Complete', 'stream' ); ?></strong></p>
344 + <p>
345 + <?php
346 + printf(
347 + // translators: Placeholders refer to version numbers (e.g. "4.2")
348 + esc_html__( 'Your Stream database has been successfully updated from %1$s to %2$s!', 'stream' ),
349 + esc_html( $this->db_version ),
350 + esc_html( $this->plugin->get_version() )
351 + );
352 + ?>
353 + </p>
354 + <?php submit_button( esc_html__( 'Continue', 'stream' ), 'secondary', false ); ?>
321 355 </form>
322 356 </div>
323 357 <?php
324 358 }
@@ -334,10 +368,11 @@
334 368 * @return array
335 369 */
336 370 public function db_update_versions() {
337 371 $db_update_versions = array(
338 - '3.0.0' /* @version 3.0.0 Drop the stream_context table, changes to stream table */,
339 - '3.0.2' /* @version 3.0.2 Fix uppercase values in stream table, connector column */,
372 + '3.0.0', /* @version 3.0.0 Drop the stream_context table, changes to stream table */
373 + '3.0.2', /* @version 3.0.2 Fix uppercase values in stream table, connector column */
374 + '3.0.8', /* @version 3.0.8 Increase size of user role IDs, user_roll column */
340 375 );
341 376
342 377 /**
343 378 * Filter to alter the DB update versions array
@@ -359,9 +394,9 @@
359 394 * @return mixed Version number on success, true on no update needed, mysql error message on error
360 395 */
361 396 public function update( $db_version, $current_version, $update_args ) {
362 397 $versions = $this->db_update_versions();
363 - include_once( $this->plugin->locations['inc_dir'] . 'db-updates.php' );
398 + include_once $this->plugin->locations['inc_dir'] . 'db-updates.php';
364 399
365 400 foreach ( $versions as $version ) {
366 401 if ( ! isset( $update_args['type'] ) ) {
367 402 $update_args['type'] = 'user';
@@ -398,9 +433,9 @@
398 433 site_id bigint(20) unsigned NOT NULL DEFAULT '1',
399 434 blog_id bigint(20) unsigned NOT NULL DEFAULT '1',
400 435 object_id bigint(20) unsigned NULL,
401 436 user_id bigint(20) unsigned NOT NULL DEFAULT '0',
402 - user_role varchar(20) NOT NULL DEFAULT '',
437 + user_role varchar(50) NOT NULL DEFAULT '',
403 438 summary longtext NOT NULL,
404 439 created datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
405 440 connector varchar(100) NOT NULL,
406 441 context varchar(100) NOT NULL,
@@ -447,10 +482,10 @@
447 482 meta_key varchar(200) NOT NULL,
448 483 meta_value varchar(200) NOT NULL,
449 484 PRIMARY KEY (meta_id),
450 485 KEY record_id (record_id),
451 - KEY meta_key (meta_key),
452 - KEY meta_value (meta_value)
486 + KEY meta_key (meta_key(191)),
487 + KEY meta_value (meta_value(191))
453 488 )";
454 489
455 490 if ( ! empty( $wpdb->charset ) ) {
456 491 $sql .= " CHARACTER SET $wpdb->charset";