35 Commits

Author SHA1 Message Date
Alexandre Alapetite
1a3912f25a Improve configuration checks (#8334)
Add a distinction between recommended and required extensions.
Add check for recommended php-intl extension as follow-up of https://github.com/FreshRSS/FreshRSS/pull/8329#issuecomment-3677686581
Improve related checks such as ZIP.
Reduce duplicated translations and tests.
2025-12-21 19:26:08 +01:00
Alexis Degrugillier
6ad625812a Add a default language constant (#7933)
This replace the use of `en` through out the code.
2025-09-09 22:01:04 +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
56d1d4f194 Remove unneeded execution permissions (#7802) 2025-08-08 22:39:33 +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
a81656c3ed Upgrade to PHP 8.1 (#6711)
* Upgrade to PHP 8.1
As discussed in https://github.com/FreshRSS/FreshRSS/discussions/5474

https://www.php.net/releases/8.0/en.php
https://www.php.net/releases/8.1/en.php

Upgrade to available native type declarations
https://php.net/language.types.declarations

Upgrade to https://phpunit.de/announcements/phpunit-10.html which requires PHP 8.1+ (good timing, as version 9 was not maintained anymore)

Upgrade `:oldest` Docker dev image to oldest Alpine version supporting PHP 8.1: Alpine 3.16, which includes PHP 8.1.22.

* Include 6736
https://github.com/FreshRSS/FreshRSS/pull/6736
2024-09-06 09:06:46 +02:00
Kasimir Cash
4b29e666b0 Command Line Parser Concept (#6099)
* Adds logic for validation

* Adds validation to do-install

* Adds help to do-install

* Adds validation & help to reconfigure

* Adds validation to check.translation

* Adds validation to manipulate.translation

* Small fixes to help texts

* Refactors language option validation

* Adds default options to validation

* Fixes validation with regex

* Refactors readAs functions

* Updates to new regex validation format

* Fixes typing around default values

* Adds file extension validation

* Restandardises validation & parsing typing around array of strings

* Adds NotOneOf validation

* Adds ArrayOfString read as

* Refactors existing validation

* Adds validation throughout cli

* Removes unused file

* Adds new CL parser with goal of wrapping CLI behaviour

* Hides parsing and validation

* Rewites CL parser to make better use of classes

* Rolls out new parser across CL

* Fixes error during unknown option check

* Fixes misnamed property calls

* Seperates validations into more appropriate locations

* Adds common boolean forms to validation

* Moves CommandLineParser and Option classes into their own files

* Fixes error when validating Int type

* Rewrites appendTypedValues -> appendTypedValidValues now filters invalid values from output

* Renames  ->  for clarity

* Adds some docs clarifying option defaults and value taking behaviour

* Refactors getUsageMessage for readability

* Minor formatting changes

* Adds tests for CommandLineParser

* Adds more tests

* Adds minor fixs

* Reconfigure now correctly updates config

* More fixes to reconfigure

* Fixes required files for CommandLineParserTest

* Use .php extension for PHP file

* PHPStan ignore instead of wrong typing

* Refactors to support php 7.4

* Moves away from dynamic properties by adding 'Definintions' to all commands

* Renames target to definition for clarity

* Stops null from being returned as a valid value in a certain edge case

* Adds PHPStan ignore instead of incorrect typing

* Refactors tests to take account of new typing solution

* Marks file as executable

* Draft CLI rework

* Finish rewrite as object-oriented

* Fix PHPStan ignore and make more strongly typed

* Rename class Option to CliOption

* Light renaming + anonymous classes

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2024-02-28 13:23:28 +01:00
Kasimir Cash
6d14813840 Standardise command line option parsing (#6036)
* Separates long & short options for parsing

* Adds parsing for short options + doc rewrites

* Fixes undefined constant in check.translation

* Standardises CL option parsing

* Refactors option parsing

* Renames getLongOptions -> getOptions

* Removes unused code

* Converges on string typing for options

* Updates docs & help files

* Updates array syntax array( ) -> [ ]
2024-01-17 08:42:43 +01:00
Kasimir Cash
9a80dde238 2297 cli parameters consistency (#6028)
* Updates do-install params

* Adds parseCliParams to _cli.php

* Updates do-install to use parseCliParams

* Updates reconfigure to use parseCliParams

* Fixes bug mail_login => email

* Update create-user to use parseCliParams

* Minor refactor

* Updates update-user to use parseCliParams

* Fix no_default_feeds => no-default-feeds

* Refactors arrays

* Updates CLI Readme

* Adds docblocks to _cli functions

* Sets vars in _cli functions

* Fixes indentation

* Meeting coding standards around colons

* Meeting PHPStan standards

* Removes stray whitespace

* Meeting PHPStan Next Level standards

* More specific typing

* Maintaining types

* Typing around getopt()

* Fixes typo

* Fixes typo perameters -> parameters

* Removes unused variable

* Rewrites deprecation warning message
2024-01-09 23:01:17 +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
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
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
3f1695db03 PHPStan 6 for CLI (#5258)
* PHPStan 6 for CLI
Except `./cli/i18n/`

* Bool

* One type forgotten
2023-04-05 16:19:14 +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
e899e4edd9 More robust application of access permissions (#5062)
* More robust application of access permissions
We were in particular missing directory traversal `+X` in our current recommendations.
Extracted to own shell script so it can easily be invoked.
Update access permissions in Docker to account to be more robust.
#fix https://github.com/FreshRSS/FreshRSS/discussions/5037

* Minor simplification

* Restrict mkdir permissions
Default mkdir permissions are 0777, which is not good for security, so downgrade to 0770.
2023-02-06 15:42:53 +01:00
Alexandre Alapetite
7d83321286 Better catch when a user does not exists (#3751)
#fix https://github.com/FreshRSS/FreshRSS/issues/3735
Before, we were relying on an exception during the first stages of user initalisation. Now the check is explicit and cleaner, producing a more appropriate HTTP response for the API.
2021-08-14 12:22:42 +02:00
Alexandre Alapetite
3499f8f1d1 Extensions in CLI (#3443)
* Extensions in CLI

https://github.com/FreshRSS/FreshRSS/pull/3440#discussion_r574659745

* Also user extensions
2021-02-26 19:34:02 +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
Alexis Degrugillier
eb51fd713a Fix coding standard (#3363)
Merged code was not following coding standard. Thus breaking all CI tests.
2021-01-12 16:49:46 +01:00
Alexandre Alapetite
8dfe209799 Possiblity to autoinstall in Docker Compose (#3353)
* Possiblity to autoinstall in Docker Compose

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

It is simply calling our existing CLI: do-install.php and
create-user.php
https://github.com/FreshRSS/FreshRSS/tree/master/cli

FreshRSS will typically be ready a few seconds before the database, so
introduce a tolerance when the database is not available / up (yet) by
trying a few times to connect. Also useful to avoid service interruption
when DB service is restarted.

Example:

```yml
freshrss-app:
    image: freshrss/freshrss
    container_name:
freshrss-app
    hostname: freshrss-app
    restart: unless-stopped

ports:
      - "8080:80"
    depends_on:
      - freshrss-db

volumes:
      - data:/var/www/FreshRSS/data
      -
extensions:/var/www/FreshRSS/extensions
    environment:
      CRON_MIN:
'*/20'
      FRESHRSS_ENV: development
      FRESHRSS_INSTALL: |-

--api_enabled
        --base_url https://rss.example.net

--db-base freshrss
        --db-host freshrss-db
        --db-password
freshrss
        --db-type pgsql
        --db-user freshrss

--default_user admin
        --language en
      FRESHRSS_USER: |-

--api_password freshrss
        --email user@example.net

--language en
        --password freshrss
        --user admin
      TZ:
Europe/Paris
```

* Minor type f in find

* shellcheck
2021-01-11 22:36:50 +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
Alexandre Alapetite
f1d1d46651 Fix CLI bug regarding an empty user (#2646)
Fix https://github.com/FreshRSS/FreshRSS/issues/2644
2019-11-08 23:11:35 +01:00
Alexis Degrugillier
71b4226dc7 Add an option validation on cli commands (#2278)
If an option used on cli is not recognized, the command
aborts and displays an error message.
If the typed option is similar to one of the recognized
options, a hint is displayed.

At the moment, there is a limitation on long options.
Short options are not validated at the moment.

See #2046
2019-03-19 20:27:06 +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
Alexandre Alapetite
52d0988655 Use __DIR__ for relative include and require
For uniformity, and to avoid having PHP searching in include_path.
http://php.net/manual/function.include.php
https://github.com/FreshRSS/FreshRSS/pull/1715
https://github.com/FreshRSS/FreshRSS/pull/1711#issuecomment-350581350
2017-12-11 21:11:34 +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
af8960b8b3 Move default configuration files
https://github.com/FreshRSS/FreshRSS/issues/1531
2017-05-12 23:33:58 +02:00
Clément
4eeae5171b use function with preg_match to check username 2017-02-16 18:54:59 +01:00
Clément
8d2b76334c Possibility to register user having a '-', a '_' or a '.' in username 2017-02-16 14:27:45 +01:00
Alexandre Alapetite
ab4ece6780 CLI do-install
https://github.com/FreshRSS/FreshRSS/issues/1095
https://github.com/FreshRSS/FreshRSS/issues/1090
2016-10-24 01:41:09 +02:00
Alexandre Alapetite
fcb9280fc8 CLI export
ZIP export, OPML export.
Corrected height of feeds select in Pafat theme.
https://github.com/FreshRSS/FreshRSS/pull/1338
https://github.com/FreshRSS/FreshRSS/issues/1039
https://github.com/FreshRSS/FreshRSS/issues/1277
2016-10-23 13:37:48 +02:00
Alexandre Alapetite
1b8eb6c7e7 CLI import ZIP/OPML/JSON for user
https://github.com/FreshRSS/FreshRSS/issues/1095
https://github.com/FreshRSS/FreshRSS/issues/851
2016-10-23 01:46:14 +02: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