PluginProbe
Stream – Activity Log & Audit Trail / 3.6.1
Stream – Activity Log & Audit Trail v3.6.1
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 | includes/db-updates.php +75 -27 3.0.33.6.1 View file →
@@ -1,10 +1,33 @@
1 1 <?php
2 2 /**
3 + * Defines DB migrations.
4 + *
5 + * @package WP_Stream
6 + */
7 +
8 +/**
9 + * Version 3.0.8
10 + *
11 + * Force update for older versions to call \dbdelta in install() method to fix column widths.
12 + *
13 + * @param string $db_version New database version.
14 + * @param string $current_version Current database version.
15 + *
16 + * @return string
17 + */
18 +function wp_stream_update_auto_308( $db_version, $current_version ) {
19 + $plugin = wp_stream_get_instance();
20 + $plugin->install->install( $current_version );
21 +
22 + return $current_version;
23 +}
24 +
25 +/**
3 26 * Version 3.0.2
4 27 *
5 - * @param string $db_version
6 - * @param string $current_version
28 + * @param string $db_version New database version.
29 + * @param string $current_version Current database version.
7 30 *
8 31 * @return string
9 32 */
10 33 function wp_stream_update_302( $db_version, $current_version ) {
@@ -14,11 +37,27 @@
14 37 foreach ( $stream_entries as $entry ) {
15 38 $class = 'Connector_' . $entry->context;
16 39 if ( class_exists( $class ) ) {
17 40 $connector = new $class();
18 - $wpdb->update( $wpdb->base_prefix . 'stream', array( 'connector' => $connector->name ), array( 'ID' => $entry->ID ) );
41 + $wpdb->update(
42 + $wpdb->base_prefix . 'stream',
43 + array(
44 + 'connector' => $connector->name,
45 + ),
46 + array(
47 + 'ID' => $entry->ID,
48 + )
49 + );
19 50 } else {
20 - $wpdb->update( $wpdb->base_prefix . 'stream', array( 'connector' => strtolower( $entry->connector ) ), array( 'ID' => $entry->ID ) );
51 + $wpdb->update(
52 + $wpdb->base_prefix . 'stream',
53 + array(
54 + 'connector' => strtolower( $entry->connector ),
55 + ),
56 + array(
57 + 'ID' => $entry->ID,
58 + )
59 + );
21 60 }
22 61 }
23 62
24 63 return $current_version;
@@ -28,10 +67,10 @@
28 67 * Version 3.0.0
29 68 *
30 69 * Update from 1.4.9
31 70 *
32 - * @param string $db_version
33 - * @param string $current_version
71 + * @param string $db_version New database version.
72 + * @param string $current_version Current database version.
34 73 *
35 74 * @return string
36 75 */
37 76 function wp_stream_update_auto_300( $db_version, $current_version ) {
@@ -36,39 +75,48 @@
36 75 */
37 76 function wp_stream_update_auto_300( $db_version, $current_version ) {
38 77 global $wpdb;
39 78
40 - // Get only the author_meta values that are double-serialized
79 + // Get only the author_meta values that are double-serialized.
41 80 $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" );
42 81
43 82 $plugin = wp_stream_get_instance();
44 83 $plugin->install->install( $current_version );
45 84
46 - $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}stream_tmp" );
85 + $starting_row = 0;
86 + $rows_per_round = 5000;
47 87
48 - foreach ( $stream_entries as $entry ) {
49 - $context = $wpdb->get_row(
50 - $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
51 - );
88 + $stream_entries = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_tmp LIMIT %d, %d", $starting_row, $rows_per_round ) );
52 89
53 - $new_entry = array(
54 - 'site_id' => $entry->site_id,
55 - 'blog_id' => $entry->blog_id,
56 - 'user_id' => $entry->author,
57 - 'user_role' => $entry->author_role,
58 - 'summary' => $entry->summary,
59 - 'created' => $entry->created,
60 - 'connector' => $context->connector,
61 - 'context' => $context->context,
62 - 'action' => $context->action,
63 - 'ip' => $entry->ip,
64 - );
90 + while ( ! empty( $stream_entries ) ) {
91 + foreach ( $stream_entries as $entry ) {
92 + $context = $wpdb->get_row(
93 + $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
94 + );
65 95
66 - if ( $entry->object_id && 0 !== $entry->object_id ) {
67 - $new_entry['object_id'] = $entry->object_id;
96 + $new_entry = array(
97 + 'site_id' => $entry->site_id,
98 + 'blog_id' => $entry->blog_id,
99 + 'user_id' => $entry->author,
100 + 'user_role' => $entry->author_role,
101 + 'summary' => $entry->summary,
102 + 'created' => $entry->created,
103 + 'connector' => $context->connector,
104 + 'context' => $context->context,
105 + 'action' => $context->action,
106 + 'ip' => $entry->ip,
107 + );
108 +
109 + if ( $entry->object_id && 0 !== $entry->object_id ) {
110 + $new_entry['object_id'] = $entry->object_id;
111 + }
112 +
113 + $wpdb->insert( $wpdb->base_prefix . 'stream', $new_entry );
68 114 }
69 115
70 - $wpdb->insert( $wpdb->base_prefix . 'stream', $new_entry );
116 + $starting_row += $rows_per_round;
117 +
118 + $stream_entries = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_tmp LIMIT %d, %d", $starting_row, $rows_per_round ) );
71 119 }
72 120
73 121 $wpdb->query( "DROP TABLE {$wpdb->base_prefix}stream_tmp, {$wpdb->base_prefix}stream_context_tmp" );
74 122