View Issue Details

IDProjectCategoryView StatusLast Update
0002747Composrcorepublic2019-08-12 17:24
ReporterChris GrahamAssigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status non-assignedResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0002747: PHP refresh (ongoing)
DescriptionCan do for PHP 5.6, prompted by future compat breaks...

Dynamically generate the <IfModule mod_php7.c> line in install.php based on actual PHP version running [DONE]

https://wiki.php.net/rfc/deprecations_php_7_3 (strip_tags change, symbols.php) [DONE]

Change any use of php_errormsg/track_errors to error_get_last [DONE]

Change any use of create_function to closures (this is used in the Tempcode compiler so is quite a big change) [DONE]



For PHP7, cool stuff without breaking earlier compat...

Look for 'eval' commands in the code, and wrap them to catch 'Error'. This catches fatal errors. We can then show a clean error message (and stack trace), including the PHP fatal error, and how long the evaluated code was (useful to catch DB truncation issues). We can possibly remove the debug_eval function, or possibly build all this into it (probably build into it). [DONE]

New automated test: call code then make sure get_resources returns empty; only run test if running on PHP7+ [DONE]

Support BMP files if it is there [DONE]



For PHP7, cool stuff when we drop earlier compat...

Implement static typing
 Make full use of static typed parameters - turn all our phpdoc headers into proper function signatures via an automated process
 Make the PHPdoc compiler complain if there is a mismatch between PHPdoc and argument/return typing
 Adjust ocProducts PHP to enable PHP 7's function-based static typing when ocproducts.type_strictness is enabled (so we don't need to do it in production with a declare command in each file)
 (Further update for PHP 7.1, nullable types and void returns)

Use new Unicode codepoint escape syntax instead of hex2bin

Update CQC to be able to parse PHP7 (we don't strictly have to do this, as we don't need to support this functionality, but we should be able to parse it anyway):
 Null coalescing operator
 Spaceship operator
 Constant arrays using define()
 Anonymous classes
 Group use declarations
 Generator delegation
 PHP 7.1
  [] instead of list()
  Support for keys in list()
  Class constant visibility
 PHP 7.2
  Allow a trailing comma for grouped namespaces
Update phpstub.php
 new functions are currently there as comments, ones we want to use will need structuring out
 define new params on these functions
  unserialize
  assert
  session_start
  dirname
  PHP 7.1
   get_headers
   unpack
 param changes
  PHP 7.2
   The $additional_headers parameter of mail() and mb_sendmail() now also accepts an array instead of a string.
Uncomment new PHP7 classes in code_quality.php

Update minimum version
 PHP version health check
 install.php
 tut_web_hosting.txt

Search the code for 'LEGACY' comments to resolve



Can do for PHP 7, prompted by future compat breaks...

...?



For PHP8, cool stuff without breaking earlier compat...

...?



For PHP 8 (roughly), cool stuff when we drop earlier compat...

https://wiki.php.net/rfc/trailing-comma-function-calls

Search the code for 'LEGACY' comments to resolve

...?
TagsRoadmap: ongoing, Roadmap: v11 partial implementation, Roadmap: v12
Attach Tags
Time estimation (hours)20
Sponsorship open

Relationships

related to 0002005 assignedSalman Web standards refresh 
related to 0003681 non-assigned Run the PHP codebase through PHP_CodeSniffer beautifier 
related to 0003860 non-assigned Use PSR-12 standard 

Activities

Chris Graham

2017-05-04 16:28

administrator   ~0005065

For removing create_function here's a start...

@@ -2104,6 +2104,17 @@ class Tempcode
  */
 function recall_named_function($id, $parameters, $code)
 {
+ static $has_closures = null;
+ if ($has_closures === null) {
+ $has_closures = (version_compare(PHP_VERSION, '5.3.0') >= 0);
+ }
+
+ if ($has_closures) {
+ return eval('return function(' . $parameters . ') { ' . $code . ' };');
+ }
+
+ // Old style, uses more memory...
+

But actually it needs a lot more work, the Tempcode engine will need overhauling because function_exists and eval won't work on closures. call_user_func will though.

Chris Graham

2018-12-07 16:36

administrator   ~0005887

PHP 5.6..

Variadic syntax

PHP 7.2...

Allow a trailing comma for grouped namespaces

PHP 7.3...

Trailing commas in function and method calls are now allowed.
More Flexible Heredoc and Nowdoc Syntax

New functions:
 array_key_first()
 array_key_last()
 hrtime()
 is_countable()

setcookie() and setrawcookie() new signature

Chris Graham

2019-05-09 21:12

administrator   ~0005952

More changes coming...

https://wiki.php.net/rfc/spread_operator_for_array
https://wiki.php.net/rfc/arrow_functions_v2
https://wiki.php.net/rfc/null_coalesce_equal_operator

Chris Graham

2019-07-09 12:43

administrator   ~0006031

https://wiki.php.net/rfc/numeric_literal_separator

Chris Graham

2019-08-12 17:24

administrator   ~0006068

A lot of this is probably mentioned above, but I went through the PHP 7.4 release notes...
 fread() and fwrite() will now return false if the operation failed. Previously an empty string or 0 was returned.
 Typed properties
 Arrow functions (fn)
 Coalesce assign operator (??=), https://wiki.php.net/rfc/null_coalesce_equal_operator
 Unpacking inside arrays, https://wiki.php.net/rfc/spread_operator_for_array
 Underscore character now valid in numeric literals (does nothing, formatting feature)
 The preg_replace_callback() and preg_replace_callback_array() functions now accept an additional $flags argument
 strip_tags() now also accepts an array of allowed tags
 New __serialize and __unserialize magic methods
 proc_open() now accepts an array instead of a string for the command; PHP will take care of any necessary argument escaping
 'real' case removed, and also is_real function
 The allow_url_include ini directive is deprecated. Enabling it will generate a deprecation notice at startup
 money_format removed
 convert_cyr_string removed
 hebrevc removed
 restore_include_path removed

Issue History

Date Modified Username Field Change
2016-07-29 22:18 Chris Graham New Issue
2016-12-07 23:53 Chris Graham Summary Switch to PHP7 => Switch to PHP7 (on hold)
2017-05-04 02:22 Chris Graham Relationship added related to 0002005
2017-05-04 16:28 Chris Graham Note Added: 0005065
2018-02-14 01:56 Chris Graham Description Updated View Revisions
2018-03-17 03:22 Chris Graham Description Updated View Revisions
2018-03-17 03:23 Chris Graham Summary Switch to PHP7 (on hold) => PHP refresh
2018-03-17 21:52 Chris Graham Description Updated View Revisions
2018-03-17 23:33 Chris Graham Description Updated View Revisions
2018-03-17 23:44 Chris Graham Description Updated View Revisions
2018-03-18 00:28 Chris Graham Description Updated View Revisions
2018-12-07 16:36 Chris Graham Note Added: 0005887
2019-05-09 21:12 Chris Graham Note Added: 0005952
2019-06-27 19:06 Chris Graham Summary PHP refresh => PHP refresh (ongoing)
2019-06-27 19:06 Chris Graham Tag Attached: Roadmap: v11 partial implementation
2019-06-27 19:06 Chris Graham Tag Attached: Roadmap: ongoing
2019-06-27 19:07 Chris Graham Tag Attached: Roadmap: v12
2019-07-09 12:43 Chris Graham Note Added: 0006031
2019-08-12 17:23 Chris Graham Relationship added related to 0003681
2019-08-12 17:23 Chris Graham Relationship added related to 0003860
2019-08-12 17:24 Chris Graham Note Added: 0006068