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

77 lines 2.2 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 $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}stream" );
14 foreach ( $stream_entries as $entry ) {
15 $class = 'Connector_' . $entry->context;
16 if ( class_exists( $class ) ) {
17 $connector = new $class();
18 $wpdb->update( $wpdb->base_prefix . 'stream', array( 'connector' => $connector->name ), array( 'ID' => $entry->ID ) );
19 } else {
20 $wpdb->update( $wpdb->base_prefix . 'stream', array( 'connector' => strtolower( $entry->connector ) ), array( 'ID' => $entry->ID ) );
21 }
22 }
23
24 return $current_version;
25 }
26
27 /**
28 * Version 3.0.0
29 *
30 * Update from 1.4.9
31 *
32 * @param string $db_version
33 * @param string $current_version
34 *
35 * @return string
36 */
37 function wp_stream_update_auto_300( $db_version, $current_version ) {
38 global $wpdb;
39
40 // Get only the author_meta values that are double-serialized
41 $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
43 $plugin = wp_stream_get_instance();
44 $plugin->install->install( $current_version );
45
46 $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}stream_tmp" );
47
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 );
52
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 );
65
66 if ( $entry->object_id && 0 !== $entry->object_id ) {
67 $new_entry['object_id'] = $entry->object_id;
68 }
69
70 $wpdb->insert( $wpdb->base_prefix . 'stream', $new_entry );
71 }
72
73 $wpdb->query( "DROP TABLE {$wpdb->base_prefix}stream_tmp, {$wpdb->base_prefix}stream_context_tmp" );
74
75 return $current_version;
76 }
77