forked from simplepie/simplepie
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to v1.5.6 #3
Open
GChuf
wants to merge
317
commits into
pfsense:master
Choose a base branch
from
simplepie:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* XML/Declaration/Parser: Do not use magic values for state machine state * HTTP/Parser: Do not use magic values for state machine state
The first alpha of PHP 8.2 was released nearly two weeks ago, so let's start testing against PHP 8.2 Co-authored-by: jrfnl <[email protected]>
* require php-cs-fixer, create config file * change CS to PSR-12 in library folder * change CS to PSR-12 in build folder * change CS to PSR-12 in demo folder * change CS to PSR-12 in tests folder * change CS to PSR-12 in src folder * Allow installation of php-cs-fixer 2.19 for PHP <7.4 * Revert "change CS to PSR-12 in src folder" This reverts commit 3d7718a. * change CS to PSR-12 in src folder BC: do not set visibility on class constants * Fix CS in composer.json * Add @PHP54Migration rule and fix CS
* Fix item get_base SimplePie was not using the best base link for an item content (instead, it was directly using the feed base). See `<xml:base>` example in https://datatracker.ietf.org/doc/html/rfc4287#section-1.1 First uses item `<xml:base>` if it exists, or the item own link, or the feed's base URL rules (feed URL, or Web site URL) Downstream issue FreshRSS/FreshRSS#4562 Downstream PR FreshRSS/FreshRSS#4565 * tests * Same indenting as other tests Maybe can help with strange CI bugs
* bump version to 1.7.0, update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md for latest PRs * Update release date for SimplePie 1.7.0
* descripe branches in README.markdown * add bug fixes in LTS strategy * rename branches and clarify purposes * clarify backport strategy * fix typo
The `Parse\Date::parse` method can return `false` when it fails to parse the value and `get_date` will return it as is but its PHPDoc annotation does not allow returning booleans. Let’s fix it by converting such values to `null`.
* Create wrapper for PSR-16 cache * Add method set_psr16_cache() * Add cache ttl, cache raw data in PSR-16 cache * Add tests for save() and load() * improve mtime() for PSR-16 cache * Fix tests for PHP < 8.0 * Fix tests for PHP 5.6 * Fix tests for PHP 5.6 * Improve tests * Rename method for setting cache * Update CHANGELOG.md * Fix typo * make cache miss more comprehensible * rename $set to $unset * ensure $data for save() has the correct data type * mark Psr16 cache as final and internal * Replace spc and spi with Cache Base constants * Improve descriptive names of test cases * Change variable name * Mark Psr16 class as internal
* Use native array_replace_recursive Since PHP 5.3+, there is a native equivalent to the SimplePie Misc function to merge arrays: https://php.net/array-replace-recursive Improvement of #268 * Keep existing code
* bump min version to PHP 7.2 * run php-cs-fixer with PHP71Migration ruleset * bump version_compare checks to PHP 7.2 * bump version_compare checks to PHP 7.2 * run php-cs-fixer with @PHP56Migration:risky * run php-cs-fixer with risky combine_nested_dirname rule * remove risky php-cs-fixer rule * add risky php-cs-fixer rules * run php-cs-fixer ruleset @PHPUnit84Migration:risky * fix accessability of internal consts * Improve Code Style * dont fix CS in demo folder * Remove duplicated mock classes * Fix compile script * Update RHP requirement in README * descripe branches in README.markdown * fix code style * Revert "descripe branches in README.markdown" This reverts commit 6b9309d. * remove Psr16CacheException * fix tests for PHP <= 7.4 * Improve code for PHP 8.0+ * Fix tests for psr/simple-cache 1 and PHP 7.4
…ations (#752) * Create wrapper for PSR-16 cache * Add method set_psr16_cache() * Add cache ttl, cache raw data in PSR-16 cache * Add tests for save() and load() * improve mtime() for PSR-16 cache * Fix tests for PHP < 8.0 * Fix tests for PHP 5.6 * Fix tests for PHP 5.6 * Improve tests * Rename method for setting cache * Update CHANGELOG.md * Fix typo * make cache miss more comprehensible * rename $set to $unset * ensure $data for save() has the correct data type * mark Psr16 cache as final and internal * Replace spc and spi with Cache Base constants * Improve descriptive names of test cases * Change variable name * Mark Psr16 class as internal * Create new DataCache interface * Implement DataCache in Psr16 cache class * create adapter for Base cache implementations * Rename SimplePie\SimplePie::$cache to $enable_cache * Create integration tests to safeguard the bahavior of the cache * refactore integration tests * Provide also default cache data in integration test * Test cache with outdated build and cache collision * test stored non feed url with valid autodiscovery cache * run unit tests first and integration tests last * test cached data with non feed url * fix tests for PHP 5.6 * stop using Cache Base::touch() * rename internal key for cache expiration * stop using Cache Base::mtime() * fix copyright year * Test if cache data is valid * test case if cache has been updated * Use DataCache in SimplePie and Sanitize classes * let Psr16 no longer implements Base Cache * fix tests * improve argument checking * deprecate Cache class and Base implementations * set BaseDataCache as final, add comments * Fix code style * rename DataCache methods to snake_case * define DataCache interface as internal * rename intergration tests for caching * Fix Memcached cache class * do not catch CacheExceptions because we allow to inject the PSR-16 cache and also a cache_name_function, the user should be notified about bad cache config * Add deprecation notes * Deprecate SimplePie::force_cache_fallback() * Update CHANGELOG.md
* Add parameter and return type declarations in DataCache interface * Fix cache ttl * Fix return type in cache mock for PHP <8 * Update src/Cache/BaseDataCache.php Co-authored-by: Jan Tojnar <[email protected]> Co-authored-by: Jan Tojnar <[email protected]>
* tests: Add unit test for Parse\Date::date_w3cdtf * Parse\Date: Clean up regex structure
* Create interface RegistryAware * Update CHANGELOG.md
* Add NameFilter and CallableNameFilter for cache names * Document rules for string returning from filter * Update CHANGELOG.md * declare strict_types in new files, fix deprecation message * remove strict_types declaration again
* declare strict_types=1 in every file * declare strict_types=1 in IRI and Parse Date class * declare strict_types=1 in Misc class, fix bug * declare strict_types=1 in SimplePie class * BC for PHP < 8.0 * Strip declare statement in compiled file * Fix many errors for PHPStan Level 1 * do not round() int * Fix get_image_height() and get_image_width() returning int|null Returning float instead of int was wrongly introduced in commt 33a8f76 According to the RSS 2.0 spec height and width must be the number of pixels. see https://www.rssboard.org/rss-specification#ltimagegtSubelementOfLtchannelgt * Update CHANGELOG.md * clarify some statements * Fix $encoded declatation * Fix $valid declaration * fix CS by running php-cs-fixer
PHP 8.2 has been released today 🎉 and the `setup-php` action has announced support for PHP 8.3, so adding PHP 8.3 to the matrix and no longer allowing PHP 8.2 to fail the build. Builds against PHP 8.3 are still allowed to fail for now. Co-authored-by: jrfnl <[email protected]>
* No URL Decode for enclosure links This line was introduced in 8a5f601#diff-a710c236cc7775672edbe5840d8fb96b0e91b0d56eff709f6eace2da47c1fe43R349-R359 Seems to be a similar error than efb1d8e Having an `urldecode` returns some potentially invalid URLs, while SimplePie does not do that for other returned URLs Downstream PR FreshRSS/FreshRSS#4944 P.S. There are a few other bugs related to enclosure links, and I will try to address some of them in distinct PRs. * Add tests * Simplify tests * Whitespace * PHP 7.2 compat * Update tests/Unit/EnclosureTest.php Co-authored-by: Jan Tojnar <[email protected]> Co-authored-by: Jan Tojnar <[email protected]>
* Sanitize thumbnail URL Add missing sanitize and absolute_url on thumbnail URL. SimplePie normally sanitizes all URLs, but the thumbnail URL was not processed. Related to #768 Downstream PR FreshRSS/FreshRSS#4944 * Update tests syntax
* No URL Decode for enclosure links This line was introduced in 8a5f601#diff-a710c236cc7775672edbe5840d8fb96b0e91b0d56eff709f6eace2da47c1fe43R349-R359 Seems to be a similar error than efb1d8e Having an `urldecode` returns some potentially invalid URLs, while SimplePie does not do that for other returned URLs Downstream PR FreshRSS/FreshRSS#4944 P.S. There are a few other bugs related to enclosure links, and I will try to address some of them in distinct PRs. * Add tests * Simplify tests * Fix case of multiple RSS2.0 enclosures SimplePie only returned the first enclosure when using the RSS 2.0 syntax for enclosures, instead of returning them all. Please merge #768 first. Downtream PR: FreshRSS/FreshRSS#4944 * Whitespace * PHP 7.2 compat * PHP 7.2 compat * Update tests/Unit/EnclosureTest.php Co-authored-by: Artur Weigandt <[email protected]> * Update tests/Unit/EnclosureTest.php Co-authored-by: Jan Tojnar <[email protected]> * Update src/Item.php Co-authored-by: Jan Tojnar <[email protected]> * Update tests syntax Co-authored-by: Artur Weigandt <[email protected]> Co-authored-by: Jan Tojnar <[email protected]>
Otherwise ApiGen will complain: Missing SimplePie\Parse\callback referenced by SimplePie\Parse\Date Missing SimplePie\Cache\type referenced by SimplePie\Cache\Redis Missing SimplePie\Cache\SimplePie referenced by SimplePie\Cache\Redis Missing SimplePie\Cache\PDO referenced by SimplePie\Cache\MySQL
* Registry: Allow using class-strings instead of magic strings This will make it much simpler to validate typos using static analysis. * Use class-strings for interaction with registry Converted using the following command: sed -i -E "s/(registry->(register|get_class|create|call)\\()'([^']+)'/\\1\\3::class/g;s/Content_Type_Sniffer::class/Content\\\\Type\\\\Sniffer::class/g;s/Parse_Date::class/Parse\\\\Date::class/g;s/XML_Declaration_Parser::class/XML\\\\Declaration\\\\Parser::class/g" $(find src -name '*.php') * deprecate old class setter * Fix deprecation message in Cache class * Define legacy types and classes in Registry, add tests * Add support and tests for legacyTypes * replace more old type names with class names * Add deprecation note * do not mute warnings while using is_subclas_of() * Fix version number Co-authored-by: Jan Tojnar <[email protected]>
* bump version to 1.8.0 * Update CHANGELOG.md * Fix version tags in deprecated messages * fix version in old deprecation messages * Fix typo see comment from @jtojnar in #752 * Add comment for DataCache interface see comment from @jtojnar in #752 * Update CHANGELOG.md for #760, #764 and #765 * Update CHANGELOG.md for #762, #767 and #763 * Update CHANGELOG.md for #768 and #770 * Update release date * Update CHANGELOG.md for #769 and #771 * Update CHANGELOG.md for #766
phpdoc_to_param_type would add union and mixed types, which are not supported by our target PHP version.
https://php.net/language.types.declarations Also helps PHPStan, which otherwise makes another lookup as it might be in the SimplePie namespace, and which fails in some cases.
The signature of `fread()` has changed from PHP 7.3 to 7.4
Fix typos
ci: Fix php-cs-fixer
Fix PHPStan for PHP 7.3
The following regular expression matches: ^( +)(\$[a-z_]+) = \$this->sanitize\((.+)\['data'\](, .+), \$this->get_base\(\3\) were replaced by: \1\2 = \3;\n\1\2 = \$this->sanitize\(\2\['data'\]\4, \$this->get_base\(\2\)
PHPDoc avoid aliases for scalar types
Extract long repeating sanitization bases into variable
CI was broken due to not pinning `composer.lock` AND allowing updates at `1.x.x` level, which may contain breaking changes, e.g. for PHPStan. ``` ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Line src/IRI.php ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ :304 Offset 3 on array{0: string, 1: '', scheme: null, 2: string, 3: string, authority: string, 4: string, path: string, ...}|array{0: string, 1: non-empty-string, scheme: string, 2: string, 3: string, authority: string, 4: string, path: string, ...} in isset() always exists and is not nullable. :307 Offset 5 on array{0: string, 1: '', scheme: null, 2: string, 3: string, authority: string|null, 4: string, path: string, ...}|array{0: string, 1: non-empty-string, scheme: string, 2: string, 3: string, authority: string|null, 4: string, path: string, ...} in isset() always exists and is not nullable. ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ```
PHP 8.4 deprecates implicitly nullable parameters, i.e. typed parameter with a `null` default value, which are not explicitly declared as nullable. Includes updating the documentation to match. Ref: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
PHP 8.4 deprecates passing `E_USER_ERROR` to `trigger_error()`, with the recommendation being to replace these type of calls with either an Exception or an `exit` statement. This commit fixes an instance found in the autoloader by changing it to a call to `exit`, which considering it is an error related to the autoloader not being registered seems the most appropriate. Ref: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
PHP 8.4 deprecates passing `E_USER_ERROR` to `trigger_error()`, with the recommendation being to replace these type of calls with either an Exception or an `exit` statement. This commit fixes another instance of this issue. In this case, the call to `trigger_error()` is replaced by throwing a generic `SimplePie\Exception` for the same. Ref: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
PHP 8.4 deprecates passing `E_USER_ERROR` to `trigger_error()`, with the recommendation being to replace these type of calls with either an Exception or an `exit` statement. This commit fixes the last instance of this issue. In this case, the call to `trigger_error()` is also replaced by throwing a generic `SimplePie\Exception` for the same. Ref: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
... the call to `trigger_error()` would now throw a PHP notice, but with the `die()` after it, with still kill the program anyhow, so we may as well, exit with the error message and remove the `trigger_error()` function call completely.
Composer 1.10.0 introduced a `lock` config option, which, when set to `false` will prevent a `composer.lock` file from being created and will ignore it when one exists. This is a useful option for PHP cross-version compatible packages such as this, where the `lock` file has no meaning. It also makes life more straight-forward for contributors as they don't have to remember that for this repo they should use `composer update` instead of `composer install`. Both will now work the same. Refs: https://getcomposer.org/doc/06-config.md#lock
PHP 8.4 is in beta, with final version scheduled for November so it is time to start testing it. Add it to CI matrix, allowing failures for now. Do not allow failures for PHP 8.3 since that has been stable for ages.
When we switched to PSR-16 inspired `DataCache` in bb38d74, we introduced a regression due to impedance mismatch between PSR-16 and HTTP Caching mechanisms: - HTTP caching uses two step invalidation – if a cache entry is accessed after its TTL passes, a request is made with a stored HTTP caching header (e.g. ETag) and the cache is considered invalid only if the server returns something else than 304 Not Modified response. - On the other hand, PSR-16 cache does not allow access to entries past its TTL, forcing us to fetch the content every time, even when the remote server could tell us it is still fine. To work around this, bb38d74 decided to store `cache_expiration_time` field in the cache entry so that we could bypass the PSR-16’s strict TTL and handle expiration ourselves. But there were few places where we forgot to set it. This patch fixes that. Unfortunately, because we also pass the same value as `cache_expiration_time` to `DataCache::set_data` as TTL, the early eviction still happens. We will also need to set the TTL to `null` (unlimited) so that the `DataCache` does not evict the entries behind our back. Partly fixes #830 ([BUG] Cache constantly updating)
This allows developer to create their own own config file, e.g. for setting `editorUrl`: https://phpstan.org/user-guide/output-format#opening-file-in-an-editor
PHP supports it natively since 5.4. acaaa76 also started to use it, presumably to fix sites that were incorrectly declaring `deflate` method when they were using `gzip`. And since we require PHP 7.2, and the zlib extension is already mandatory for the `gzinflate` and `gzuncompress` functions, let’s also remove the `funcion_exists` check.
When a regex contains a capture group within another capture group followed by `?`, and the outer group is not matched, the resulting matched text for both groups will be an empty string. (1) Or, if there are no further matched capture groups, the indices for the groups will be simply omitted from the `$matches` array. (2) We want missing components of the URI to be `null` so we had a conditionals for the aforementioned matches. As of PHP 7.2, we can just use `PREG_UNMATCHED_AS_NULL` to get `null`s in the case (1): https://www.php.net/manual/en/function.preg-match.php#refsect1-function.preg-match-parameters If we raised minimum PHP version to 7.4, we would not even need the `isset` to handle (2) because from that version onward, the flag also disables the omission of tail unmatched groups: https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.pcre Switch the optional outer capture groups (1, 3, 6 and 8) to anonymous ones now that we are no longer using them for anything.
Looks like this has been incorrect since 5bf1814 Revealed by PHPStan level 8.
* Builds against PHP 8.4 are no longer allowed to fail. Ref: https://www.php.net/releases/8.4/en.php
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mostly bug and issue fixes, some new features.
Redmine issue: https://redmine.pfsense.org/issues/11508