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
stream / includes / db-updates.php

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

119 lines 3.0 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(
36 $wpdb->base_prefix . 'stream',
37 array(
38 'connector' => $connector->name,
39 ),
40 array(
41 'ID' => $entry->ID,
42 )
43 );
44 } else {
45 $wpdb->update(
46 $wpdb->base_prefix . 'stream',
47 array(
48 'connector' => strtolower( $entry->connector ),
49 ),
50 array(
51 'ID' => $entry->ID,
52 )
53 );
54 }
55 }
56
57 return $current_version;
58 }
59
60 /**
61 * Version 3.0.0
62 *
63 * Update from 1.4.9
64 *
65 * @param string $db_version
66 * @param string $current_version
67 *
68 * @return string
69 */
70 function wp_stream_update_auto_300( $db_version, $current_version ) {
71 global $wpdb;
72
73 // Get only the author_meta values that are double-serialized
74 $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" );
75
76 $plugin = wp_stream_get_instance();
77 $plugin->install->install( $current_version );
78
79 $starting_row = 0;
80 $rows_per_round = 5000;
81
82 $stream_entries = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_tmp LIMIT %d, %d", $starting_row, $rows_per_round ) );
83
84 while ( ! empty( $stream_entries ) ) {
85 foreach ( $stream_entries as $entry ) {
86 $context = $wpdb->get_row(
87 $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
88 );
89
90 $new_entry = array(
91 'site_id' => $entry->site_id,
92 'blog_id' => $entry->blog_id,
93 'user_id' => $entry->author,
94 'user_role' => $entry->author_role,
95 'summary' => $entry->summary,
96 'created' => $entry->created,
97 'connector' => $context->connector,
98 'context' => $context->context,
99 'action' => $context->action,
100 'ip' => $entry->ip,
101 );
102
103 if ( $entry->object_id && 0 !== $entry->object_id ) {
104 $new_entry['object_id'] = $entry->object_id;
105 }
106
107 $wpdb->insert( $wpdb->base_prefix . 'stream', $new_entry );
108 }
109
110 $starting_row += $rows_per_round;
111
112 $stream_entries = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}stream_tmp LIMIT %d, %d", $starting_row, $rows_per_round ) );
113 }
114
115 $wpdb->query( "DROP TABLE {$wpdb->base_prefix}stream_tmp, {$wpdb->base_prefix}stream_context_tmp" );
116
117 return $current_version;
118 }
119