Commit Graph

738 Commits

Author SHA1 Message Date
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
0a38aa7456 Automatic trusted_sources during install (#5358)
* Automatic trusted_sources during install
Fix https://github.com/FreshRSS/FreshRSS/issues/5357

* Fix install for http_auth

* Update lib/lib_rss.php

Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>

* Fill null exception e-mail

* Revert some syntax

* Minor parentheses
2023-05-03 00:37:04 +02:00
Alexandre Alapetite
c72914bba2 PHPStan Level 7 for more DAO PDO (#5328)
* PHPStan Level 7 for more DAO PDO
With new function to address common type and check problems

* A bit more

* PHPStan Level 7 for FreshRSS_Entry
2023-04-28 14:01:11 +02:00
Alexandre Alapetite
5579dc88ab Better XPath failure (#5317)
Report feeds as errored for more cases
2023-04-20 08:21:37 +02:00
Alexandre Alapetite
ecd956c736 PHPStan 7 configureController (#5318)
And fix bugs for saving user queries
2023-04-20 00:55:10 +02:00
Alexandre Alapetite
ef82e218ea PHPStan Level 7 Minz_ActionController and lib_date (#5313) 2023-04-19 09:16:48 +02:00
Alexandre Alapetite
687d0b40a8 Fix safe_ascii (#5311)
Fix https://github.com/FreshRSS/FreshRSS/issues/5310
2023-04-17 19:53: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
b3121709d6 PHPStan Level 6 FreshRSS_Search FreshRSS_Entry (#5292)
* PHPStan Level 6 FreshRSS_Search FreshRSS_Entry

* Minor fix

* Type fix

* Apply suggestions from code review

Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>

* Minor types syntax
Compatibility Intelephense

---------

Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
2023-04-14 14:23:45 +02:00
Luc SANCHEZ
6e7fa07a39 PHPstan level 6 for Dispatcher.php (#5290)
* PHPstan level 6 for Dispatcher.php

* PHPstan level 6 for Dispatcher.php

* Minor fixes

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-04-12 13:11:28 +02:00
Luc SANCHEZ
594d118bc4 PHPstan level 6 for Migrator.php (#5283)
* PHPstan level 5 for Migrator.php

* PHPstan level 5 for Migrator.php

* Update lib/Minz/Migrator.php

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

* Update lib/Minz/Migrator.php

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

* Update lib/Minz/Migrator.php

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

* Update lib/Minz/Migrator.php

* Update lib/Minz/Migrator.php

* Fix type

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-04-11 13:39:04 +02:00
Luc SANCHEZ
03129a2ee7 PHPStan for Minz_Session class (#5282)
* PHPstan level 8 for Session.php

* PHPstan level 8 for Session.php

* PHPstan level 8 for Session.php

* Update lib/Minz/Session.php

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

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-04-10 22:35:40 +02:00
Alexandre Alapetite
90bf0ecd81 PHPStan 9 for lib/http-conditional.php (#5277)
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112
2023-04-10 12:42:06 +02:00
Alexandre Alapetite
743ca371bb PHPStan Level 6 for more files (#5275)
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112
2023-04-08 17:37:42 +02:00
Alexandre Alapetite
b6ac505f8f Fix login (#5271)
Fix https://github.com/FreshRSS/FreshRSS/issues/5270
2023-04-07 16:12:03 +02:00
Alexandre Alapetite
dbbae15a84 Remove ConfigurationSetter (#5251)
This class has not been maintained for a while. Only a subset of our configuration properties are there, and some code is not relevant anymore. Furthermore, it is relying exclusively on dynamically invoked functions, making it challenging to maintain, in particular to find out what is used and what is not, what is handled and what is not.
It is not well suited for changes in data formats, which have been handled in the Context class instead.
It is also not able to handle configuration properties that are missing.
It is the class with most errors for PHPStan level 6 (179 errors). It is also making intense use of is_callable and call_user_func_array, which are performance killers.
Should the need arrise again to perform validation of our internal configuration files, I suggest an implementation with the opposite approach, namely driven by our code instead of driven by the data.
In summary, at the moment, this class is costly, while not offering many guarantees.
2023-04-07 12:40:43 +02:00
Luc SANCHEZ
d23d10bcde Phpstan Level6 for View.php (#5269)
* Remarque's from Alkarex

* indentation

* indentation

* Apply suggestions from code review

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

* Remarque's from Alkarex

* A few improvements

* Remarque's from Alkarex

* Remarque's from Alkarex

* Remarque's from Alkarex

* Remarque's from Alkarex

* Fixes and improvments

* Fix getTagsForEntry

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-04-07 12:32:10 +02:00
Alexandre Alapetite
6c01e4e7d6 Use typed access to request parameters (#5267)
* Use typed access to request parameters
This was a big source of mixed datatypes in many places

* Fix notifications

* Fix bookmarkAction
2023-04-07 00:13:49 +02:00
Alexandre Alapetite
2118448133 PHPStan level 6 for more files (#5264)
7 more files passing (see phpstan-next.txt)
2023-04-05 23:26:38 +02:00
Luc SANCHEZ
4f078958b5 Fix phpstan level 9 error for f.php and lib/favicons.php (#5263)
* Fix phpstan level 9 error

* Fix phpstan level 9 error

* Remarque's from Alkarex

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
2023-04-05 22:28:34 +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
288ed04ccc PHPStan level 6 for all PDO and Exception classes (#5239)
* PHPStan level 6 for all PDO and Exception classes
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112

* Fix type

* Now also our remaining own librairies

* Motivation for a few more files

* A few more DAO classes

* Last interface
2023-03-31 08:23:39 +02:00
Alexandre Alapetite
6a5857ea5f Simplify extension method (#5234)
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
});
```
2023-03-29 21:31:25 +02:00
Luc SANCHEZ
0317683155 Add test and type hinting (#5087)
* - Add test and type hinting
- pass PhpStan Level 9

* fix dump

* fix style

* fix visibility

* fix style

* add test

* add test

* add test

* add test

* add test

* Simplify

* cleaning after test

* remove space

* fix style

* use specific log file for test

* Remarque's from Alkarex

* A few more details

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-03-27 00:36:21 +02:00
Luc SANCHEZ
5f898dcc5e Modernize Constants and use new constant for string 'currentUser' (#5089)
* Modernize Constants and use new constant 'currentUser'

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Update app/Controllers/userController.php

* Update app/Controllers/userController.php

* Update app/Controllers/userController.php

* Update app/Models/Auth.php

* Update p/api/greader.php

* Update p/api/greader.php

* Update p/api/greader.php

* Update app/Models/Context.php

* Update app/Models/LogDAO.php

* Update lib/Minz/Log.php

* Update p/api/greader.php

* Update app/layout/header.phtml

* Update app/views/helpers/export/articles.phtml

* Update cli/do-install.php

* Remarque's from Alkarex

* Remarque's from Alkarex

* Refactor using new Minz_User class

* Consistent naming of public constants

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-03-26 14:17:22 +02:00
Alexandre Alapetite
edee27ff0f Merge SimplePie 747 (#5199)
* Merge SimplePie 747
#fix https://github.com/FreshRSS/FreshRSS/issues/5195

Upstream https://github.com/simplepie/simplepie/pull/747

* Syntax error
2023-03-13 13:10:09 +01:00
berumuron
165a6b7347 Update lib_opml to v0.5.1 (#5188) 2023-03-10 20:04:46 +01:00
Konrad Gräfe
16472fd427 Fix MySQL UNIX socket support (#5166)
MySQL uses different parameters for passing UNIX socket pathts
(unix_socket) and TCP sockets (host) in contrast to PosgreSQL which uses
one for both (host).

Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
2023-03-05 18:00:04 +01:00
maTh
068d18b69b Add: <meta name="theme-color"> (#5105)
* implemented

* themes' metadata.json

* fix

* fix

* retrigger tests

* Update lib/Minz/View.php

Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>

* Update lib/Minz/View.php

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

* Update lib/Minz/View.php

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

* Update lib/Minz/View.php

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

* fix

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
2023-03-04 15:05:58 +01:00
maTh
a7e1428485 defined('CLEANCACHE_HOURS') (#5144)
https://github.com/FreshRSS/FreshRSS/issues/4627
2023-03-04 13:46:46 +01:00
Alexandre Alapetite
32acd6c13e SimplePie use single constant for default HTTP Accept header (#5083)
* Use single constant for default SimplePie HTTP Accept
And add missing headers in `SimplePie_Locator::body()`
Follow-up of 5d966b9f64

* Update SimplePie default HTTP Accept
Fix https://github.com/FreshRSS/FreshRSS/pull/5079#issuecomment-1421619176
The `*/*` breaks Mastodon content negotiation

* Revert "Update SimplePie default HTTP Accept"

This reverts commit 13a5a5cb3b.

* Same as upstream
2023-03-04 11:18:56 +01:00
Alexandre Alapetite
05ae1b0d26 XML+XPath (#5076)
* XML+XPath
#fix https://github.com/FreshRSS/FreshRSS/issues/5075
Implementation allowing to take an XML document as input using an XML parser (instead of an HTML parser for HTML+XPath)

* Remove noise from another PR

* Better MIME for XML

* And add glob *.xml for cache cleaning

* Minor syntax

* Add glob json for clean cache
2023-02-09 13:57:20 +01: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
Luc SANCHEZ
40aa8b9264 Type hinting and doc (#5063)
* Type hinting and doc

* fix cs

* Remove declare strict

* Remove declare strict

* Pass PHPStan level 9
Revert too boolean syntax

* Minor wording

* Fix revert typo

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-02-03 14:35:59 +01:00
Alexandre Alapetite
9b5de54a9c Remove -x on some files not needing it (#5065) 2023-02-03 14:34:47 +01:00
Alexandre Alapetite
4ad66c24bf Workaround disabled openlog syslog (#5054)
* Workaround disabled openlog syslog
#fix https://github.com/FreshRSS/FreshRSS/issues/5053
#fix https://github.com/FreshRSS/FreshRSS/issues/5027

* COPY_SYSLOG_TO_STDERR

* Better return

* Simplify openlog
2023-01-30 20:31:46 +01:00
Alexandre Alapetite
4f316b2ed3 PHPStan level 9 for ./p/ and lib_rss.php (#5049)
And app/FreshRSS.php
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112
2023-01-29 18:53:51 +01:00
Alexandre Alapetite
07efaf71ea Fix error handling when updating URL (#5039)
Fix 3 related error handling when updating the feed URL with an invalid URL. Previously leading to unclear 500 page with additional PHP errors.
2023-01-26 08:59:34 +01:00
Alexandre Alapetite
d105761fec i18n safer vsprintf (#5022)
Fix bug introduced by https://github.com/FreshRSS/FreshRSS/pull/4807
though only for the French i18n, wich has some `%` signs in the URL, making `vsprintf` to crash.

Only use `vsprintf`` when we call the translation with some parameters, otherwise skip it (probably faster as well).
2023-01-18 23:39:30 +01:00
berumuron
daaa391e33 tec: Update the lib_opml (#4403)
* fix: Fix undefined GLOB_BRACE on Alpine

The manual states that:

> Note: The GLOB_BRACE flag is not available on some non GNU systems,
> like Solaris or Alpine Linux.

This generated an error on Alpine.

Reference: https://www.php.net/manual/function.glob.php

* fix: List details of feeds for OPML exportation

The details are necessary to export the XPath information, the CSS full
content path and read actions filters.

* Update LibOpml to 0.4.0

* Refactor OPML importation to be more robust

First, it fixes two regressions introduced by the update of lib_opml:

- title attribute is used when text attribute is missing;
- the OPML category attribute is used as a fallback for feeds categories.

In a related way, if also fixes a problem when a feed had both a parent
category outline and a category attribute. Before, it only considered the
attribute as its category, but now it considers the parent outline.

Then, it counts category limit correctly by not increasing
`$nb_categories` if the category already exists.

* Exclude lib_opml from the CodeSniffer

* Fix variable names when logging some errors

* Fix catch of LibOpml Exception

* Make sure to declare the category

* Exclude lib_opml from PHPStan analyze

* Disable markdownlint for lib_opml

* Fix typos

* Use auto-loading and allow updates via Composer

* Fix broken links to lib_opml

* Bring back the ability to import the OPML frss:opmlUrl attribute

* Refactor the logs of OPML errors

* Update lib_opml to the version 0.5.0

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-01-18 10:12:21 +01:00
Alexandre Alapetite
075cf4c800 API avoid logging passwords (#5001)
* API avoid logging passwords
* Strip passwords and tokens from API logs
* Only log failed requests information when in debug mode

* Remove debug SHA

* Clean also Apache logs

* Better comments

* Redact also token parameters

* shfmt

* Simplify whitespace

* redacted
2023-01-11 23:27:14 +01:00
Alexandre Alapetite
1d9d4e3e3c Update dev dependencies (#4993)
Related to https://github.com/FreshRSS/FreshRSS/pull/4991
Required a few changes in code to pass the tests
2023-01-09 12:59:30 +01:00
Alexandre Alapetite
8f9c4143fc Better enclosures (#4944)
* Better enclosures
#fix https://github.com/FreshRSS/FreshRSS/issues/4702
Improvement of https://github.com/FreshRSS/FreshRSS/pull/2898

* A few fixes

* Better enclosure titles

* Improve thumbnails

* Implement thumbnail for HTML+XPath

* Avoid duplicate enclosures
#fix https://github.com/FreshRSS/FreshRSS/issues/1668

* Fix regex

* Add basic support for media:credit
And use <figure> for enclosures

* Fix link encoding + simplify code

* Fix some SimplePie bugs
Encoding errors in enclosure links

* Remove debugging syslog

* Remove debugging syslog

* SimplePie fix multiple RSS2 enclosures
#fix https://github.com/FreshRSS/FreshRSS/issues/4974

* Improve thumbnails

* Performance with yield
Avoid generating all enclosures if not used

* API keep providing enclosures inside content
Clients are typically not showing the enclosures to the users (tested with News+, FeedMe, Readrops, Fluent Reader Lite)

* Lint

* Fix API output enclosure

* Fix API content strcut

* API tolerate enclosures without a type
2023-01-06 19:53:43 +01:00
maTh
18a4ade32f Improved: Minz Framework. Byebye Internet Explorer and its Conditional comments (#4651)
* Update View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
2022-11-22 08:18:52 +01:00
Alexandre Alapetite
42eeb402ad Fix type hints regressions (#4855)
Fix regressions from https://github.com/FreshRSS/FreshRSS/pull/4561

Example:

```
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to checkToken() must be an instance of FreshRSS_UserConfiguration, instance of Minz_Configuration given, called in /var/www/FreshRSS/p/api/greader.php on line 1091 and defined in /var/www/FreshRSS/p/api/greader.php:223
Stack trace:
#0 /var/www/FreshRSS/p/api/greader.php(1091): checkToken()
#1 {main}
  thrown in /var/www/FreshRSS/p/api/greader.php on line 223
```

Improvement of https://github.com/FreshRSS/FreshRSS/pull/4110
2022-11-15 15:42:26 +01:00
Alexandre Alapetite
570503b7f1 Require PHP 7.2+ (#4848)
Drop PHP 7.0- as planned https://github.com/FreshRSS/FreshRSS/discussions/3321#discussioncomment-835704
2022-11-14 15:02:44 +01:00
Alexandre Alapetite
8864d514c8 NFS-friendly is_writable() checks (#4780)
#fix https://github.com/FreshRSS/FreshRSS/issues/4779
2022-11-14 14:57:45 +01:00
Alexis Degrugillier
0fd608420e Remove ajax parameter when modifying the request (#4743)
Before, when clicking on the author name to use as a filter, the displayed page
was a result page from the ajax query. This was due to the use of the ajax
parameter in the query.
Now, the ajax parameter is removed from the query before displaying the filters.

Fix #4726
2022-10-18 23:22:54 +02:00
Alexis Degrugillier
db4c2798ae Allow redirection after login (#4654)
Before, if you've tried to reach a page without being logged, you'll be
automatically redirected to the index page after login.
Now, the original page is used after login.

Fix #3663
2022-10-03 16:49:52 +02:00
Alexandre Alapetite
97fc0bc95e GLOB_BRACE is not available on all platforms (#4628)
https://php.net/glob

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

Improvement of https://github.com/FreshRSS/FreshRSS/pull/4220
2022-09-20 12:03:46 +02:00