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

80 lines 2.1 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.2
4 *
5 * @param string $db_version
6 * @param string $current_version
7 *
8 * @return string
9 */
10 function wp_stream_update_302( $db_version, $current_version ) {
11 global $wpdb;
12
13 $plugin = wp_stream_get_instance();
14 $prefix = $plugin->install->table_prefix;
15
16 $stream_entries = $wpdb->get_results( "SELECT * FROM {$prefix}stream" );
17 foreach ( $stream_entries as $entry ) {
18 $class = 'Connector_' . $entry->context;
19 if ( class_exists( $class ) ) {
20 $connector = new $class();
21 $wpdb->update( $prefix . 'stream', array( 'connector' => $connector->name ), array( 'ID' => $entry->ID ) );
22 } else {
23 $wpdb->update( $prefix . 'stream', array( 'connector' => strtolower( $entry->connector ) ), array( 'ID' => $entry->ID ) );
24 }
25 }
26
27 return $current_version;
28 }
29
30 /**
31 * Version 3.0.0
32 *
33 * Update from 1.4.9
34 *
35 * @param string $db_version
36 * @param string $current_version
37 *
38 * @return string
39 */
40 function wp_stream_update_auto_300( $db_version, $current_version ) {
41 global $wpdb;
42
43 // Get only the author_meta values that are double-serialized
44 $plugin = wp_stream_get_instance();
45 $prefix = $plugin->install->table_prefix;
46
47 $wpdb->query( "RENAME TABLE {$prefix}stream TO {$prefix}stream_tmp, {$prefix}stream_context TO {$prefix}stream_context_tmp" );
48
49 $plugin->install->install( $current_version );
50
51 $stream_entries = $wpdb->get_results( "SELECT * FROM {$prefix}stream_tmp" );
52
53 foreach ( $stream_entries as $entry ) {
54 $context = $wpdb->get_row( "SELECT * FROM {$prefix}stream_context_tmp WHERE record_id = {$entry->ID} LIMIT 1" );
55
56 $new_entry = array(
57 'site_id' => $entry->site_id,
58 'blog_id' => $entry->blog_id,
59 'user_id' => $entry->author,
60 'user_role' => $entry->author_role,
61 'summary' => $entry->summary,
62 'created' => $entry->created,
63 'connector' => $context->connector,
64 'context' => $context->context,
65 'action' => $context->action,
66 'ip' => $entry->ip,
67 );
68
69 if ( $entry->object_id && 0 !== $entry->object_id ) {
70 $new_entry['object_id'] = $entry->object_id;
71 }
72
73 $wpdb->insert( $prefix . 'stream', $new_entry );
74 }
75
76 $wpdb->query( "DROP TABLE {$prefix}stream_tmp, {$prefix}stream_context_tmp" );
77
78 return $current_version;
79 }
80