Skip to content

Commit

Permalink
integrated upstream changes (#13)
Browse files Browse the repository at this point in the history
* Add docker compose

* Add apcu for PHP 5.5+
* Disable APC on PHP 7+ as APCu 5 is not supported
* Add ability to use a custom test runtime

Co-authored-by: Thomas <[email protected]>

* Use GitHub actions for Continuous Integration tests

Remove TravisCI integration

* Fix test for /bin/ls file mimetype guessing, using application/x-pie-executable

* PHP 8.1 > internal_method_return_types
https://wiki.php.net/rfc/internal_method_return_types

PHP 8.0 added return type for abstract methods on Iterator, ArrayAccess, Countable, IteratorAggregate
PHP 8.1 made non implementation as a Deprecated Warning
PHP 9.0 (no release date at this moment) will drop the support.

Temporary Fix : adding this Attribute
Will drop the Deprecated warning.

Adding return type will break compatibility before PHP 7.4,
Return type has been added on PHP 7.0, but "mixed" special type is required, and it has been added on PHP 7.4.
In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4

Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment.

* PHP 8.1 > Serializable Phase Out
https://wiki.php.net/rfc/phase_out_serializable

PHP 7.4 add a new Serialize mecanism
PHP 8.1 made old method, "Serializable implementation" deprecated
PHP 9.0 (no release date at this moment) will drop the support.

Temporary Fix: Adding both method serialize/unserialize and __serialize/__unserialize

In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4.

Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment.

Each class has been serialized/unserialized and compared on PHP 8.1.2 and 5.6.30

* PHP 8.0 & 8.1 > Deprecated of null to non-nullable internal function parameters

Mainly ensure use of string instead of null / false by casting the variable into (string)
Also fix method/function arguments with default value must be at the end.

Thanks to @teymour
FriendsOfSymfony1@cba71a4

* PHP 8.1 > strftime deprecated.

2 possible workaround, use partial implementation with php date method or use IntlDateFormatter.
As symfony1 is not intended to evolve, it should not rely on currently unused PHP-Extension (nor update composer.json).

I propose a fix to replace "strftime" by "date", with a translation of format for PHP 8.1+

It will lose the ability of translating date of logs (does anybody use it ?) and it will deprecated a few strftime format (probably not used)
Performances should remains OK

I only tested it with a few formats (the default one and a few others)
If you need some missing strftime formats, please add them.

* PHP 8.1 > Unit Test

sfException> fileExcerpt file can be null, and PHP 8.1 do not allow null on is_readable()

sfBrowser> Move sf_test conf before getContext, because getContext can throw some sfException, which will raise some printStackTrace, hidden by another Exception "header already sent ..."

lime.php> some trace can have no "file" (internal methods call)
lime.php> handle_exception can handle Error/Throwable, not avaialble under php7.2: remove typing

sfTestFunctionalBase> can throw exception

Fix Select Unit test NewActivePendingExpired.
DomDocument on recent php return a list of values, not concatened ones.

Fix SessionStorage UnitTest.

sfSessionStorage could not be restarted.
Flag $sessionStarted as false when shutdown to avoid error during unit test which can start several sfSessionStorage

Storage need to be shutdown to avoid:
PHP Warning:  session_name(): Session name cannot be changed when a session is active

* Fix lime message: "An uncaught exception has been thrown" do not have "error" value

uncaught exception does not populate error field

* PHP 8.1 > uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero

* Fix ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty

* PHP 8.0 > fread()/count() behavior

ValueError: fread(): Argument #2 ($length) must be greater than 0

TypeError: count(): Argument #1 ($value) must be of type Countable|array Foo Given
Use Symfony Polyfill symfony/polyfill@d330c00

TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given
Do not use Symfony pollyfill, is_array is enought

* Fix Declaration of sfPearRestTest::downloadHttp($url, $lastmodified = null, $accept = false) must be compatible with sfPearRest::downloadHttp($url, $lastmodified = null, $accept = false, $channel = false)

* PHP 8.0 > mktime update

8.0.0 	hour is no longer optional.
8.0.0 	minute, second, month, day and year are nullable now.

* Fix sfWebResponse->getContentType() return a string not an array

* Fix sfDoctrineTester, string cannot be accessed as array

* PHP 8.0 > Fix is_numeric behavior with trailing empty char
Numeric strings ending with whitespace ("42 ") will now return true. Previously, false was return instead.

Use same fix has main maintened Yaml lib :
symfony/yaml@4152e36
+ performance improvement
symfony/yaml@2b5f2ae

* PHP 8.0 > String to Number Comparison.
When $previousIndent was equal to 0, and $matches['indent'] = "    "

PHP(before 8.0)> (0 != "    ") ==> false
PHP8.0+ > (0 != "     ")  ==> true

In order to keep "false" value we avoid "0" as a valid value.

More details here why here:
https://www.php.net/manual/en/migration80.incompatible.php

* PHP 8.1 > Change support to PHP 8.1

* Fix UnitTest application/x-sharedlib

/bin/ls can be reported as:
- application/x-sharedlib
- application/x-executable
- application/x-pie-executable

* PHP 8.1 > mysqli_report revert to off
https://php.watch/versions/8.1/mysqli-error-mode

* Refactor code and apply Coding Style fixes

* PHP 8.1 > Better MYSQLI_REPORT_OFF implementations for php8.1 compat

Thanks @mentalstring

* PHP 8.1 > remove full_path from uploads added on PHP v8.1

* Fix use of null on string parameter on multiple classes

* Github Actions: enable testing on PHP v8.0 and v8.1 (for PRs too)

* test environment for php 8.2

* PHP 8.2 > Using ${var} in strings is deprecated, use {$var} instead.

* PHP 8.2 > Creation of dynamic property Class::$property is deprecated

* PHP 8.0 > Uncaught ArgumentCountError: Too few arguments to function

* PHP 8.0 > Trying to access array offset on value of type bool

* PHP 8.0 > Passing null to parameter #1 ($haystack) of type string is deprecated

* set symfony version to 1.5.15-dev

* PHP 8.0 > Class name must be a valid object or a string in case the controller does not exist.

* PHP 8.0 > Fix undefined array key

* PHP 8.1 > Fix some more null on string parameter

* Prepared release 1.5.15

* Add(changelog) Add v1.5.15 release date to Changelog file

* Add(versioning) Add v1.5.16-dev as next release

* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate (FriendsOfSymfony1#277)

* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate, add return types from implemented sfIMessageSource

* Add(linting) Add code linting to GitHub workflow, use php-cs-fixer

* Fix(php-cs) Fix php-cs styles according to configuration

* Add(gitattributes) Add .gitattributes to repository

* Fix: avoid creating dynamic property $options in sfViewCacheManager (FriendsOfSymfony1#290) 

Dynamic properties are deprecated since PHP8.2

* Update(github) Update github workflows, include cache for composer install

* Fix(php-cs-fixer) Fix php-cs-fixer warnings, according to new checks

* add php8.3

* Fix(php-cs-fix) fix php-cs-fix single_space_around_construct warning

* Fix(php-cs-fixer) Fix php-cs-fixer to v3.45 and apply code fixes

* Fix(deprecation) preg_match_all requires string parameter (FriendsOfSymfony1#298)

* Fix APC cache tests

- Using negative TTLs to force the immediate expiration of keys, while
  convenient in tests, doesn't work consistently with APC and is an
  undocumented feature. Using a low TTL and sleep() is what guarantees
  that it works for APC. See krakjoe/apcu#184

- The setting apc.use_request_time interferes with key expiration when
  running on the CLI. Making sure it always has a sensible value for
  running the tests. See krakjoe/apcu#392

* Add APCu support

Support for the APCu extension (through sfAPCuCache) as an alternative
to APC, which no longer works with recent versions of PHP.

* Fix sfCacheSessionStorageTest with PHP>=7.2

From PHP 7.2 onward, session functions are stricter and may not work
if output/headers have already been sent out. Using output buffering
prevents this issue.

* Remove test dependency on APC

Replace the use of sfAPCCache with sfFileCache in
sfCacheSessionStorageTest so that it doesn't depend on APC being
available.

* Fix deprecation on stropos()  usage on sfDebug::shortenFilePath (FriendsOfSymfony1#299)

Fix PHP v8.x deprecation on strpos() usage with `null` as first parameter

* Fix strpos() deprecation on sfCacheSessionStorage check for cookie

* Fix setrawcookie() deprecation on null parameter (FriendsOfSymfony1#304)

* Fix str_replace() deprecated null parameter on sfNumberFormat

* Declare $params var

* Replace default with 0

* Update README

Fix build badge, update supported PHP version and other minor tweaks.

* Fix link to GitHub pipeline badge

* fix(config) sfCacheConfigHandler: There is no fourth argument. Nice catch phpstan!

* Fix PHP8.1 sfForm - Unsupported operand types: array + null on sfForm::updateValues()

Avoid error:
Fatal error: Uncaught TypeError: Unsupported operand types: array + null in lib\form\sfForm.class.php:319

Step to reproduce :
$form = new sfForm();
$form->updateValues(array('foo' => 'value'));

PHP 5.3 coding style

May use sfForm::getValues(), but as sfForm::updateValues() is a hack, it could be used before bind ($this->isBound = true);

* fix(phpdoc) remove html code from throws phpdoc. phpstan don't like this

* fix(phpdoc) remove version tag

* PHP 8.3 deprecated errors fixed (FriendsOfSymfony1#320)

* Update min PHP requirement to v7.4 or v8.1

* Remove PHP v8.0 from CI workflow

* Updated gh workflow to use latest actions

* Backported display_errors-handling to sf1

* Set min versions of swiftmailer to 5.4.13 and 6.2.5 and updated swiftmailer submodule (FriendsOfSymfony1#331)

* Update min versions of swiftmailer to v5.4.13 or v6.2.5
* Update swiftmailer code on submodule to v5.4.13

* Sync changelog with latest releases (FriendsOfSymfony1#337)

* Sync changelog with latest releases

* Remove(legacy): Remove unsupported PHP docker images

* Remove(legacy): drop sfAPCCache cache as apc extension does not exist anymore

Please use sfAPCUCache instead

* Fix(docblock): fix typo in check_configuration.php docblock

* Update(check-config): use PHP constant for version check on check_configuration.php file

* Remove(legacy): delete checks for 'magic_quotes_gpc' and 'register_globals' ini settings, as removed on PHP v5.4

* Remove(legacy): delete EAccelerator cache, the extension is not existing for php v7.4

See: https://github.com/eaccelerator/eaccelerator, where the following
message is shown:

> This project is deprecated and does not work with anything newer than PHP 5.3.
> Please use a recent version of PHP with OPcache instead!

* Remove(legacy): drop XCache support, as the extension is not available for PHP >= 7.4

* Remove(legacy): delete check for PHP < 5.2 in tests for mime_content_type bug

* Remove(legacy): drop PHP v5.3 check for SQLite version match

* Remove(legacy): drop PHP v5.4 check and compatibility layer on sfWebRequest

* Remove(legacy): drop PHP v5.3 check on sfRoute

This removes a preliminary fix for a legacy PHP 5.3. issue with regexp excaping
PHP bug reference: http://bugs.php.net/bug.php?id=47229

* Update: Update php-cs-fixer to v3.51

Apply rule fixes

* Update: php-cs-fixer, enable short array syntax

* Update: move php-cs-fixer cache under .cache folder

* Update: run php-cs-fixer on PHP v7.4 as min supported version

* Update: GitHub actions to run php-cs-fixer only on relevant changed files

* Hotfix: Add type checking for deserialized data in sfParameterHolder and sfNamespacedParameterHolder (CVE-2024-28861)

* Update php-cs-fixer to v3.52

* Remove(legacy): drop sf*Cache implementations for APC, XCache and EAccelerator extensions

* Phpstan: fix warnings on sfAPCiCache implementation, add docblocks and returns

* Phpstan: fix warnings on sfFileCache and sfMemcache implementation, add missing returns

* Phpstan: fix missing sfTask* return statement

* [widget] fix return statement missing (FriendsOfSymfony1#349)

* [validator] fix return statement missing (FriendsOfSymfony1#352)

* [view] fix return statement missing on ParamHolder and CacheManager (FriendsOfSymfony1#350)

* [task] Fix return statement missing on some tasks (FriendsOfSymfony1#353)

* [util] fix missing return statement and docblock on sfContext class (FriendsOfSymfony1#351)

* Chore: Fix Changelog typo (FriendsOfSymfony1#361)

* Fix: update the SYMFONY_VERSION constant to the latest release number (FriendsOfSymfony1#355)

* Add: Include "test" folder to gitattribute's exclusion (FriendsOfSymfony1#368)

* Fix: Correct type-hint for parameters sfConfigCache (FriendsOfSymfony1#370)

---------

Co-authored-by: Alexandre Quercia <[email protected]>
Co-authored-by: Thomas <[email protected]>
Co-authored-by: Emanuele Panzeri <[email protected]>
Co-authored-by: Tybaze <[email protected]>
Co-authored-by: Paulo Magalhaes <[email protected]>
Co-authored-by: Thomas A. Hirsch <[email protected]>
Co-authored-by: Karoly Gossler <[email protected]>
Co-authored-by: Vincent Mariani <[email protected]>
Co-authored-by: iricketson <[email protected]>
Co-authored-by: Ian Ricketson <[email protected]>
Co-authored-by: Sergei Miami <[email protected]>
Co-authored-by: darkpills <>
Co-authored-by: ಠ_ಠ <[email protected]>
  • Loading branch information
13 people authored Jul 1, 2024
1 parent ef6ed6c commit b13683e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
docker-compose.yml export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
test/ export-ignore
tests/ export-ignore
6 changes: 3 additions & 3 deletions lib/config/sfConfigCache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public function import($config, $once = true, $optional = false)
/**
* Registers a configuration handler.
*
* @param string $handler The handler to use when parsing a configuration file
* @param class $class A configuration handler class
* @param string $params An array of options for the handler class initialization
* @param string $handler The handler to use when parsing a configuration file
* @param class-string<sfConfigHandler> $class A configuration handler class
* @param string[] $params An array of options for the handler class initialization
*/
public function registerConfigHandler($handler, $class, $params = [])
{
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/TextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function simple_format_text($text, $options = [])
{
$css = (isset($options['class'])) ? ' class="'.$options['class'].'"' : '';

$text = preg_replace('/(\r\n|\r)/', "\n", $text); // lets make them newlines crossplatform
$text = preg_replace('/(\r\n|\r)/', "\n", $text); // lets make them newlines crossplatform
$text = preg_replace('/\n{2,}/', "</p><p{$css}>", $text); // turn two and more newlines into paragraph

// turn single newline into <br/>
Expand Down
2 changes: 1 addition & 1 deletion lib/task/sfTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ protected function usageCloseToLimit($usage, $warning_when_remaining)

protected function convertIntToUnit($size)
{
$unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
$unit = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'];
$i = floor(log($size, 1024));

return @round($size / pow(1024, $i), 2)." {$unit[$i]}";
Expand Down

0 comments on commit b13683e

Please sign in to comment.