| @@ -857,9 +857,9 @@ | ||
| 857 | 857 | $updates['twitter_title'] = mb_substr($data['twitter_title'], 0, 191); |
| 858 | 858 | } |
| 859 | 859 | if (!empty($data['twitter_card'])) { |
| 860 | 860 | // twitter_card column only exists in newer Yoast versions; skip if absent |
| 861 | - $col_check = $wpdb->get_var($wpdb->prepare( | |
| 861 | + $col_check = $wpdb->get_var($wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 862 | 862 | "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = 'twitter_card'", |
| 863 | 863 | DB_NAME, |
| 864 | 864 | $indexable_table |
| 865 | 865 | )); |
| @@ -877,10 +877,10 @@ | ||
| 877 | 877 | $updates['breadcrumb_title'] = mb_substr($data['breadcrumb_title'], 0, 191); |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | if (!empty($updates)) { |
| 881 | - $row_exists = $wpdb->get_var($wpdb->prepare( | |
| 882 | - "SELECT id FROM {$indexable_table} WHERE object_id = %d AND object_type = 'post'", | |
| 881 | + $row_exists = $wpdb->get_var($wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 882 | + "SELECT id FROM {$wpdb->prefix}yoast_indexable WHERE object_id = %d AND object_type = 'post'", | |
| 883 | 883 | $post_id |
| 884 | 884 | )); |
| 885 | 885 | |
| 886 | 886 | // This probe decides two things at once: the value of the write-once |
| @@ -906,9 +906,9 @@ | ||
| 906 | 906 | return $wrote; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | if ($row_exists) { |
| 910 | - $wpdb->update( | |
| 910 | + $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 911 | 911 | $indexable_table, |
| 912 | 912 | $updates, |
| 913 | 913 | ['object_id' => $post_id, 'object_type' => 'post'] |
| 914 | 914 | ); |
| @@ -944,9 +944,9 @@ | ||
| 944 | 944 | // still reports what landed. Claiming nothing was written would |
| 945 | 945 | // tell the conflict handler this post is unsynced to Yoast while |
| 946 | 946 | // Yoast's own meta holds our values, and it would hand tag |
| 947 | 947 | // ownership to the wrong plugin. |
| 948 | - if ($wpdb->insert($indexable_table, $insert) === false) { | |
| 948 | + if ($wpdb->insert($indexable_table, $insert) === false) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 949 | 949 | Metasync_Seo_Backup::discard_backups('post', $post_id, $backups_created); |
| 950 | 950 | return $wrote; |
| 951 | 951 | } |
| 952 | 952 | } |
| @@ -1006,11 +1006,13 @@ | ||
| 1006 | 1006 | |
| 1007 | 1007 | $current = null; |
| 1008 | 1008 | if ($row_existed) { |
| 1009 | 1009 | $select = '`' . implode('`, `', array_map('esc_sql', $columns)) . '`'; |
| 1010 | - $current = $wpdb->get_row( | |
| 1010 | + // Column list is esc_sql()'d above; the table is a fixed literal. | |
| 1011 | + $current = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 1011 | 1012 | $wpdb->prepare( |
| 1012 | - "SELECT {$select} FROM {$table} WHERE object_id = %d AND object_type = 'post'", | |
| 1013 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- column list esc_sql()'d above, table is a fixed literal | |
| 1014 | + "SELECT {$select} FROM {$wpdb->prefix}yoast_indexable WHERE object_id = %d AND object_type = 'post'", | |
| 1013 | 1015 | $post_id |
| 1014 | 1016 | ), |
| 1015 | 1017 | ARRAY_A |
| 1016 | 1018 | ); |
| @@ -1245,10 +1247,15 @@ | ||
| 1245 | 1247 | |
| 1246 | 1248 | $current = null; |
| 1247 | 1249 | if ($row_existed) { |
| 1248 | 1250 | $select = '`' . implode('`, `', array_map('esc_sql', $columns)) . '`'; |
| 1249 | - $current = $wpdb->get_row( | |
| 1250 | - $wpdb->prepare("SELECT {$select} FROM {$table} WHERE post_id = %d", $post_id), | |
| 1251 | + // Column list is esc_sql()'d above; the table is a fixed literal. | |
| 1252 | + $current = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 1253 | + $wpdb->prepare( | |
| 1254 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- column list esc_sql()'d above, table is a fixed literal | |
| 1255 | + "SELECT {$select} FROM {$wpdb->prefix}aioseo_posts WHERE post_id = %d", | |
| 1256 | + $post_id | |
| 1257 | + ), | |
| 1251 | 1258 | ARRAY_A |
| 1252 | 1259 | ); |
| 1253 | 1260 | |
| 1254 | 1261 | // The row was there a moment ago, so a null answer now is a failed |
| @@ -1317,9 +1324,9 @@ | ||
| 1317 | 1324 | |
| 1318 | 1325 | $table = $wpdb->prefix . 'aioseo_posts'; |
| 1319 | 1326 | |
| 1320 | 1327 | // Bail if the AIOSEO post table does not exist (plugin not initialised). |
| 1321 | - $table_exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $table)); | |
| 1328 | + $table_exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $table)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 1322 | 1329 | if ($table_exists !== $table) { |
| 1323 | 1330 | return false; |
| 1324 | 1331 | } |
| 1325 | 1332 | |
| @@ -1426,10 +1433,10 @@ | ||
| 1426 | 1433 | } |
| 1427 | 1434 | |
| 1428 | 1435 | $row['updated'] = current_time('mysql'); |
| 1429 | 1436 | |
| 1430 | - $existing_id = $wpdb->get_var($wpdb->prepare( | |
| 1431 | - "SELECT id FROM {$table} WHERE post_id = %d", | |
| 1437 | + $existing_id = $wpdb->get_var($wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 1438 | + "SELECT id FROM {$wpdb->prefix}aioseo_posts WHERE post_id = %d", | |
| 1432 | 1439 | $post_id |
| 1433 | 1440 | )); |
| 1434 | 1441 | |
| 1435 | 1442 | // An unreadable probe cannot be treated as "no row". It would commit a |
| @@ -1448,9 +1455,9 @@ | ||
| 1448 | 1455 | if (!$this->backup_aioseo_columns($post_id, $table, $row, true, $backups_created)) { |
| 1449 | 1456 | return false; |
| 1450 | 1457 | } |
| 1451 | 1458 | |
| 1452 | - return ($wpdb->update($table, $row, ['post_id' => $post_id]) !== false) && $wrote; | |
| 1459 | + return ($wpdb->update($table, $row, ['post_id' => $post_id]) !== false) && $wrote; // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 1453 | 1460 | } |
| 1454 | 1461 | |
| 1455 | 1462 | $backups_created = []; |
| 1456 | 1463 | if (!$this->backup_aioseo_columns($post_id, $table, $row, false, $backups_created)) { |
| @@ -1471,9 +1478,9 @@ | ||
| 1471 | 1478 | 'robots_notranslate' => 0, |
| 1472 | 1479 | ]; |
| 1473 | 1480 | $row = array_merge($robot_defaults, $row); |
| 1474 | 1481 | |
| 1475 | - $inserted = $wpdb->insert($table, $row); | |
| 1482 | + $inserted = $wpdb->insert($table, $row); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- mirrors SEO meta into third-party plugin storage (Yoast indexables/AIOSEO tables) — no WordPress API for their schemas | |
| 1476 | 1483 | |
| 1477 | 1484 | // The row_existed='0' marker was recorded before the insert, because a |
| 1478 | 1485 | // marker that will not save has to be able to veto the write. If the |
| 1479 | 1486 | // insert then failed there is no row of ours, and leaving the marker |