Schneller und stabiler bei Updates (0.45.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 12m25s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 12m51s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 10m43s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 10m37s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 12m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m38s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 9m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 12m25s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 12m51s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 10m43s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 10m37s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 12m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m38s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 9m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
- Ladefehler während eines Updates schalten keine Plugins mehr ab: Wartungsmodus merkt sich den Update-Zeitraum (+2 min Nachlauf), Plugin-Uploads markieren den Dateiaustausch ohne Wartungsmodus; guard/recoverFromCrash prüfen das, betroffene Plugins (mit disabled_at im Zeitraum) werden wieder eingeschaltet - Plugin-Oberflächen werden nach public/plugin-assets kopiert (Webserver statt PHP), bei Deaktivieren/Löschen/Neu-Hochladen entfernt; Route bleibt als Rückfall - RichTextEditor in SDK, Leichte-Sprache-Leiste und Glossar asynchron; fehlende Menü-Symbole kuratiert → kein Laden des kompletten Symbolsatzes - Inertia-Prefetch (hover, 10 s) für Menülinks und Neuigkeiten-Vorschauen; Prefetch zählt nicht als Lesen (Reach) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
55a26e3f8e
commit
bf68be68f9
205 changed files with 773 additions and 464 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Plugins;
|
||||
|
||||
use App\Support\Update\Filesystem;
|
||||
use App\Version;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Vorkompilierte Oberflächen separat installierter Plugins (Plugin-SDK).
|
||||
|
|
@ -59,6 +61,9 @@ class PluginAssets
|
|||
|
||||
$clean = fn ($file) => is_string($file) && preg_match('#^[A-Za-z0-9_./-]+$#', $file) && ! str_contains($file, '..') ? $file : null;
|
||||
|
||||
// Einmal nach public/ kopieren – dann liefert der Webserver die Dateien ohne PHP aus
|
||||
$this->publish($slug, $manifest);
|
||||
|
||||
$this->cache[$slug] = [
|
||||
'base' => '/plugin-assets/'.rawurlencode($slug).'/'.rawurlencode($manifest->version).'/',
|
||||
'components' => array_filter(array_map($clean, (array) ($data['components'] ?? [])), fn ($file, $key) => $file !== null && preg_match('#^[A-Za-z0-9_/-]+$#', (string) $key), ARRAY_FILTER_USE_BOTH),
|
||||
|
|
@ -85,6 +90,83 @@ class PluginAssets
|
|||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* dist/ eines aktiven Plugins nach public/plugin-assets/<slug>/<version>/ kopieren (gleiche
|
||||
* Adresse wie die PHP-Route). Der Webserver liefert vorhandene Dateien direkt aus – schneller
|
||||
* und ohne Sitzung. Geht das Kopieren nicht (public/ schreibgeschützt), springt die Route ein.
|
||||
*/
|
||||
public function publish(string $slug, PluginManifest $manifest): bool
|
||||
{
|
||||
$target = self::publicPath($slug).'/'.$manifest->version;
|
||||
|
||||
if (is_file($target.'/.complete')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$dist = realpath($manifest->path.'/dist');
|
||||
|
||||
if (! $dist || ! preg_match('#^[A-Za-z0-9.+-]+$#', $manifest->version)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$staging = self::publicPath($slug).'/.tmp-'.bin2hex(random_bytes(4));
|
||||
|
||||
try {
|
||||
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dist, \FilesystemIterator::SKIP_DOTS));
|
||||
|
||||
foreach ($files as $file) {
|
||||
$relative = substr($file->getPathname(), strlen($dist) + 1);
|
||||
|
||||
// Nur erlaubte Dateitypen und saubere Namen (wie bei der Route)
|
||||
if (! $file->isFile() || ! isset(self::TYPES[strtolower($file->getExtension())]) || ! preg_match('#^[A-Za-z0-9_./-]+$#', $relative)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_dir(dirname($staging.'/'.$relative)) && ! @mkdir(dirname($staging.'/'.$relative), 0775, true)) {
|
||||
throw new \RuntimeException('public/plugin-assets ist nicht beschreibbar.');
|
||||
}
|
||||
|
||||
if (! @copy($file->getPathname(), $staging.'/'.$relative)) {
|
||||
throw new \RuntimeException("{$relative} konnte nicht kopiert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
@file_put_contents($staging.'/.complete', (string) time());
|
||||
Filesystem::deleteDirectory($target);
|
||||
|
||||
if (! @rename($staging, $target)) {
|
||||
throw new \RuntimeException('Kopie konnte nicht übernommen werden.');
|
||||
}
|
||||
|
||||
// Ältere Versionen dieses Plugins entfernen
|
||||
foreach (glob(self::publicPath($slug).'/*', GLOB_ONLYDIR) ?: [] as $dir) {
|
||||
if (basename($dir) !== $manifest->version) {
|
||||
Filesystem::deleteDirectory($dir);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Filesystem::deleteDirectory($staging);
|
||||
Log::info("Plugin-Dateien von {$slug} werden über PHP ausgeliefert: ".$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Veröffentlichte Kopie entfernen (Plugin deaktiviert oder gelöscht) */
|
||||
public static function unpublish(string $slug): void
|
||||
{
|
||||
if (preg_match('#^[a-z0-9-]+$#', $slug)) {
|
||||
Filesystem::deleteDirectory(self::publicPath($slug));
|
||||
}
|
||||
}
|
||||
|
||||
private static function publicPath(string $slug): string
|
||||
{
|
||||
return rtrim((string) (config('inhaus.plugin_assets_path') ?: public_path('plugin-assets')), '/').'/'.$slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad einer ausgelieferten Datei – nur aus dist/ eines aktiven Kunden-Plugins.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue