56 Commits

Author SHA1 Message Date
Alexandre Alapetite
a18c35046d Housekeeping lib_rss.php (#8193)
* Housekeeping lib_rss.php
`lib_rss.php` had become much too large, especially after https://github.com/FreshRSS/FreshRSS/pull/7924
Moved most functions to other places.
Mostly no change of code otherwise (see comments).

* Extension: composer run-script phpstan-third-party
2025-11-11 08:17:12 +01:00
Alexis Degrugillier
72884813e1 Add hook enums (#8036)
- add an enum to handle hook types (enum are available since PHP 8.1)
- change hook calls from string value to enum value
2025-09-30 22:59:41 +02:00
Alexis Degrugillier
23ba48c71f Change how files are included (#7916)
1. `include`, `include_once`, `require` and `require_once` are expressions not functions, parentheses are not necessary.
2. to move up the directory tree, it's better to use the `dirname` function instead of relying on `/..`.
2025-09-05 15:56:46 +02:00
Alexandre Alapetite
b1d24fbdb7 PHPStan 2.0 (#7131)
* PHPStan 2.0
fix https://github.com/FreshRSS/FreshRSS/issues/6989
https://github.com/phpstan/phpstan/releases/tag/2.0.0
https://github.com/phpstan/phpstan/blob/2.0.x/UPGRADING.md

* More

* More

* Done

* fix i18n CLI

* Restore a PHPStan Next test
For work towards PHPStan Level 10

* 4 more on Level 10

* fix getTagsForEntry

* API at Level 10

* More Level 10

* Finish Minz at Level 10

* Finish CLI at Level 10

* Finish Controllers at Level 10

* More Level 10

* More

* Pass bleedingEdge

* Clean PHPStan options and add TODOs

* Level 10 for main config

* More

* Consitency array vs. list

* Sanitize themes get_infos

* Simplify TagDAO->getTagsForEntries()

* Finish reportAnyTypeWideningInVarTag

* Prepare checkBenevolentUnionTypes and checkImplicitMixed

* Fixes

* Refix

* Another fix

* Casing of __METHOD__ constant
2024-12-27 12:12:49 +01:00
Alexandre Alapetite
bfd277065c Improve feed refresh (#6117)
* Improve feed refresh
Better account for some edge cases for cron and automatic labels
fix https://github.com/FreshRSS/FreshRSS/issues/6089
fix https://github.com/FreshRSS/FreshRSS/issues/6109

* Apply labels also to new entries already marked as read

* Add case most relevant for cron
2024-02-26 09:01:25 +01:00
Alexandre Alapetite
a80a5f48a1 Pass PHPStan level 8 (#5946)
* Pass PHPStan level 8
And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels

* Revert wrong replace in comment

* Fix PHPStan level 8

* Update PHPStan and other dev dependencies

* Remove obsolete comment

* noVariableVariables and towards bleedingEdge
https://github.com/phpstan/phpstan-strict-rules
https://phpstan.org/blog/what-is-bleeding-edge

* More bleedingEdge

* A bit more PHPStan level 9

* More PHPStan level 9

* Prepare for booleansInConditions
Ignore int and null

* Revert wrong line

* More fixes

* Fix keep_max_n_unread

* Stricter attribute functions

* Stricter callHooks and more PHPStan level 9

* More typing

* A tiny more
2023-12-18 17:59:16 +01:00
Alexandre Alapetite
f0d4f2762d Rework keepmax (#5905)
* Rework keepmax
fix https://github.com/FreshRSS/FreshRSS/issues/5702
fix https://github.com/FreshRSS/FreshRSS/issues/5870

* More WIP

* Minor progress

* Progress

* Beta

* Improved debug message

* Revert noCommit

* Fix variable reset

* Remove debug syslogs
2023-12-03 19:52:02 +01:00
Alexandre Alapetite
b65ea97901 Fix PHP 7 compatibility strict_types (#5893)
* Fix PHP 7 compatibility
https://github.com/FreshRSS/FreshRSS/discussions/5892

* Multiple PHP 7 fixes

* PHPStan
2023-11-18 23:21:20 +01:00
Luc SANCHEZ
30c7a61a9b Use strict_types (#5830)
* Little's optimisations and booleans in conditions

* Apply strict type

* Apply strict type

* Apply strict type

* Fix multiple bugs with PHP 8.2 and 8.3

* Many declares missing, more errors fixed

* Apply strict type

* Another approach

* Stronger typing for Minz_Session

* Fix case of SQLite

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-11-16 22:43:00 +01:00
Alexandre Alapetite
6e2f2f1c1e A few additional PHPStan rules (#5388)
A subset of
https://github.com/phpstan/phpstan-strict-rules
2023-05-11 13:02:04 +02:00
Alexandre Alapetite
30c69ef147 Use PHPStan dynamicConstantNames (#5370)
https://phpstan.org/config-reference#constants
Avoid a few phpstan-ignore-next-line
2023-05-04 19:47:54 +02:00
Alexandre Alapetite
f3760f138d Complete PHPStan Level 6 (#5305)
* Complete PHPStan Level 6
Fix https://github.com/FreshRSS/FreshRSS/issues/4112
And initiate PHPStan Level 7

* PHPStan Level 6 for tests
* Use phpstan/phpstan-phpunit
* Update to PHPStan version 1.10

* Fix mixed bug

* Fix mixed return bug

* Fix paginator bug

* Fix FreshRSS_UserConfiguration

* A couple more Minz_Configuration bug fixes

* A few trivial PHPStan Level 7 fixes

* A few more simple PHPStan Level 7

* More files passing PHPStan Level 7
Add interface to replace removed class from https://github.com/FreshRSS/FreshRSS/pull/5251

* A few more PHPStan Level 7 preparations

* A few last details
2023-04-17 08:30:21 +02:00
Alexandre Alapetite
36aa0122e1 Fix extensions in actualize_script (#5243)
* Fix extension freshrss_user_maintenance in actualize_script
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/3440

The hook was called before registering all the extensions for the current user

* PHPStan Level 6 for extensions
And remove 5-year old legacy format of enabled extensions < FreshRSS 1.11.1

* Fix multiple bugs in extensions

* Minor typing

* Don't change signature of methods supposed to be overridden

* PHPStan Level 9 and compatibility Intelliphense

* Set as final the methods not supposed to be overriden
2023-04-04 10:23:26 +02:00
Alexandre Alapetite
0f5e321c0b Mutex for actualize script (#5235)
* Simplify extension method
One parameter was not used

Furthermore, that unused parameter was preventing simpler calls (i.e. without a dedicated extension class). Now it is possible to register a call back with a lamda:

```php
Minz_ExtensionManager::addHook('feed_before_actualize', function () {
	// Hello
});
```

* Mutex for actualize script
In the case of extremely long cron jobs that are refreshing feeds, a cron job might start before the previous one has completed, leading to an accumulation of cron jobs running in parallel.
Although we already have a mutex preventing concurrency problems on a single feed refresh, the problem occurs in particular if each feed can take a long time (e.g. due to heavy processing, which is my usecase).
https://github.com/FreshRSS/FreshRSS/pull/5234 must be merged first

* Fiw wrong return
2023-03-31 08:24:31 +02:00
Alexandre Alapetite
f3af3f0f3d Automated test towards PHPStan level 6 (#5230)
* Automated test towards PHPStan level 6
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112
With this automated tests, files that are passing Level 6 are tested to avoid regressions towards Level 5 (which is the current baseline for the whole code-base)

It is included when calling `make test-all` or can be called specifically by `composer run-script phpstan-next`

* Test and example with 3 new passing files
2023-03-26 23:19:41 +02:00
maTh
4214954ea1 Improved: error page (#4465)
* error page: true HTML page

* error page: http500 erorr

* error page: add CSP header

* 'log.txt' replaced by LOG_FILENAME

* use ADMIN_LOG

* log.txt => LOG_FILENAME

* error message: add <title>

* Docs created

* delete: documentation on error message page

* line break added

* added: new line at the end

* typo fixed

* Update lib/lib_rss.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update lib/lib_rss.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Minz HTTP 500

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2022-08-21 22:44:03 +02:00
Alexandre Alapetite
1acd3ab09b Use typographic quotes (#4133)
* Use typographic quotes

* A few fixes

* Fix

* Fix not saved

* Implement feedback

* Detail

* Revert spoken English fixes
Left for a future dedicated discussion

* More reverts

* Final reverts

* Final minor
2022-01-08 21:58:55 +01:00
Alexandre Alapetite
1335a0e3cf PHPStan level 5 (#4110)
* Fix most PHPDocs errors
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103
https://phpstan.org/writing-php-code/phpdoc-types

* Avoid func_get_args
Use variadic syntax instead https://php.net/manual/functions.arguments#functions.variable-arg-list
And avoid dynamic functions names when possible to more easily identify calls and unused functions.
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103

* PHPStan level 3

* PHPStand level 4

* Update default to PHPStan level 4

* Towards level 5

* Fix level 4 regression

* Towards level 5

* Pass PHPStan level 5

* Towards level 6

* Remove erronenous regression from changelog
https://github.com/FreshRSS/FreshRSS/pull/4116
2022-01-04 13:59:09 +01:00
Alexandre Alapetite
77e9877316 Add PHPStan (#4021)
* Add PHPStan
#fix https://github.com/FreshRSS/FreshRSS/issues/4016
https://phpstan.org/

```sh
composer run-script phpstan
```

* More fixes

* Fix global variables

* Add .phtml

* Fix merge
https://github.com/FreshRSS/FreshRSS/pull/4090

* Fix more warnings

* Fix view errors and enable in CI

* ReturnTypeWillChange

* Dynamic view type

* Fix Minz static/self bug
2021-12-31 17:00:51 +01:00
Alexis Degrugillier
787e8fa463 Add user maintenance hooks (#3440)
The new hook allows to add maintenance extensions at the user level.

See #3398
2021-02-17 16:34:54 +01:00
Alexandre Alapetite
d42b4c299c Add requirements check in CLI (#3410)
* Add requirements check in CLI

#fix https://github.com/FreshRSS/FreshRSS/issues/1853

* More checks

#fix https://github.com/FreshRSS/FreshRSS/issues/1853
2021-02-05 22:21:31 +01:00
Alexandre Alapetite
9c6682e7ed Avoid manual initialisations of system or user configuration (#3070)
* Avoid manual intialisations of system or user configuration

More consistent use of Context

* Simplify FreshRSS_Context::initUser

* Remove a few manual get_user_configuration

* A bit of debugging

* Fix context user init

* Fix install

* Fix concurrency

Concurrent requests could lead to bad race condition

* Fix actualize cron

Fix case when system i initialised several times
2021-01-02 21:20:19 +01:00
Alexandre Alapetite
0319cc9d23 Minz allow parallel sessions (#3096)
* Minz allow parallel sessions

#fix https://github.com/FreshRSS/FreshRSS/issues/3093

* Array optimisation

* Array optimisation missing

* Reduce direct access to $_SESSION except in install process

* Fix session start headers warning

* Use cookie only the first time the session is started:
`PHP Warning:  session_start(): Cannot start session when headers
already sent in /var/www/FreshRSS/lib/Minz/Session.php on line 39`

* New concept of volatile session for API calls

Optimisation: do not use cookies or local storage at all for API calls
without a Web session
Fix warning:

```
PHP Warning:  session_destroy(): Trying to destroy uninitialized session
in Unknown on line 0
```

* Only call Minz_Session::init once in our index

It was called twice (once indirectly via FreshRSS->init())

* Whitespace

* Mutex for notifications

Implement mutex for notifications
https://github.com/FreshRSS/FreshRSS/pull/3208#discussion_r499509809

* Typo

* Install script is not ready for using Minz_Session
2020-10-06 23:19:45 +02:00
Alexis Degrugillier
caeb660f29 Add a way to disable/enable users (#3056)
If you want to block users without deleting their account, you can now
disable them from the interface.
2020-06-14 19:50:09 +02:00
Alexis Degrugillier
1694264e2c Modify shebang to be more portable (#3038)
The new shebang is a portable way to find the php interpreter. It works
on Mac, GNU/Linux and BSD.
2020-06-06 19:04:21 +02:00
Alexandre Alapetite
6f3e5d99b4 Revert to STDOUT for cron messages (#2979)
#fix https://github.com/FreshRSS/FreshRSS/issues/2975
2020-05-15 18:23:15 +02:00
Craig Andrews
62a42a2063 Delay the feeds actualization start notice (#2974)
* Delay the feeds actualization start notice

Move the actualization start notice until after SIMPLEPIE_SYSLOG_ENABLED is defined.

Fixes https://github.com/FreshRSS/FreshRSS/issues/2973

* Update app/actualize_script.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2020-05-15 17:23:20 +02:00
Alexandre Alapetite
11dd6e91b7 Improve logs during cron actualization (#2964)
For
https://github.com/FreshRSS/FreshRSS/issues/2952#issuecomment-626218921
And fix a little bug writing logs with the wrong user name
2020-05-14 21:21:39 +02:00
Alexandre Alapetite
aea3806590 Attempt to reduce max memory usage during actualize (#2955)
* Attempt to reduce max memory usage during actualize

#Fix https://github.com/FreshRSS/FreshRSS/issues/2952

* Use memory_get_peak_usage
2020-05-10 21:34:12 +02:00
Alexandre Alapetite
acc50df0ef Fix logging environment constants (#2745)
* Fix logging environment constants

* COPY_LOG_TO_SYSLOG was only working when Syslog was used
* FRESHRSS_ENV was not properly used to set logging level

* Simplify code

Always call `openlog()` even when it is not used

* Always specify syslog properties

https://github.com/FreshRSS/FreshRSS/pull/2745#discussion_r362207445

* $username is also needed further down

* No new line in syslog
2020-01-03 18:50:33 +01:00
Alexandre Alapetite
802c264574 Copy syslog to STDERR (#2208)
* Use openlog before syslog
In order to have a copy on stderr when syslog is not available.

* Take advantage of syslog for actualization
Pipe cron job STDERR and syslog to Docker log
Cf. 00bd467655
2019-01-06 00:46:48 +01:00
David souza
7e9a29b719 add shebang to actualize script (#1886)
* add shebang to actualize script

* Update actualize_script.php
2018-05-20 12:27:17 +02:00
Alexandre Alapetite
26d4ba63d6 Merge branch 'dev' into logfilesize 2017-12-10 22:12:07 +01:00
Kevin Papst
5c52d9b34b Check requirement in CLI script (#1711)
* check requirements in actualize_script before executing, fixes #1710

* removed empty whiteline

* testing all requirements

* incorporated code review feedback

* removed code that is already executed in _cli.php

* added newline at eof

* fixed include problems

* fixed include problems
2017-12-10 22:09:54 +01:00
Alexandre Alapetite
b1c317a253 Log rotation, use Minz_Log, new log constants
ADMIN_LOG, API_LOG, PSHB_LOG
2017-12-10 21:58:24 +01:00
Alexandre Alapetite
e1f214e9e2 CLI list-users and create-user
https://github.com/FreshRSS/FreshRSS/issues/1095
https://github.com/FreshRSS/FreshRSS/issues/1090
2016-10-22 12:58:06 +02:00
Alexandre Alapetite
e8d1a6dcc9 Cron refresh favicons
Related to
https://github.com/FreshRSS/FreshRSS/issues/1181
https://github.com/FreshRSS/FreshRSS/issues/1298
2016-10-12 15:47:04 +02:00
Marien Fressinaud
59ea9f2a3b Remove calls to syslog()
Temporary fix:

- Change syslog by Minz_Log::notice in most of the files
- Logs are stored in USERS_PATH/_/log.txt for actualize_script.php
- Simply comment syslog in SimplePie

See https://github.com/FreshRSS/FreshRSS/issues/711
2015-01-29 10:14:45 +01:00
Alexandre Alapetite
12081f7ba2 Quick fix cron actualization due to problematic FreshRSS constructor/init
https://github.com/FreshRSS/FreshRSS/issues/759
Suggestion: the static objects should be user-independent (or at least
with the possibility to be re-set), while the FreshRSS object and its
attributes should be user-dependent.
2015-01-20 23:29:04 +01:00
Marien Fressinaud
c96e1d9aec Coding style in actualize_script 2015-01-06 23:07:57 +01:00
Marien Fressinaud
cf406fc575 Fix a bug of authentication in actualize_script
See https://github.com/FreshRSS/FreshRSS/issues/730
2015-01-06 23:06:17 +01:00
Marien Fressinaud
5cdfd6d493 Fix and improve actualize_script
See https://github.com/FreshRSS/FreshRSS/issues/730
2015-01-06 22:12:48 +01:00
Marien Fressinaud
c391ca62f1 Remove all old references to LOG_PATH
See https://github.com/FreshRSS/FreshRSS/issues/729
2014-12-28 18:05:02 +01:00
Alexandre Alapetite
9f97f7df88 Ne pas rafraîchir les flux des utilisateurs non logués depuis x jours
https://github.com/marienfressinaud/FreshRSS/issues/681
Warning: needs some testing
2014-10-29 00:45:42 +01:00
Luc Didry
e861e5789d Fix errors + improvements on bug #683 fix. 2014-10-26 19:00:00 +01:00
Luc Didry
956896bf87 Fixes #683 2014-10-26 17:01:31 +01:00
plopoyop
fe29390006 start with admin only if exists 2014-10-20 22:28:40 +02:00
Alexandre Alapetite
5081ffaf39 Minz: remove one layer of ob_ (experimental)
https://github.com/marienfressinaud/FreshRSS/issues/303#issuecomment-38351311
https://github.com/marienfressinaud/FreshRSS/issues/163
* Remove Minz_Response (not needed anymore)
* Move Minz_Request::reseted to Minz_Dispatcher::reset()
2014-03-22 17:56:07 +01:00
Alexandre Alapetite
0cabd1f50d Mutex par flux pour les actualisations
Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351
Nouvelle constante TMP_PATH comme répertoire pour stocker des fichiers
temporaires (si possible en mémoire et non sur disque, tel tmpfs pour
/tmp sur certaines distributions Linux)
Requiert PHP 5.2.1+ (contre 5.2.0 auparavant) pour le
`sys_get_temp_dir()`
2014-02-11 21:48:10 +01:00
Alexandre Alapetite
5e9c60752c Actualize : Tolère PHP lancé en CGI plutôt que CLI
Corrige https://github.com/marienfressinaud/FreshRSS/issues/405
+ Message d'erreur en cas de problème de droits dans ./data/ (par
exemple si le cron utilise un mauvais utilisateur)
2014-02-01 12:23:12 +01:00