PluginProbe
Stream – Activity Log & Audit Trail / 3.9.0
Stream – Activity Log & Audit Trail v3.9.0
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
← All changes | classes/class-db-driver-wpdb.php +24 -10 3.2.13.9.0 View file →
@@ -1,7 +1,16 @@
1 1 <?php
2 +/**
3 + * Database Driver class for "stream" table responsible for holding records.
4 + *
5 + * @package WP_Stream
6 + */
7 +
2 8 namespace WP_Stream;
3 9
10 +/**
11 + * Class - DB_Driver_WPDB
12 + */
4 13 class DB_Driver_WPDB implements DB_Driver {
5 14 /**
6 15 * Holds Query class
7 16 *
@@ -37,9 +46,9 @@
37 46
38 47 $wpdb->stream = $this->table;
39 48 $wpdb->streammeta = $this->table_meta;
40 49
41 - // Hack for get_metadata
50 + // Hack for get_metadata.
42 51 $wpdb->recordmeta = $this->table_meta;
43 52 }
44 53
45 54 /**
@@ -55,10 +64,13 @@
55 64 if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
56 65 return false;
57 66 }
58 67
59 - $meta = $data['meta'];
60 - unset( $data['meta'] );
68 + $meta = array();
69 + if ( array_key_exists( 'meta', $data ) ) {
70 + $meta = $data['meta'];
71 + unset( $data['meta'] );
72 + }
61 73
62 74 $result = $wpdb->insert( $this->table, $data );
63 75 if ( ! $result ) {
64 76 return false;
@@ -65,12 +77,14 @@
65 77 }
66 78
67 79 $record_id = $wpdb->insert_id;
68 80
69 - // Insert record meta
81 + // Insert record meta.
70 82 foreach ( (array) $meta as $key => $vals ) {
71 83 foreach ( (array) $vals as $val ) {
72 - $this->insert_meta( $record_id, $key, $val );
84 + if ( is_scalar( $val ) && '' !== $val ) {
85 + $this->insert_meta( $record_id, $key, $val );
86 + }
73 87 }
74 88 }
75 89
76 90 return $record_id;
@@ -78,11 +92,11 @@
78 92
79 93 /**
80 94 * Insert record meta
81 95 *
82 - * @param int $record_id
83 - * @param string $key
84 - * @param string $val
96 + * @param int $record_id Record ID.
97 + * @param string $key Meta Key.
98 + * @param string $val Meta Data.
85 99 *
86 100 * @return array
87 101 */
88 102 public function insert_meta( $record_id, $key, $val ) {
@@ -102,9 +116,9 @@
102 116
103 117 /**
104 118 * Retrieve records
105 119 *
106 - * @param array $args
120 + * @param array $args Query arguments.
107 121 *
108 122 * @return array
109 123 */
110 124 public function get_records( $args ) {
@@ -117,9 +131,9 @@
117 131 *
118 132 * GROUP BY allows query to find just the first occurrence of each value in the column,
119 133 * increasing the efficiency of the query.
120 134 *
121 - * @param string $column
135 + * @param string $column Column being filtered.
122 136 *
123 137 * @return array
124 138 */
125 139 public function get_column_values( $column ) {