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

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

52 lines 1.4 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.0
4 *
5 * Update from 1.4.9
6 *
7 * @param string $db_version
8 * @param string $current_version
9 *
10 * @return string
11 */
12 function wp_stream_update_auto_300( $db_version, $current_version ) {
13 global $wpdb;
14
15 // Get only the author_meta values that are double-serialized
16 $plugin = wp_stream_get_instance();
17 $prefix = $plugin->install->table_prefix;
18
19 $wpdb->query( "RENAME TABLE {$prefix}stream TO {$prefix}stream_tmp, {$prefix}stream_context TO {$prefix}stream_context_tmp" );
20
21 $plugin->install->install( $current_version );
22
23 $stream_entries = $wpdb->get_results( "SELECT * FROM {$prefix}stream_tmp" );
24
25 foreach ( $stream_entries as $entry ) {
26 $context = $wpdb->get_row( "SELECT * FROM {$prefix}stream_context_tmp WHERE record_id = {$entry->ID} LIMIT 1" );
27
28 $new_entry = array(
29 'site_id' => $entry->site_id,
30 'blog_id' => $entry->blog_id,
31 'user_id' => $entry->author,
32 'user_role' => $entry->author_role,
33 'summary' => $entry->summary,
34 'created' => $entry->created,
35 'connector' => $context->connector,
36 'context' => $context->context,
37 'action' => $context->action,
38 'ip' => $entry->ip,
39 );
40
41 if ( $entry->object_id && 0 !== $entry->object_id ) {
42 $new_entry['object_id'] = $entry->object_id;
43 }
44
45 $wpdb->insert( $prefix . 'stream', $new_entry );
46 }
47
48 $wpdb->query( "DROP TABLE {$prefix}stream_tmp, {$prefix}stream_context_tmp" );
49
50 return $current_version;
51 }
52