Skip to content

Commit

Permalink
Make extensions use typed methods Minz_Request::paramString and Minz_…
Browse files Browse the repository at this point in the history
…Session::paramString (#181)

* enable strict_types

* replace deprecated Minz_Session::param method and use typed version Minz_Session::paramString instead

* replace deprecated Minz_Request::param method and use typed version Minz_Request::paramString instead

* bump version
  • Loading branch information
mkorthof authored Nov 21, 2023
1 parent ee6aa7c commit ce44911
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 15 deletions.
8 changes: 5 additions & 3 deletions xExtension-CustomCSS/extension.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

declare(strict_types=1);

class CustomCSSExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();

$current_user = Minz_Session::param('currentUser');
$current_user = Minz_Session::paramString('currentUser');
$filename = 'style.' . $current_user . '.css';
$filepath = join_path($this->getPath(), 'static', $filename);

Expand All @@ -16,7 +18,7 @@ public function init() {
public function handleConfigureAction() {
$this->registerTranslates();

$current_user = Minz_Session::param('currentUser');
$current_user = Minz_Session::paramString('currentUser');
$filename = 'style.' . $current_user . '.css';
$staticPath = join_path($this->getPath(), 'static');
$filepath = join_path($staticPath, $filename);
Expand All @@ -28,7 +30,7 @@ public function handleConfigureAction() {
$tmpPath = explode(EXTENSIONS_PATH . '/', $filepath);
$this->permission_problem = $tmpPath[1];
} else if (Minz_Request::isPost()) {
$css_rules = html_entity_decode(Minz_Request::param('css-rules', ''));
$css_rules = html_entity_decode(Minz_Request::paramString('css-rules'));
file_put_contents($filepath, $css_rules);
}

Expand Down
2 changes: 1 addition & 1 deletion xExtension-CustomCSS/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Custom CSS",
"author": "Marien Fressinaud",
"description": "Give possibility to overwrite the CSS with a user-specific rules.",
"version": "0.2",
"version": "0.3",
"entrypoint": "CustomCSS",
"type": "user"
}
8 changes: 5 additions & 3 deletions xExtension-CustomJS/extension.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

declare(strict_types=1);

class CustomJSExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();

$current_user = Minz_Session::param('currentUser');
$current_user = Minz_Session::paramString('currentUser');
$filename = 'script.' . $current_user . '.js';
$filepath = join_path($this->getPath(), 'static', $filename);

Expand All @@ -16,7 +18,7 @@ public function init() {
public function handleConfigureAction() {
$this->registerTranslates();

$current_user = Minz_Session::param('currentUser');
$current_user = Minz_Session::paramString('currentUser');
$filename = 'script.' . $current_user . '.js';
$staticPath = join_path($this->getPath(), 'static');
$filepath = join_path($staticPath, $filename);
Expand All @@ -28,7 +30,7 @@ public function handleConfigureAction() {
$tmpPath = explode(EXTENSIONS_PATH . '/', $filepath);
$this->permission_problem = $tmpPath[1];
} else if (Minz_Request::isPost()) {
$js_rules = html_entity_decode(Minz_Request::param('js-rules', ''));
$js_rules = html_entity_decode(Minz_Request::paramString('js-rules'));
file_put_contents($filepath, $js_rules);
}

Expand Down
2 changes: 1 addition & 1 deletion xExtension-CustomJS/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Custom JS",
"author": "Frans de Jonge",
"description": "Apply custom JS.",
"version": "0.2",
"version": "0.3",
"entrypoint": "CustomJS",
"type": "user"
}
14 changes: 8 additions & 6 deletions xExtension-ImageProxy/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class ImageProxyExtension extends Minz_Extension {
// Defaults
const PROXY_URL = 'https://images.weserv.nl/?url=';
Expand Down Expand Up @@ -52,12 +54,12 @@ public function handleConfigureAction() {
$this->registerTranslates();

if (Minz_Request::isPost()) {
FreshRSS_Context::$user_conf->image_proxy_url = Minz_Request::param('image_proxy_url', self::PROXY_URL, true);
FreshRSS_Context::$user_conf->image_proxy_scheme_http = Minz_Request::param('image_proxy_scheme_http', '');
FreshRSS_Context::$user_conf->image_proxy_scheme_https = Minz_Request::param('image_proxy_scheme_https', '');
FreshRSS_Context::$user_conf->image_proxy_scheme_default = Minz_Request::param('image_proxy_scheme_default', self::SCHEME_DEFAULT);
FreshRSS_Context::$user_conf->image_proxy_scheme_include = Minz_Request::param('image_proxy_scheme_include', '');
FreshRSS_Context::$user_conf->image_proxy_url_encode = Minz_Request::param('image_proxy_url_encode', '');
FreshRSS_Context::$user_conf->image_proxy_url = Minz_Request::paramString('image_proxy_url', true) ?: self::PROXY_URL;
FreshRSS_Context::$user_conf->image_proxy_scheme_http = Minz_Request::paramString('image_proxy_scheme_http');
FreshRSS_Context::$user_conf->image_proxy_scheme_https = Minz_Request::paramString('image_proxy_scheme_https');
FreshRSS_Context::$user_conf->image_proxy_scheme_default = Minz_Request::paramString('image_proxy_scheme_default') ?: self::SCHEME_DEFAULT;
FreshRSS_Context::$user_conf->image_proxy_scheme_include = Minz_Request::paramString('image_proxy_scheme_include');
FreshRSS_Context::$user_conf->image_proxy_url_encode = Minz_Request::paramString('image_proxy_url_encode');
FreshRSS_Context::$user_conf->save();
}
}
Expand Down
2 changes: 1 addition & 1 deletion xExtension-ImageProxy/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Image Proxy",
"author": "Frans de Jonge",
"description": "No insecure content warnings or disappearing images.",
"version": "0.5",
"version": "0.6",
"entrypoint": "ImageProxy",
"type": "user"
}
2 changes: 2 additions & 0 deletions xExtension-QuickCollapse/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class QuickCollapseExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();
Expand Down
2 changes: 2 additions & 0 deletions xExtension-ReadingTime/extension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
class ReadingTimeExtension extends Minz_Extension {
public function init() {
Minz_View::appendScript($this->getFileUrl('readingtime.js', 'js'));
Expand Down
2 changes: 2 additions & 0 deletions xExtension-ShareByEmail/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class ShareByEmailExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();
Expand Down
2 changes: 2 additions & 0 deletions xExtension-StickyFeeds/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class StickyFeedsExtension extends Minz_Extension {
public function init() {
Minz_View::appendStyle($this->getFileUrl('style.css', 'css'));
Expand Down
2 changes: 2 additions & 0 deletions xExtension-TTRSS_API/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class TTRSS_APIExtension extends Minz_Extension {
public function init() {
$this->registerHook('post_update',
Expand Down
2 changes: 2 additions & 0 deletions xExtension-TitleWrap/extension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

class TitleWrapExtension extends Minz_Extension {
public function init() {
Minz_View::appendStyle($this->getFileUrl('title_wrap.css', 'css'));
Expand Down
3 changes: 3 additions & 0 deletions xExtension-showFeedID/extension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

class ShowFeedIdExtension extends Minz_Extension {
public function init() {
Minz_View::appendScript($this->getFileUrl('showfeedid.js', 'js'));
Expand Down

5 comments on commit ce44911

@edwrap
Copy link

@edwrap edwrap commented on ce44911 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CustomCSS extension is broken after this commit (possibly others, too, but this is the only one I use). On a new install of FreshRSS today, CustomCSS config page is blank, and enabling the extension breaks FreshRSS entirely. Downloaded version immediately before this commit and it works as usual

@Alkarex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update to the latest FreshRSS edge branch or/and update the CustomCSS extension

@Alkarex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, what FreshRSS version are you using?

@edwrap
Copy link

@edwrap edwrap commented on ce44911 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, as I commented in the issue report, I’m on 1.22.1. I just tried the edge branch and CustomCSS with this commit is working fine. I should’ve considered that a possibility - apologies!

@Alkarex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on a better fix

Please sign in to comment.