Prüft gegen echtes Pods in DDEV: Status ohne Probleme, /pods-check speichert einen grünen Bericht im Format mit Schlüssel version, Reiter zeigt die Pods-Sektion, Freigabe nur für ungetestete Versionen und ohne Sperrwirkung, ein roter Bericht sperrt Pods-Felder bis zu seiner Entfernung. Stellt den Ausgangszustand wieder her. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.1 KiB
PHP
60 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Drives the admin-post handlers of the tab "Compatibility" for the Pods profile without a browser and prints
|
|
* the notice of the redirect (one word). Used by pods-compat-smoke.sh.
|
|
*
|
|
* Usage (inside DDEV, Pods active, as the smoke does):
|
|
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/pods-compat-release.php <release|withdraw> <real|untested>
|
|
*
|
|
* "real" uses the profile as shipped (3.3.9.2 is tested, so releasing is refused); "untested" is the same profile
|
|
* with an empty testedVersions list, which simulates a Pods version the plugin was not tested with.
|
|
* No strict_types: wp eval-file runs this through eval().
|
|
*/
|
|
|
|
defined('WP_CLI') && WP_CLI || exit;
|
|
|
|
use LIT\MCP\Admin\AdminPostAction;
|
|
use LIT\MCP\Admin\CompatibilityTab;
|
|
use LIT\MCP\Compatibility\Compatibility;
|
|
use LIT\MCP\Integrations\Pods\PodsCompatibility;
|
|
|
|
[$mode, $profileKind] = [$args[0] ?? '', $args[1] ?? ''];
|
|
$real = PodsCompatibility::profile();
|
|
$profile = $profileKind === 'untested'
|
|
? new LIT\MCP\Compatibility\Profile(
|
|
id: $real->id,
|
|
label: $real->label,
|
|
tier: $real->tier,
|
|
capabilities: $real->capabilities,
|
|
manifests: $real->manifests,
|
|
active: $real->active,
|
|
version: $real->version,
|
|
minVersion: $real->minVersion,
|
|
testedVersions: []
|
|
)
|
|
: $real;
|
|
|
|
$admins = get_users(['role' => 'administrator', 'number' => 1]);
|
|
wp_set_current_user($admins[0]->ID);
|
|
$action = $mode === 'withdraw' ? CompatibilityTab::WITHDRAW_ACTION : CompatibilityTab::RELEASE_ACTION;
|
|
$_POST['profile'] = 'pods';
|
|
$_REQUEST['_wpnonce'] = wp_create_nonce($action . '_pods');
|
|
|
|
$location = '';
|
|
add_filter('wp_redirect', static function ($url) use (&$location) {
|
|
$location = (string) $url;
|
|
|
|
return false; // do not send anything: the CLI has no response to redirect.
|
|
});
|
|
$tab = new CompatibilityTab(
|
|
new Compatibility([$profile], report: Compatibility::storedReport(...)),
|
|
null,
|
|
new AdminPostAction(static function (): void {
|
|
})
|
|
);
|
|
$mode === 'withdraw' ? $tab->withdraw() : $tab->release();
|
|
|
|
parse_str((string) wp_parse_url($location, PHP_URL_QUERY), $query);
|
|
echo $query['lit_mcp_notice'] ?? 'no-redirect', "\n";
|