IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
56 | 56 | return true; |
57 | 57 | } |
58 | 58 | } |
59 | | // Didn't find it, so try to create it. |
60 | | $wpdb->query( $create_ddl ); |
| 59 | /* |
| 60 | * Didn't find it, so try to create it. |
| 61 | * |
| 62 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because there are no |
| 63 | * variables applicable here. |
| 64 | */ |
| 65 | $wpdb->query( $create_ddl ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
61 | 66 | |
62 | 67 | // We cannot directly tell that whether this succeeded! |
63 | 68 | foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) { |
… |
… |
|
84 | 89 | */ |
85 | 90 | function maybe_add_column( $table_name, $column_name, $create_ddl ) { |
86 | 91 | global $wpdb; |
87 | | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { |
88 | 92 | |
89 | | if ( $column == $column_name ) { |
| 93 | /* |
| 94 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because this statement cannot be prepared, |
| 95 | * it fetches the columns for a table name, which cannot be quoted. |
| 96 | */ |
| 97 | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
| 98 | if ( $column === $column_name ) { |
90 | 99 | return true; |
91 | 100 | } |
92 | 101 | } |
93 | 102 | |
94 | | // Didn't find it, so try to create it. |
95 | | $wpdb->query( $create_ddl ); |
| 103 | /* |
| 104 | * Didn't find it, so try to create it. |
| 105 | * |
| 106 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because there |
| 107 | * are no variables applicable for this query. |
| 108 | */ |
| 109 | $wpdb->query( $create_ddl ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
96 | 110 | |
97 | | // We cannot directly tell that whether this succeeded! |
98 | | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { |
99 | | if ( $column == $column_name ) { |
| 111 | /* |
| 112 | * We cannot directly tell that whether this succeeded! |
| 113 | * |
| 114 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because this statement cannot be prepared, |
| 115 | * it fetches the columns for a table name, which cannot be quoted. |
| 116 | */ |
| 117 | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
| 118 | if ( $column === $column_name ) { |
100 | 119 | return true; |
101 | 120 | } |
102 | 121 | } |
… |
… |
|
118 | 137 | */ |
119 | 138 | function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { |
120 | 139 | global $wpdb; |
121 | | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { |
122 | | if ( $column == $column_name ) { |
123 | 140 | |
124 | | // Found it, so try to drop it. |
125 | | $wpdb->query( $drop_ddl ); |
| 141 | /* |
| 142 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because this statement cannot be prepared, |
| 143 | * it fetches the columns for a table name, which cannot be quoted. |
| 144 | */ |
| 145 | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
| 146 | if ( $column === $column_name ) { |
126 | 147 | |
127 | | // We cannot directly tell that whether this succeeded! |
128 | | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { |
129 | | if ( $column == $column_name ) { |
| 148 | /* |
| 149 | * Found it, so try to drop it. |
| 150 | * |
| 151 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because there are no attributes |
| 152 | * relevant for this query. |
| 153 | */ |
| 154 | $wpdb->query( $drop_ddl ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
| 155 | |
| 156 | /* |
| 157 | * We cannot directly tell that whether this succeeded! |
| 158 | * |
| 159 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because this statement cannot be prepared, |
| 160 | * it fetches the columns for a table name, which cannot be quoted. |
| 161 | */ |
| 162 | foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
| 163 | if ( $column === $column_name ) { |
130 | 164 | return false; |
131 | 165 | } |
132 | 166 | } |
… |
… |
|
167 | 201 | */ |
168 | 202 | function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null ) { |
169 | 203 | global $wpdb; |
| 204 | |
| 205 | /* |
| 206 | * The phpcs ignore (WordPress.WP.PreparedSQL.NotPrepared) has been added because this statement cannot be prepared, |
| 207 | * it fetches the columns for a table name, which cannot be quoted. |
| 208 | */ |
| 209 | $results = $wpdb->get_results( "DESC $table_name" ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared |
170 | 210 | $diffs = 0; |
171 | | $results = $wpdb->get_results( "DESC $table_name" ); |
172 | 211 | |
173 | 212 | foreach ( $results as $row ) { |
174 | 213 | |
175 | | if ( $row->Field == $col_name ) { |
| 214 | // The results are named via SQL standards, thus the capital letter cannot be resolved otherwise. |
| 215 | $result_field = $row->Field; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
| 216 | $result_type = $row->Type; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
| 217 | $result_null = $row->Null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
| 218 | $result_key = $row->Key; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
| 219 | $result_default = $row->Default; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
| 220 | $result_extra = $row->Extra; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar |
| 221 | |
| 222 | if ( $result_field == $col_name ) { |
176 | 223 | |
177 | 224 | // Got our column, check the params. |
178 | | if ( ( $col_type != null ) && ( $row->Type != $col_type ) ) { |
| 225 | if ( ( null !== $col_type ) && ( $result_type != $col_type ) ) { |
179 | 226 | ++$diffs; |
180 | 227 | } |
181 | | if ( ( $is_null != null ) && ( $row->Null != $is_null ) ) { |
| 228 | if ( ( null !== $is_null ) && ( $result_null != $is_null ) ) { |
182 | 229 | ++$diffs; |
183 | 230 | } |
184 | | if ( ( $key != null ) && ( $row->Key != $key ) ) { |
| 231 | if ( ( null !== $key ) && ( $result_key != $key ) ) { |
185 | 232 | ++$diffs; |
186 | 233 | } |
187 | | if ( ( $default != null ) && ( $row->Default != $default ) ) { |
| 234 | if ( ( null !== $default ) && ( $result_default != $default ) ) { |
188 | 235 | ++$diffs; |
189 | 236 | } |
190 | | if ( ( $extra != null ) && ( $row->Extra != $extra ) ) { |
| 237 | if ( ( null !== $extra ) && ( $result_extra != $extra ) ) { |
191 | 238 | ++$diffs; |
192 | 239 | } |
193 | 240 | if ( $diffs > 0 ) { |