mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-07-16 10:02:59 -04:00
Saving custom CSS/JS rendered the response from the pre-save state (no Post/Redirect/Get), so the stylesheet cache-busting URL was stale and the change only appeared after a manual reload, which reads as erratic behavior. Redirect back to the extension config after save, matching the pattern used elsewhere in the codebase. Fixes #8795 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
final class UserJSExtension extends Minz_Extension {
|
|
public string $js_rules = '';
|
|
private const FILENAME = 'script.js';
|
|
|
|
#[\Override]
|
|
public function init(): void {
|
|
parent::init();
|
|
|
|
$this->registerTranslates();
|
|
if ($this->hasFile(self::FILENAME)) {
|
|
Minz_View::appendScript($this->getFileUrl(self::FILENAME, isStatic: false));
|
|
}
|
|
}
|
|
|
|
#[\Override]
|
|
public function handleConfigureAction(): void {
|
|
parent::init();
|
|
|
|
$this->registerTranslates();
|
|
|
|
if (FreshRSS_Auth::requestReauth()) {
|
|
return;
|
|
}
|
|
|
|
if (Minz_Request::isPost()) {
|
|
$js_rules = Minz_Request::paramString('js-rules', plaintext: true);
|
|
$this->saveFile(self::FILENAME, $js_rules);
|
|
FreshRSS_UserDAO::touch();
|
|
// Redirect (Post/Redirect/Get) so the next page is built after the save,
|
|
// with a fresh cache-busting URL for the updated script
|
|
Minz_Request::good(_t('feedback.conf.updated'), [
|
|
'c' => 'extension', 'a' => 'configure', 'params' => ['e' => $this->getName()],
|
|
]);
|
|
}
|
|
|
|
$this->js_rules = '';
|
|
if ($this->hasFile(self::FILENAME)) {
|
|
$this->js_rules = htmlspecialchars($this->getFile(self::FILENAME) ?? '', ENT_NOQUOTES, 'UTF-8');
|
|
}
|
|
}
|
|
}
|