| 1 |
<?php |
| 2 |
/** |
| 3 |
* Primary routing for storage operations that depend on current database state. |
| 4 |
* |
| 5 |
* @package OpenStation |
| 6 |
*/ |
| 7 |
defined( 'ABSPATH' ) || exit; |
| 8 |
|
| 9 |
/** |
| 10 |
* Keep advisory locks and their protected reads on writable connections. |
| 11 |
* |
| 12 |
* HyperDB classifies SELECT GET_LOCK and SELECT FOR UPDATE as reads. Use its |
| 13 |
* supported routing API before acquiring the lock; LudicrousDB has a renamed |
| 14 |
* equivalent. Keep this routing for the request so release and readbacks cannot |
| 15 |
* move to a lagging replica. Standard wpdb already uses one connection. |
| 16 |
* |
| 17 |
* @internal |
| 18 |
* @return void |
| 19 |
*/ |
| 20 |
function openstation_storage_use_primary() { |
| 21 |
global $wpdb; |
| 22 |
if ( is_callable( array( $wpdb, 'send_reads_to_primaries' ) ) ) { |
| 23 |
$wpdb->send_reads_to_primaries(); |
| 24 |
} elseif ( is_callable( array( $wpdb, 'send_reads_to_masters' ) ) ) { |
| 25 |
$wpdb->send_reads_to_masters(); |
| 26 |
} |
| 27 |
} |
| 28 |
|