PluginProbe
Stream – Activity Log & Audit Trail / 3.2.3
Stream – Activity Log & Audit Trail v3.2.3
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.3, at includes/db-updates.php

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