fix: library IDs stay hidden without library access (ruling P13)
Outline, node-get, write outlines, the render summary and replace-text's opaque-node match name no library ID unless the library group is visible and the user has divi_library; read-only still names them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\WordPress\Render;
|
||||
|
||||
use Closure;
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\Annotations;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
@@ -22,8 +23,15 @@ final class PageRenderSummaryAbility implements Ability
|
||||
/** At most this many global-module notes per summary. */
|
||||
private const GLOBAL_NOTES = 20;
|
||||
|
||||
public function __construct(private ContentSchema $schema, private PageRenderer $renderer)
|
||||
{
|
||||
/**
|
||||
* @param (Closure(): bool)|null $globalIdsVisible Ruling P13: whether global module IDs may be named
|
||||
* (library access of this connection); null = always.
|
||||
*/
|
||||
public function __construct(
|
||||
private ContentSchema $schema,
|
||||
private PageRenderer $renderer,
|
||||
private ?Closure $globalIdsVisible = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
@@ -108,13 +116,23 @@ final class PageRenderSummaryAbility implements Ability
|
||||
$notes[] = 'Der Eintrag ist passwortgeschützt; Besucher sehen zuerst das Passwortformular.';
|
||||
}
|
||||
|
||||
foreach (array_slice(self::globalModuleIds((string) $post->post_content), 0, self::GLOBAL_NOTES) as $id) {
|
||||
$globalIds = self::globalModuleIds((string) $post->post_content);
|
||||
if ($globalIds !== [] && $this->globalIdsVisible !== null && ! ($this->globalIdsVisible)()) {
|
||||
$notes[] = sprintf(
|
||||
'Globales Modul %s ist im Auszug nicht enthalten (beim Aufruf über die Schnittstelle rendert Divi '
|
||||
. 'globale Module nicht); Inhalt mit lit-divi-outline mit post_id %s lesen.',
|
||||
$id,
|
||||
$id
|
||||
'%d %s im Auszug nicht enthalten (beim Aufruf über die Schnittstelle rendert Divi globale Module '
|
||||
. 'nicht; die Divi-Bibliothek ist für dieses Konto nicht zugänglich).',
|
||||
count($globalIds),
|
||||
count($globalIds) === 1 ? 'globales Modul ist' : 'globale Module sind'
|
||||
);
|
||||
} else {
|
||||
foreach (array_slice($globalIds, 0, self::GLOBAL_NOTES) as $id) {
|
||||
$notes[] = sprintf(
|
||||
'Globales Modul %s ist im Auszug nicht enthalten (beim Aufruf über die Schnittstelle rendert Divi '
|
||||
. 'globale Module nicht); Inhalt mit lit-divi-outline mit post_id %s lesen.',
|
||||
$id,
|
||||
$id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge(
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\WordPress;
|
||||
|
||||
use Closure;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\Integration;
|
||||
use LIT\MCP\Integrations\WordPress\Content\ContentComposer;
|
||||
@@ -21,8 +22,8 @@ use LIT\MCP\Integrations\WordPress\Menus\MenuListAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuOperations;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuSetItemsAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Menus\MenuWriter;
|
||||
use LIT\MCP\Integrations\WordPress\Render\PageRenderer;
|
||||
use LIT\MCP\Integrations\WordPress\Render\PageRenderSummaryAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Render\PageRenderer;
|
||||
use LIT\MCP\Integrations\WordPress\Revisions\RevisionRestoreAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Revisions\RevisionsListAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
@@ -49,10 +50,15 @@ defined('ABSPATH') || exit;
|
||||
final class WordPressIntegration implements Integration
|
||||
{
|
||||
/** @param ContentComposer|null $divi Divi short form for lit/content-create (DiviIntegration). */
|
||||
/**
|
||||
* @param (Closure(): bool)|null $globalIdsVisible Ruling P13: whether lit-page-render-summary may name
|
||||
* global module IDs (the Divi integration's library access); null = always.
|
||||
*/
|
||||
public function __construct(
|
||||
private ContentSchema $schema,
|
||||
private ChangeLog $log,
|
||||
private ?ContentComposer $divi = null
|
||||
private ?ContentComposer $divi = null,
|
||||
private ?Closure $globalIdsVisible = null
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -99,7 +105,7 @@ final class WordPressIntegration implements Integration
|
||||
new MenuAssignLocationAbility($this->log),
|
||||
new WpSettingsGetAbility($whitelist),
|
||||
new WpSettingsUpdateAbility($whitelist, $this->log),
|
||||
new PageRenderSummaryAbility($this->schema, new PageRenderer()),
|
||||
new PageRenderSummaryAbility($this->schema, new PageRenderer(), $this->globalIdsVisible),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user