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

random_bytes and random_int are detected as random extension functions and PHP 8.2 min version requirement #372

Closed
llaville opened this issue Mar 18, 2024 Discussed in #371 · 7 comments
Assignees
Labels

Comments

@llaville
Copy link
Owner

Discussed in #371

Originally posted by MocioF March 18, 2024
Hi,
I'm starting using this tool to inspect the code base of a wp plugin.
I need some help interpreting the output.
php-compatinfo says that minimum php version required is 8.2.0beta1 but I think this is a false result because my plugin runs on PHP 7.4.
In the extension list I see 2 values greater than 7.4.
One is for a "random" extension, detected on functions random_bytes and_random_int that should be in the core https://www.php.net/manual/it/random.installation.php
The other one is for "core" that asks for a minimum PHP 8.1.0alpha1 (when php-compatinfo is run on PHP 8.1.26-r1 (compiled on gentoo).
Is there something i misunderstand in this output:

Extensions Analysis
-------------------

   Extension  REF      EXT min/Max PHP min/Max PHP suggest  
   core       core     8.1.0alpha1 8.1.0alpha1              
   ctype      ctype    4.0.4       7.1.0       4.0.4        
   date       date     4.0.0       4.0.0                    
   dom        dom      5.0.0       5.0.0                    
   filter     filter   0.11.0      5.0.0                    
   hash       hash     1.1         4.0.0                    
   intl       intl     1.0.0beta   5.2.0                    
   json       json     1.2.1       5.3.0                    
   libxml     libxml   7.0.0alpha1 7.0.0alpha1              
   mbstring   mbstring 7.2.0alpha1 7.1.0       7.2.0alpha1  
   pcre       pcre     4.0.0       4.0.1                    
   random     random   8.2.0beta1  8.2.0beta1               
   standard   standard 7.2.0alpha1 7.1.0       4.0.0        
   Total [13]                      8.2.0beta1
```</div>
@llaville llaville added the bug label Mar 18, 2024
@llaville llaville self-assigned this Mar 18, 2024
@llaville
Copy link
Owner Author

Existing Random Number functions moved to the new random extension since PHP 8.2.0

But If you analyse a source code on previous platform like PHP 8.1 or less, the rule is that you should get expected version PHP min = 7.0.2

Component impacted is PHP CompatInfo DB that handle versionning of all elements including Doctrine ORM queries.

@llaville
Copy link
Owner Author

@MocioF FYI :
I've already found what I think to be the best fix for this issue. I'll test it more to see if I find any regression.
In case all will be ok, I'll release a PHP CompatInfo DB 6.4.1 that will include the correction.

All you'll then to do is run composer update

@MocioF
Copy link

MocioF commented Mar 18, 2024

Thanks @llaville, I will upgrade the software, when you will merge the update.

llaville added a commit to llaville/php-compatinfo-db that referenced this issue Mar 18, 2024
@llaville
Copy link
Owner Author

Explains

For developers who want to learn more about this issue.
Try these few examples to understand what's happens with CompatInfo DB releases 6.4.0 or lower.

Example with class AMQPException

vendor/bin/doctrine dbal:run-sql 'select * from classes where name = "AMQPException";'
 ---- -------------- --------------- ----------- ------- ---------- ------------- --------- --------- ---------
  id   extension_id   name            interface   flags   polyfill   ext_min       ext_max   php_min   php_max
 ---- -------------- --------------- ----------- ------- ---------- ------------- --------- --------- ---------
  3    1              AMQPException   0           1                  0.1.0                   5.2.0
  16   1              AMQPException   0           1                  2.0.0alpha1             7.4.0
 ---- -------------- --------------- ----------- ------- ---------- ------------- --------- --------- ---------

Before fix, you should get php_min = 5.2.0 whatever platform you are on

After fix, you will have php_min = 7.4.0 if your platform is PHP 7.4.0 or greater
and php_min = 5.2.0 if your platform is PHP 7.3.x or lower

Example with constant T_BAD_CHARACTER

vendor/bin/doctrine dbal:run-sql 'select * from constants where name = "T_BAD_CHARACTER";'
 ------ -------------- ----------------- ----------------- ---------- ------------ --------- --------- ------------ ---------
  id     extension_id   name              declaring_class   polyfill   deprecated   ext_min   ext_max   php_min      php_max
 ------ -------------- ----------------- ----------------- ---------- ------------ --------- --------- ------------ ---------
  6842   94             T_BAD_CHARACTER                                             4.2.0               4.2.0        5.6.40
  6977   94             T_BAD_CHARACTER                                             7.4.0               7.4.0beta1
 ------ -------------- ----------------- ----------------- ---------- ------------ --------- --------- ------------ ---------

Before fix, you should get php_min = 4.2.0 whatever platform you are on

After fix, you will have php_min = 7.4.0beta1 if your platform is PHP 7.4.0 or greater
and php_min = 4.2.0 if your platform is PHP 7.3.x or lower

Example with function random_int

vendor/bin/doctrine dbal:run-sql 'select * from functions where name = "random_int";'
 ------ -------------- ------------ ------------ ---------- ----------------- ----------- ------- ---------- ------------ --------- ------------ ---------
  id     extension_id   name         parameters   excludes   declaring_class   prototype   flags   polyfill   ext_min      ext_max   php_min      php_max
 ------ -------------- ------------ ------------ ---------- ----------------- ----------- ------- ---------- ------------ --------- ------------ ---------
  5275   65             random_int                                                         1                  8.2.0beta1             8.2.0beta1
  7969   86             random_int                                                         1                  7.0.2                  7.0.2
 ------ -------------- ------------ ------------ ---------- ----------------- ----------- ------- ---------- ------------ --------- ------------ ---------

Before fix, you should get php_min = 8.2.0beta1 whatever platform you are on

After fix, you will have php_min = 8.2.0beta1 if your platform is PHP 8.2.0 or greater
and php_min = 7.0.2 if your platform is PHP 8.2.0 or lower

@llaville
Copy link
Owner Author

PHP CompatInfo DB 6.4.1 has just been released !

@llaville
Copy link
Owner Author

PHP CompatInfo DB 6.4.2 has just been released !

And a PHP CompatInfo 7.1.3 is on way ...

llaville added a commit that referenced this issue Mar 19, 2024
@llaville
Copy link
Owner Author

PHP CompatInfo 7.1.3 has just been released !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants