Sicherheitsupdate nach Audit (0.29.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m50s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m34s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m45s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m30s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m9s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m5s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 48s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 11:34:54 +00:00
parent a37895a16a
commit f1202bea08
226 changed files with 1952 additions and 450 deletions

View file

@ -3,13 +3,14 @@
namespace Inhaus\Plugins\Pages;
use App\Models\User;
use App\Pagebuilder\Content;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Pages\Models\Page;
/** Suchquelle für die globale Suche: veröffentlichte, sichtbare Seiten */
class PageSearch
{
public function __construct(private readonly PageTree $tree) {}
public function __construct(private readonly PageTree $tree, private readonly Content $content) {}
/**
* @return list<array<string, mixed>>
@ -27,27 +28,30 @@ class PageSearch
}
});
return $query->orderBy('title')->limit($limit * 3)->get()
->filter(fn (Page $page) => $this->tree->isVisible($page->id, $user))
->take($limit)
->map(fn (Page $page) => [
$terms = GlobalSearch::terms($search);
$results = [];
foreach ($query->orderBy('title')->limit($limit * 3)->get() as $page) {
if (count($results) >= $limit || ! $this->tree->isVisible($page->id, $user)) {
continue;
}
// Treffer und Auszug nur aus dem, was diese Person auf der Seite sieht
// (Blöcke mit eingeschränkter Sichtbarkeit zählen nicht)
$text = $this->content->plainText($this->content->render($page->content, $user, ['page_id' => $page->id]));
if (! collect($terms)->every(fn (string $term) => mb_stripos($page->title.' '.$text, $term) !== false)) {
continue;
}
$results[] = [
'title' => $page->title,
'url' => $page->url(),
'excerpt' => GlobalSearch::excerpt($this->text($page->content), $search),
'excerpt' => GlobalSearch::excerpt($text, $search),
'meta' => collect($this->tree->ancestors($page->id))->pluck('title')->filter()->implode(' › ') ?: 'Seite',
])->values()->all();
}
];
}
/** Alle Texte aus den Pagebuilder-Blöcken */
private function text(mixed $content): string
{
$parts = [];
array_walk_recursive($content, function ($value, $key) use (&$parts) {
if (is_string($value) && ! in_array($key, ['type', 'id', 'url', 'image', 'icon', 'layout', 'variant'], true) && ! preg_match('#^(https?:|/|[a-z0-9_.-]+$)#i', $value)) {
$parts[] = $value;
}
});
return implode(' ', $parts);
return $results;
}
}