Merge branch 'master' into weblate-integration

This commit is contained in:
Andrew Dolgov
2024-06-14 13:47:14 +03:00
30 changed files with 2805 additions and 78 deletions

View File

@@ -1,5 +1,5 @@
ARG PROXY_REGISTRY
FROM ${PROXY_REGISTRY}alpine:3.19
FROM ${PROXY_REGISTRY}alpine:3.20
EXPOSE 9000/tcp
ENV SCRIPT_ROOT=/opt/tt-rss

View File

@@ -29,12 +29,12 @@ if [ -z $SKIP_RSYNC_ON_STARTUP ]; then
mkdir -p $DST_DIR
chown $OWNER_UID:$OWNER_GID $DST_DIR
sudo -u app rsync -a \
sudo -u app rsync -a --no-owner \
$SRC_DIR/ $DST_DIR/
else
chown -R $OWNER_UID:$OWNER_GID $DST_DIR
sudo -u app rsync -a --delete \
sudo -u app rsync -a --no-owner --delete \
--exclude /cache \
--exclude /lock \
--exclude /feed-icons \
@@ -44,7 +44,7 @@ if [ -z $SKIP_RSYNC_ON_STARTUP ]; then
--exclude /themes.local \
$SRC_DIR/ $DST_DIR/
sudo -u app rsync -a --delete \
sudo -u app rsync -a --no-owner --delete \
$SRC_DIR/plugins.local/nginx_xaccel \
$DST_DIR/plugins.local/nginx_xaccel
fi

View File

@@ -11,7 +11,6 @@
define('NO_SESSION_AUTOSTART', true);
require_once "autoload.php";
require_once "functions.php";
require_once "sessions.php";
ini_set('session.use_cookies', "0");

View File

@@ -25,7 +25,6 @@
require_once "autoload.php";
require_once "sessions.php";
require_once "functions.php";
$op = (string)clean($op);
$method = (string)clean($method);

View File

@@ -11,7 +11,14 @@ class Cache_Local implements Cache_Adapter {
}
public function set_dir(string $dir) : void {
$this->dir = Config::get(Config::CACHE_DIR) . "/" . basename(clean($dir));
$cache_dir = Config::get(Config::CACHE_DIR);
// use absolute path local to current dir if CACHE_DIR is relative
// TODO: maybe add a special method to Config() for this?
if ($cache_dir[0] != '/')
$cache_dir = dirname(__DIR__) . "/$cache_dir";
$this->dir = $cache_dir . "/" . basename(clean($dir));
$this->make_dir();
}

View File

@@ -15,11 +15,11 @@ class Counters {
}
/**
* @param array<int> $feed_ids
* @param array<int> $label_ids
* @param array<int>|null $feed_ids
* @param array<int>|null $label_ids
* @return array<int, array<string, int|string>>
*/
static function get_conditional(array $feed_ids = null, array $label_ids = null): array {
static function get_conditional(?array $feed_ids = null, ?array $label_ids = null): array {
return [
...self::get_global(),
...self::get_virt(),
@@ -52,10 +52,10 @@ class Counters {
}
/**
* @param array<int> $cat_ids
* @param array<int>|null $cat_ids
* @return array<int, array<string, int|string>>
*/
private static function get_cats(array $cat_ids = null): array {
private static function get_cats(?array $cat_ids = null): array {
$ret = [];
/* Labels category */
@@ -141,10 +141,10 @@ class Counters {
}
/**
* @param array<int> $feed_ids
* @param array<int>|null $feed_ids
* @return array<int, array<string, int|string>>
*/
private static function get_feeds(array $feed_ids = null): array {
private static function get_feeds(?array $feed_ids = null): array {
$span = Tracer::start(__METHOD__);
$ret = [];
@@ -300,10 +300,10 @@ class Counters {
}
/**
* @param array<int> $label_ids
* @param array<int>|null $label_ids
* @return array<int, array<string, int|string>>
*/
static function get_labels(array $label_ids = null): array {
static function get_labels(?array $label_ids = null): array {
$span = Tracer::start(__METHOD__);
$ret = [];

View File

@@ -453,7 +453,7 @@ class Feeds extends Handler_Protected {
if ($num_errors > 0) {
$reply['content'] .= "<br/>";
$reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">" .
$reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors(); return false\">" .
__('Some feeds have update errors (click for details)') . "</a>";
}
$reply['content'] .= "</span></p></div>";
@@ -603,7 +603,7 @@ class Feeds extends Handler_Protected {
if ($num_errors > 0) {
$reply['headlines']['content'] .= "<br/>";
$reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">".
$reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors(); return false\">".
__('Some feeds have update errors (click for details)')."</a>";
}
$reply['headlines']['content'] .= "</span></p>";
@@ -2097,8 +2097,8 @@ class Feeds extends Handler_Protected {
$doc = new DOMDocument();
if (@$doc->loadHTML($content)) {
$xpath = new DOMXPath($doc);
$entries = $xpath->query('/html/head/link[@rel="alternate" and '.
'(contains(@type,"rss") or contains(@type,"atom"))]|/html/head/link[@rel="feed"]');
$entries = $xpath->query('/html/*[self::head or self::body]/link[@rel="alternate" and '.
'(contains(@type,"rss") or contains(@type,"atom"))]|/html/*[self::head or self::body]/link[@rel="feed"]');
foreach ($entries as $entry) {
if ($entry->hasAttribute('href')) {
@@ -2127,7 +2127,7 @@ class Feeds extends Handler_Protected {
$cat->delete();
}
static function _add_cat(string $title, int $owner_uid, int $parent_cat = null, int $order_id = 0): bool {
static function _add_cat(string $title, int $owner_uid, ?int $parent_cat = null, int $order_id = 0): bool {
$cat = ORM::for_table('ttrss_feed_categories')
->where('owner_uid', $owner_uid)

View File

@@ -429,7 +429,7 @@ class PluginHost {
/**
* @param PluginHost::KIND_* $kind
*/
function load_all(int $kind, int $owner_uid = null, bool $skip_init = false): void {
function load_all(int $kind, ?int $owner_uid = null, bool $skip_init = false): void {
$span = Tracer::start(__METHOD__);
$span->setAttribute('func.args', json_encode(func_get_args()));
@@ -447,7 +447,7 @@ class PluginHost {
/**
* @param PluginHost::KIND_* $kind
*/
function load(string $classlist, int $kind, int $owner_uid = null, bool $skip_init = false): void {
function load(string $classlist, int $kind, ?int $owner_uid = null, bool $skip_init = false): void {
$span = Tracer::start(__METHOD__);
$span->setAttribute('func.args', json_encode(func_get_args()));

View File

@@ -904,10 +904,12 @@ class Pref_Feeds extends Handler_Protected {
<div dojoType="dijit.layout.BorderContainer" gutters="false">
<div region='top' dojoType="fox.Toolbar">
<div style='float : right'>
<input dojoType="dijit.form.TextBox" id="feed_search" size="20" type="search"
value="<?= htmlspecialchars($feed_search) ?>">
<button dojoType="dijit.form.Button" onclick="dijit.byId('feedTree').reload()">
<?= __('Search') ?></button>
<form dojoType="dijit.form.Form" onsubmit="dijit.byId('feedTree').reload(); return false;">
<input dojoType="dijit.form.TextBox" id="feed_search" size="20" type="search"
value="<?= htmlspecialchars($feed_search) ?>">
<button dojoType="dijit.form.Button" type="submit">
<?= __('Search') ?></button>
</form>
</div>
<div dojoType="fox.form.DropDownButton">

View File

@@ -665,10 +665,12 @@ class Pref_Filters extends Handler_Protected {
<div dojoType='fox.Toolbar'>
<div style='float : right; padding-right : 4px;'>
<input dojoType="dijit.form.TextBox" id="filter_search" size="20" type="search"
value="<?= htmlspecialchars($filter_search) ?>">
<button dojoType="dijit.form.Button" onclick="dijit.byId('filterTree').reload()">
<?= __('Search') ?></button>
<form dojoType="dijit.form.Form" onsubmit="dijit.byId('filterTree').reload(); return false;">
<input dojoType="dijit.form.TextBox" id="filter_search" size="20" type="search"
value="<?= htmlspecialchars($filter_search) ?>">
<button dojoType="dijit.form.Button" type="submit">
<?= __('Search') ?></button>
</form>
</div>
<div dojoType="fox.form.DropDownButton">

View File

@@ -210,11 +210,13 @@ class Pref_Users extends Handler_Administrative {
<div dojoType='fox.Toolbar'>
<div style='float : right'>
<input dojoType='dijit.form.TextBox' id='user_search' size='20' type='search'
value="<?= htmlspecialchars($user_search) ?>">
<button dojoType='dijit.form.Button' onclick='Users.reload()'>
<?= __('Search') ?>
</button>
<form dojoType="dijit.form.Form" onsubmit="Users.reload(); return false;">
<input dojoType='dijit.form.TextBox' id='user_search' size='20' type='search'
value="<?= htmlspecialchars($user_search) ?>">
<button dojoType='dijit.form.Button' type='submit'>
<?= __('Search') ?>
</button>
</form>
</div>
<div dojoType='fox.form.DropDownButton'>

View File

@@ -193,14 +193,14 @@ class Prefs {
/**
* @return array<int, array<string, bool|int|null|string>>
*/
static function get_all(int $owner_uid, int $profile_id = null) {
static function get_all(int $owner_uid, ?int $profile_id = null) {
return self::get_instance()->_get_all($owner_uid, $profile_id);
}
/**
* @return array<int, array<string, bool|int|null|string>>
*/
private function _get_all(int $owner_uid, int $profile_id = null) {
private function _get_all(int $owner_uid, ?int $profile_id = null) {
$rv = [];
$ref = new ReflectionClass(get_class($this));

View File

@@ -1511,7 +1511,7 @@ class RSSUtils {
*
* @return array<int, array<string, string>> An array of filter action arrays with keys "type" and "param"
*/
static function get_article_filters(array $filters, string $title, string $content, string $link, string $author, array $tags, array &$matched_rules = null, array &$matched_filters = null): array {
static function get_article_filters(array $filters, string $title, string $content, string $link, string $author, array $tags, ?array &$matched_rules = null, ?array &$matched_filters = null): array {
$span = Tracer::start(__METHOD__);
$matches = array();

View File

@@ -62,7 +62,7 @@ class Sanitizer {
*
* @return false|string The HTML, or false if an error occurred.
*/
public static function sanitize(string $str, ?bool $force_remove_images = false, int $owner = null, string $site_url = null, array $highlight_words = null, int $article_id = null) {
public static function sanitize(string $str, ?bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null) {
$span = OpenTelemetry\API\Trace\Span::getCurrent();
$span->addEvent("Sanitizer::sanitize");

View File

@@ -1,7 +1,7 @@
<?php
class TimeHelper {
static function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string {
static function smart_date_time(int $timestamp, int $tz_offset = 0, ?int $owner_uid = null, bool $eta_min = false): string {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
if ($eta_min && time() + $tz_offset - $timestamp < 3600) {
@@ -21,7 +21,7 @@ class TimeHelper {
}
}
static function make_local_datetime(?string $timestamp, bool $long, int $owner_uid = null,
static function make_local_datetime(?string $timestamp, bool $long, ?int $owner_uid = null,
bool $no_smart_dt = false, bool $eta_min = false): string {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];

View File

@@ -58,7 +58,7 @@ class UserHelper {
}
}
static function authenticate(string $login = null, string $password = null, bool $check_only = false, string $service = null): bool {
static function authenticate(?string $login = null, ?string $password = null, bool $check_only = false, ?string $service = null): bool {
if (!Config::get(Config::SINGLE_USER_MODE)) {
$user_id = false;
$auth_module = false;
@@ -130,7 +130,7 @@ class UserHelper {
}
}
static function load_user_plugins(int $owner_uid, PluginHost $pluginhost = null): void {
static function load_user_plugins(int $owner_uid, ?PluginHost $pluginhost = null): void {
if (!$pluginhost) $pluginhost = PluginHost::getInstance();

View File

@@ -6,30 +6,33 @@
}
},
"repositories": [
{
{
"name": "j4mie/idiorm",
"type": "vcs",
"url": "https://dev.tt-rss.org/fox/idiorm.git"
}
],
"autoload": {
"psr-4": {
"": "classes/"
}
"type": "vcs",
"url": "https://dev.tt-rss.org/fox/idiorm.git"
}
],
"autoload": {
"psr-4": {
"": "classes/"
},
"files": [
"include/functions.php"
]
},
"require": {
"spomky-labs/otphp": "^10.0",
"chillerlan/php-qrcode": "^4.3.3",
"mervick/material-design-icons": "^2.2",
"j4mie/idiorm": "dev-master",
"require": {
"spomky-labs/otphp": "^10.0",
"chillerlan/php-qrcode": "^4.3.3",
"mervick/material-design-icons": "^2.2",
"j4mie/idiorm": "dev-master",
"open-telemetry/exporter-otlp": "^1.0",
"php-http/guzzle7-adapter": "^1.0",
"soundasleep/html2text": "^2.1",
"guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
"phpstan/phpstan": "1.10.3",
"phpunit/phpunit": "9.5.16",
},
"require-dev": {
"phpstan/phpstan": "1.10.3",
"phpunit/phpunit": "9.5.16",
"phpunit/php-code-coverage": "^9.2"
}
}
}

View File

@@ -155,8 +155,8 @@
/**
* @param array<string, mixed> $attributes
*/
function select_feeds_cats(string $name, int $default_id = null, array $attributes = [],
bool $include_all_cats = true, string $root_id = null, int $nest_level = 0, string $id = ""): string {
function select_feeds_cats(string $name, ?int $default_id = null, array $attributes = [],
bool $include_all_cats = true, ?string $root_id = null, int $nest_level = 0, string $id = ""): string {
$ret = "";

View File

@@ -41,7 +41,7 @@
*
* @deprecated by Prefs::get()
*/
function get_pref(string $pref_name, int $owner_uid = null) {
function get_pref(string $pref_name, ?int $owner_uid = null) {
return Prefs::get($pref_name, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null);
}
@@ -50,7 +50,7 @@
*
* @deprecated by Prefs::set()
*/
function set_pref(string $pref_name, $value, int $owner_uid = null, bool $strip_tags = true): bool {
function set_pref(string $pref_name, $value, ?int $owner_uid = null, bool $strip_tags = true): bool {
return Prefs::set($pref_name, $value, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null, $strip_tags);
}
@@ -211,7 +211,7 @@
*
* @return false|string The HTML, or false if an error occurred.
*/
function sanitize(string $str, bool $force_remove_images = false, int $owner = null, string $site_url = null, array $highlight_words = null, int $article_id = null) {
function sanitize(string $str, bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null) {
return Sanitizer::sanitize($str, $force_remove_images, $owner, $site_url, $highlight_words, $article_id);
}
@@ -250,17 +250,17 @@
}
/** @deprecated by UserHelper::authenticate() */
function authenticate_user(string $login = null, string $password = null, bool $check_only = false, string $service = null): bool {
function authenticate_user(?string $login = null, ?string $password = null, bool $check_only = false, ?string $service = null): bool {
return UserHelper::authenticate($login, $password, $check_only, $service);
}
/** @deprecated by TimeHelper::smart_date_time() */
function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string {
function smart_date_time(int $timestamp, int $tz_offset = 0, ?int $owner_uid = null, bool $eta_min = false): string {
return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min);
}
/** @deprecated by TimeHelper::make_local_datetime() */
function make_local_datetime(string $timestamp, bool $long, int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string {
function make_local_datetime(string $timestamp, bool $long, ?int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string {
return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min);
}

View File

@@ -4,7 +4,6 @@
use UserHelper;
require_once "autoload.php";
require_once "functions.php";
require_once "errorhandler.php";
require_once "lib/gettext/gettext.inc.php";

View File

@@ -12,7 +12,6 @@
require_once "autoload.php";
require_once "sessions.php";
require_once "functions.php";
Config::sanity_check();

View File

@@ -251,6 +251,27 @@ const CommonDialogs = {
alert(__("No feeds selected."));
}
},
debugSelected: function() {
const sel_rows = this.getSelectedFeeds();
if (sel_rows.length > 0) {
if (confirm(__("Debug selected feeds?"))) {
Notify.progress("Opening debugger for selected feeds...", true);
for (let i = 0; i < sel_rows.length; i++) {
/* global __csrf_token */
App.postOpenWindow("backend.php", {
op: "Feeds",
method: "updatedebugger",
feed_id: sel_rows[i],
csrf_token: __csrf_token,
});
}
}
} else {
alert(__("No feeds selected."));
}
},
content: `
<div dojoType="fox.Toolbar">
<div dojoType="fox.form.DropDownButton">
@@ -290,6 +311,9 @@ const CommonDialogs = {
<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' onclick='App.dialogOf(this).removeSelected()'>
${__('Unsubscribe from selected feeds')}
</button>
<button style='float : left' class='alt-info' dojoType='dijit.form.Button' onclick='App.dialogOf(this).debugSelected()'>
${__('Debug selected feeds')}
</button>
<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>
${__('Close this window')}
</button>

View File

@@ -11,7 +11,6 @@
require_once "autoload.php";
require_once "sessions.php";
require_once "functions.php";
Config::sanity_check();

View File

@@ -4,7 +4,6 @@
require_once "autoload.php";
require_once "sessions.php";
require_once "functions.php";
Config::sanity_check();

View File

@@ -3,4 +3,3 @@
get_include_path());
require_once "autoload.php";
require_once "functions.php";

View File

@@ -8,7 +8,6 @@
chdir(__DIR__);
require_once "autoload.php";
require_once "functions.php";
if (php_sapi_name() != "cli") {

View File

@@ -9,7 +9,6 @@
define('DISABLE_SESSIONS', true);
require_once "autoload.php";
require_once "functions.php";
Config::sanity_check();

File diff suppressed because it is too large Load Diff

View File

@@ -114,4 +114,5 @@ return array(
'157bbd0180425c7142fbaf1b1646bec3' => $vendorDir . '/open-telemetry/exporter-otlp/_register.php',
'9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
'1c27df0e838db1c8a6427db7c5db3db2' => $baseDir . '/include/functions.php',
);

File diff suppressed because it is too large Load Diff