Skip to content
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

NTO-180 PHP8.1 compatibility #3

Merged
merged 94 commits into from
Nov 2, 2022
Merged

NTO-180 PHP8.1 compatibility #3

merged 94 commits into from
Nov 2, 2022

Conversation

akhumphrey
Copy link

@akhumphrey akhumphrey commented Sep 6, 2022

This PR was constructed using much the same approach as the PHP8.x compatibility PR for doctrine1. As a result, it has a similar hodgepodge style to that PR as well.

thirsch and others added 30 commits March 30, 2019 10:43
… Submodule for swiftmailer not required as it is also a dependency within composer.
…version on every pageload, let's drop PHP 5.3 support.
Swiftmailer 6 back to master.
(cherry picked from commit 3622f22)
… Submodule for swiftmailer not required as it is also a dependency within composer.

(cherry picked from commit ba2dfe3)
(cherry picked from commit 2e00caa)
(cherry picked from commit 90c5a42)
# Conflicts:
#	composer.json
#	lib/mailer/sfMailer.class.php
Is it possible to keep the submodule?
…d of stdout. This patch allows to set it as a new setting in settings.yml
@akhumphrey akhumphrey self-assigned this Sep 6, 2022
@akhumphrey akhumphrey marked this pull request as ready for review October 18, 2022 04:15
lib/request/sfWebRequest.class.php Outdated Show resolved Hide resolved
@akhumphrey akhumphrey merged commit fc64166 into master Nov 2, 2022
@akhumphrey akhumphrey deleted the php81 branch November 2, 2022 19:40
@@ -759,7 +764,7 @@ protected function generateStarParameter($url, $defaults, $parameters)
}
else
{
$tmp[] = urlencode($key).'/'.urlencode($value);
$tmp[] = urlencode($key) . '/' . urlencode($value ?: '');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrested-development-season1

This tiny change breaks any URL where parameters use 1 and 0 to indicate boolean flags. For example, the URL

https://manager-dev.ah.dd81.controlport.co.uk/trolleys/active/0/status/0/type/Trolley

gets turned into

https://manager-dev.ah.dd81.controlport.co.uk/trolleys/active//status//type/Trolley

A patch to fix will be forthcoming.

akhumphrey added a commit that referenced this pull request Feb 24, 2023
* Returned null if the requested controller does ont exist, as promised in the method docblock.

* Don't check the checkbox if the value is '0' or 0.

* Improved generated typehints for doctrine model classes.

* Revert "Improved generated typehints for doctrine model classes."

This reverts commit cd4243d.

* Allow swiftmailer 6

* Allowed optional installation of swiftmailer 6 if plattform >= PHP 7. Submodule for swiftmailer not required as it is also a dependency within composer.

* PHP 7.4 deprecates get_magic_quotes_gpc. Instead of checking the php-version on every pageload, let's drop PHP 5.3 support.

* Deprecated: Array and string offset access syntax with curly braces is deprecated.

* Swiftmailer6 compat.

* Swiftmailer6 compat.

* Allow swiftmailer 6

(cherry picked from commit 3622f22)

* Allowed optional installation of swiftmailer 6 if plattform >= PHP 7. Submodule for swiftmailer not required as it is also a dependency within composer.

(cherry picked from commit ba2dfe3)

* Swiftmailer6 compat.

(cherry picked from commit 2e00caa)

* Swiftmailer6 compat.

(cherry picked from commit 90c5a42)

* Check if class "Swift" is loaded.

* Another easy way for being compatbiel with swiftmailer 5 and 6!

* Reverted sfMailer changes.

* Even more reverts.

* Still 1.5.13 for our branch.

* Fixed merge conflicts.

* Is it possible to keep the submodule?

* PHP >= 5.2.4 supports stderr for reporting the error to stderr instead of stdout. This patch allows to set it as a new setting in settings.yml

* Added the new settings to WHATS_NEW.md

* Fixed deprecated non optional parameters after optional parameters.

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* php 8.1 compat

* Revert "php 8.1 compat"

This reverts commit 566e652.

* php 8.1 compat

* 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

* Change support to PHP 8.1

* Update Travis to PHP up to 8.1

PHP 5.3 is broken due to Letsencrypt certificate cannot download composer

PHP 5.4 do not contains apc module on (and precise has same cert problem than 5.3))

* Fix UnitTest application/x-sharedlib

/bin/ls is now application/x-sharedlib on ubuntu focal

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

* WillBeRemoved, Ensure Travis is OK on PHP 8.1

It only fix one last error due to Doctrine throwing warning on PHP 8.1.
other/tasksTest, 1 subtests trying to load Doctrine_Manager.

To avoid this warning on your setup:
- Use temporary: php.ini error_reporting = E_ALL & ~E_DEPRECATED
- Use temporary: Tybaze/doctrine1, branch compat_php8.1
- Use FriendsOfSymfony1/doctrine1 once merged PR-85

* php 8.1 compat

* bumped min php version, bumped branch alias

* set more durable permissions when generating `doctrine_schema_[\d]{5}.yml`

* updated format to match existing logging

* updated method signature to match `Iterator::current()`

* disallow passing `null` to `urldecode` in `sfRoute`

* added default value for `$number` to `format_number_choice()`

* updated remaining `sfRouteCollection` iterator method signatures to match upstream

* avoid passing `null` to `urlencode()`

* avoid passing `null` to `strpos()`

* dumb syntax error

* another dumb syntax error

* Coding Style

* Code Simplification from Merge Review

* Better MYSQLI_REPORT_OFF implementations for php8.1 compat
Thanks @mentalstring

* remove full_path from uploads added on php8.1

* fix use of null on string parameter

* avoid passing `null` to `urlencode()`

* minor tweaks

* Eine Methode aufgeräumt und etwas Deutsch entfernt

Co-authored-by: Thomas A. Hirsch <thomas.hirsch@vema-eg.de>
Co-authored-by: Thomas <me@thirsch.de>
Co-authored-by: Thomas <th@it-solutions-hirsch.de>
Co-authored-by: Tybaze <tybaze@users.noreply.github.com>
Co-authored-by: Ben Tybaze <6998932+Tybaze@users.noreply.github.com>
Co-authored-by: Paulo Magalhaes <mentalstring@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants