- PostGuard::editable() refuses trashed entries unless the caller opts in (content-get, revisions-list, post-trash); publish/schedule/unpublish/update/ restore/duplicate/replace now refuse them. - PostGuard::statusStable(): content-update, revision-restore and replace-with-copy refuse a future post whose date has passed (any save would publish it); the content-update rollback and PostCloner row writes re-check. - PostCloner::ownMeta() treats a failed SELECT as an error; replace() reads the copy before its first write. - replace-with-copy needs create_posts (backup clone) and reports backup_id in write_failed/partial_write. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
if (! class_exists('wpdb')) {
|
|
/**
|
|
* Minimal wpdb for unit tests. prepare()/esc_like() behave like the real ones
|
|
* closely enough for assertions on the generated SQL; query methods are meant
|
|
* to be mocked via Mockery::mock(wpdb::class)->makePartial().
|
|
*/
|
|
class wpdb
|
|
{
|
|
public $prefix = 'wp_';
|
|
public $posts = 'wp_posts';
|
|
public $postmeta = 'wp_postmeta';
|
|
public $usermeta = 'wp_usermeta';
|
|
public $options = 'wp_options';
|
|
public $insert_id = 0;
|
|
public $last_error = '';
|
|
|
|
public function prepare($query, ...$args)
|
|
{
|
|
if (count($args) === 1 && is_array($args[0])) {
|
|
$args = $args[0];
|
|
}
|
|
// Quotes string placeholders but does not escape, so tests can assert on raw values.
|
|
$query = str_replace("'%s'", '%s', $query);
|
|
$query = str_replace('%s', "'%s'", $query);
|
|
|
|
return vsprintf($query, $args);
|
|
}
|
|
|
|
public function esc_like($text)
|
|
{
|
|
return addcslashes($text, '_%\\');
|
|
}
|
|
|
|
public function get_charset_collate()
|
|
{
|
|
return 'DEFAULT CHARACTER SET utf8mb4';
|
|
}
|
|
|
|
public function insert($table, $data, $format = null)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
public function query($query)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public function get_col($query = null, $x = 0)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function get_var($query = null, $x = 0, $y = 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public function get_results($query = null, $output = 'OBJECT')
|
|
{
|
|
return [];
|
|
}
|
|
}
|
|
}
|