This commit is contained in:
Javier Casares 2026-03-02 11:22:59 +00:00
commit 5cdf7f48e5
29 changed files with 6526 additions and 0 deletions

View file

@ -0,0 +1,58 @@
<?php
/**
* MLP2 site relations reader.
*
* Reads all site connection rows from the MLP2 backup site_relations table.
*
* MLP2 site_relations schema:
* site_1 INT UNSIGNED -- lower site ID
* site_2 INT UNSIGNED -- higher site ID
* PRIMARY KEY (site_1, site_2)
*
* @package Robotstxt_Mlp2_Mlp5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations
*/
class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations {
/**
* Return all MLP2 site relation rows as an array of associative arrays.
*
* Each element has keys: site_1 (int), site_2 (int).
*
* @return array[]
*/
public static function get_all(): array {
global $wpdb;
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
$table = $mlp2->get_site_relations_table();
if ( '' === $table ) {
return array();
}
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$rows = $wpdb->get_results( "SELECT site_1, site_2 FROM `{$table}`", ARRAY_A );
if ( ! is_array( $rows ) ) {
return array();
}
$result = array();
foreach ( $rows as $row ) {
$result[] = array(
'site_1' => (int) $row['site_1'],
'site_2' => (int) $row['site_2'],
);
}
return $result;
}
}