PluginProbe
Stream – Activity Log & Audit Trail / 3.2.0
Stream – Activity Log & Audit Trail v3.2.0
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
stream / includes / db-updates.php

db-updates.php in Stream – Activity Log & Audit Trail 3.2.0, at includes/db-updates.php

103 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Version 3.0.8
4 *
5 * Force update for older versions to call \dbdelta in install() method to fix column widths.
6 *
7 * @param string $db_version
8 * @param string $current_version
9 *
10 * @return string
11 */
12 function wp_stream_update_auto_308( $db_version, $current_version ) {
13 $plugin = wp_stream_get_instance();
14 $plugin->install->install( $current_version );
15
16 return $current_version;
17 }
18
19 /**
20 * Version 3.0.2
21 *
22 * @param string $db_version
23 * @param string $current_version
24 *
25 * @return string
26 */
27 function wp_stream_update_302( $db_version, $current_version ) {
28 global $wpdb;
29
30 $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}stream" );
31 foreach ( $stream_entries as $entry ) {
32 $class = 'Connector_' . $entry->context;
33 if ( class_exists( $class ) ) {
34 $connector = new $class();
35 $wpdb->update( $wpdb->base_prefix . 'stream', array( 'connector' => $connector->name ), array( 'ID' => $entry->ID ) );
36 } else {
37 $wpdb->update( $wpdb->base_prefix . 'stream', array( 'connector' => strtolower( $entry->connector ) ), array( 'ID' => $entry->ID ) );
38 }
39 }
40
41 return $current_version;
42 }
43
44 /**
45 * Version 3.0.0
46 *
47 * Update from 1.4.9
48 *
49 * @param string $db_version
50 * @param string $current_version
51 *
52 * @return string
53 */
54 function wp_stream_update_auto_300( $db_version, $current_version ) {
55 global $wpdb;
56
57 // Get only the author_meta values that are double-serialized
58 $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}stream TO {$wpdb->base_prefix}stream_tmp, {$wpdb->base_prefix}stream_context TO {$wpdb->base_prefix}stream_context_tmp" );
59
60 $plugin = wp_stream_get_instance();
61 $plugin->install->install( $current_version );
62
63 $starting_row = 0;
64 $rows_per_round = 5000;
65
66 $stream_entries = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_tmp LIMIT %d, %d", $starting_row, $rows_per_round ) );
67
68 while ( ! empty( $stream_entries ) ) {
69 foreach ( $stream_entries as $entry ) {
70 $context = $wpdb->get_row(
71 $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
72 );
73
74 $new_entry = array(
75 'site_id' => $entry->site_id,
76 'blog_id' => $entry->blog_id,
77 'user_id' => $entry->author,
78 'user_role' => $entry->author_role,
79 'summary' => $entry->summary,
80 'created' => $entry->created,
81 'connector' => $context->connector,
82 'context' => $context->context,
83 'action' => $context->action,
84 'ip' => $entry->ip,
85 );
86
87 if ( $entry->object_id && 0 !== $entry->object_id ) {
88 $new_entry['object_id'] = $entry->object_id;
89 }
90
91 $wpdb->insert( $wpdb->base_prefix . 'stream', $new_entry );
92 }
93
94 $starting_row += $rows_per_round;
95
96 $stream_entries = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_tmp LIMIT %d, %d", $starting_row, $rows_per_round ) );
97 }
98
99 $wpdb->query( "DROP TABLE {$wpdb->base_prefix}stream_tmp, {$wpdb->base_prefix}stream_context_tmp" );
100
101 return $current_version;
102 }
103