Skip to content

Commit fc64166

Browse files
akhumphreythirschTybazementalstring
authored
NTO-180 PHP8.1 compatibility (#3)
* 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>
1 parent b071762 commit fc64166

File tree

78 files changed

+1049
-547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1049
-547
lines changed

.travis.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
os: linux
2-
dist: xenial
2+
dist: focal
33
language: php
44

55
php:
6-
- 7.0
7-
- 7.1
8-
- 7.2
9-
- 7.3
10-
- 7.4
11-
- nightly
6+
- 7.4
7+
- 8.0
8+
- 8.1
9+
- nightly
1210

1311
# run build against nightly but allow them to fail
1412
jobs:
1513
fast_finish: true
1614
allow_failures:
1715
- php: nightly
16+
- php: 5.3
17+
- php: 5.4
1818
include:
1919
- php: 5.3
2020
dist: precise
2121
- php: 5.4
22-
dist: precise
22+
dist: trusty
2323
- php: 5.5
2424
dist: trusty
2525
- php: 5.6
2626
dist: trusty
27+
- php: 7.0
28+
dist: xenial
29+
- php: 7.1
30+
dist: xenial
31+
- php: 7.2
32+
dist: xenial
33+
- php: 7.3
34+
dist: xenial
2735

2836
services:
2937
- memcached
@@ -40,6 +48,8 @@ install:
4048
# by default, --remote is not used on travis
4149
- git submodule update --remote --force
4250
- composer install --prefer-dist --no-progress --no-suggest -o
51+
# Temporary, while Doctrine is not merged, it will avoid one error tasksTest
52+
- echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
4353

4454
script:
4555
- php data/bin/check_configuration.php

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All the enhancements and BC breaks are listed in the [WHATS_NEW](https://github.
1111

1212
- [DIC](https://github.com/FriendsOfSymfony1/symfony1/wiki/ServiceContainer)
1313
- Composer support
14-
- PHP 7.2 support
14+
- PHP 8.1 support
1515
- performance boost
1616
- new widgets & validators
1717
- some tickets fixed from the symfony trac

WHATS_NEW.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ This allow you to remove all stylesheets and/or all javascripts added into the g
165165
Configuration
166166
-------------
167167

168-
A new configuration `sf_upload_dir_name` contains 'uploads' has been added.
168+
* A new configuration `sf_upload_dir_name` contains 'uploads' has been added.
169+
* A new settings `sf_display_errors` has been added to change display_errors from stdout to stderr for example.
169170

170171
Performance
171172
-----------
@@ -244,4 +245,4 @@ all:
244245
monolog.handler.file:
245246
class: Monolog\Handler\StreamHandler
246247
arguments: [/the/file/path/of/your/file.log]
247-
```
248+
```

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"require": {
88
"swiftmailer/swiftmailer": "~6.2",
9-
"php" : ">=5.3.0"
9+
"php" : ">=8.1.0"
1010
},
1111
"require-dev": {
1212
"psr/log": "*"
@@ -24,11 +24,8 @@
2424
},
2525
"extra": {
2626
"branch-alias": {
27-
"dev-master": "1.5-dev"
27+
"dev-php81": "1.6-dev"
2828
}
2929
},
30-
"replace": {
31-
"lexpress/symfony1": "^1.5"
32-
},
3330
"bin": ["data/bin/symfony"]
3431
}

lib/addon/sfPager.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ protected function resetIterator()
529529
*
530530
* @see Iterator
531531
*/
532+
#[\ReturnTypeWillChange]
532533
public function current()
533534
{
534535
if (!$this->isIteratorInitialized())
@@ -544,6 +545,7 @@ public function current()
544545
*
545546
* @see Iterator
546547
*/
548+
#[\ReturnTypeWillChange]
547549
public function key()
548550
{
549551
if (!$this->isIteratorInitialized())
@@ -559,6 +561,7 @@ public function key()
559561
*
560562
* @see Iterator
561563
*/
564+
#[\ReturnTypeWillChange]
562565
public function next()
563566
{
564567
if (!$this->isIteratorInitialized())
@@ -576,6 +579,7 @@ public function next()
576579
*
577580
* @see Iterator
578581
*/
582+
#[\ReturnTypeWillChange]
579583
public function rewind()
580584
{
581585
if (!$this->isIteratorInitialized())
@@ -593,6 +597,7 @@ public function rewind()
593597
*
594598
* @see Iterator
595599
*/
600+
#[\ReturnTypeWillChange]
596601
public function valid()
597602
{
598603
if (!$this->isIteratorInitialized())
@@ -608,6 +613,7 @@ public function valid()
608613
*
609614
* @see Countable
610615
*/
616+
#[\ReturnTypeWillChange]
611617
public function count()
612618
{
613619
return $this->getNbResults();

lib/autoload/sfCoreAutoload.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* The current symfony version.
1313
*/
14-
define('SYMFONY_VERSION', '1.5.14-dev');
14+
define('SYMFONY_VERSION', '1.6.0');
1515

1616
/**
1717
* sfCoreAutoload class.

lib/cache/sfFileCache.class.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,15 @@ protected function read($path, $type = self::READ_DATA)
256256
fseek($fp, 0, SEEK_END);
257257
$length = ftell($fp) - 24;
258258
fseek($fp, 24);
259-
$data[self::READ_DATA] = @fread($fp, $length);
259+
260+
if ($length > 0)
261+
{
262+
$data[self::READ_DATA] = @fread($fp, $length);
263+
}
264+
else
265+
{
266+
$data[self::READ_DATA] = '';
267+
}
260268
}
261269
}
262270
else

lib/config/sfApplicationConfiguration.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public function initConfiguration()
143143
}
144144

145145
// error settings
146-
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
146+
// PHP >= 5.2.4 supports stdout/stderr instead of bool here: https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
147+
ini_set('display_errors', $this->isDebug() ? sfConfig::get('sf_display_errors', 'stdout') : '');
147148
error_reporting(sfConfig::get('sf_error_reporting'));
148149

149150
// initialize plugin configuration objects

lib/config/sfViewConfigHandler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ protected function addHtmlHead($viewName = '')
223223

224224
foreach ($this->mergeConfigValue('metas', $viewName) as $name => $content)
225225
{
226-
$data[] = sprintf(" \$response->addMeta('%s', '%s', false, false);", $name, str_replace('\'', '\\\'', preg_replace('/&amp;(?=\w+;)/', '&', htmlspecialchars($content, ENT_QUOTES, sfConfig::get('sf_charset')))));
226+
$data[] = sprintf(" \$response->addMeta('%s', '%s', false, false);", $name, str_replace('\'', '\\\'', preg_replace('/&amp;(?=\w+;)/', '&', htmlspecialchars($content == null ? '' : $content, ENT_QUOTES, sfConfig::get('sf_charset')))));
227227
}
228228

229229
return implode("\n", $data)."\n";

lib/controller/sfController.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ protected function getController($moduleName, $controllerName, $extension)
299299
$classSuffix = ucfirst(strtolower($extension));
300300
if (!isset($this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix]))
301301
{
302-
$this->controllerExists($moduleName, $controllerName, $extension, true);
302+
if (!$this->controllerExists($moduleName, $controllerName, $extension, true))
303+
{
304+
return null;
305+
}
303306
}
304307

305308
$class = $this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix];

0 commit comments

Comments
 (0)