Problem/Motivation

Status Report on D10.3. with php 8.3 says:

The following module is installed, but it is incompatible with PHP 8.3.6:

Diff

Steps to reproduce

precision = 24 (instead of default of 14) set in php.ini

Proposed resolution

change diff.info.yml from php8.1 to 8.3

name: Diff
type: module
description: Shows changes between content revisions.
php: 8.3

Remaining tasks

User interface changes

API changes

Data model changes

Comments

maxilein created an issue. See original summary.

maxilein’s picture

Priority: Normal » Major
StatusFileSize
new78.54 KB

Changing to critical since my suggested fix did not work.
The message is still there. And blocks update.php

maxilein’s picture

Investigating further this is the message in extend list:

This module requires PHP version 8.30000000000000071054274.* and is incompatible with PHP version 8.3.6.

I have a precision of 24 set in php.ini, because we need large numbers.

maxilein’s picture

changing php: 8.3 to 8.3.6 makes the error go away.

Where is that check done?
I'd like to make sure that other modules can handle it correctly.

maxilein’s picture

Priority: Major » Normal
maxilein’s picture

StatusFileSize
new27.66 KB

The same erroneous comparison is shown with 2.0beta.

maxilein’s picture

Title: Incompatible with PHP 8.3.6:Diff » False Status Message: Incompatible with PHP 8.3.6:Diff
Version: 8.x-1.7 » 2.0.0-beta2
acbramley’s picture

Status: Active » Postponed (maintainer needs more info)

I cannot reproduce this on 8.3 with Diff 2.x.

Can you please try to reproduce this with a vanilla Drupal installation.

maxilein’s picture

Hi,
this is the important difference: I have a precision = 24 (instead of default of 14) set in php.ini
You have to restart apache afterwards.

Where is the code that checks the php version in diff? I could not find it.

maxilein’s picture

Issue summary: View changes
acbramley’s picture

Title: False Status Message: Incompatible with PHP 8.3.6:Diff » PHP version comparison fails with higher precision
Project: Diff » Drupal core
Version: 2.0.0-beta2 » 11.0.x-dev
Component: Code » system.module
Status: Postponed (maintainer needs more info) » Active
quietone’s picture

Version: 11.0.x-dev » 11.x-dev
maxilein’s picture

// Ensure this module is compatible with the currently installed version of PHP.
    if (version_compare(phpversion(), $module->info['php']) < 0) {
      $compatible = FALSE;
      $required = $module->info['php'] . (substr_count($module->info['php'], '.') < 2 ? '.*' : '');
      $reasons[] = $this->t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', [
        '@php_required' => $required,
        '@php_version' => phpversion(),
      ]);
    }
maxilein’s picture

Another similar error.
https://stackoverflow.com/questions/10997482/php-version-compare-returns...

(https://www.php.net/manual/en/function.phpversion.php)

But I really don't understand where the extended float digits are coming from ...

maxilein’s picture

wrong issue...

dpi’s picture

Marking a similar issue in Scheduled Transitions as duplicate.

User reports issues where the patch PHP version they have should match the minimum minor version required by the contrib.

--

My initial thought on this from the ST issue is it could be a YAML implementation issue; a difference between PHP YAML or YAML package.

Could also be some kind of strict typing thing where the `php` value of info.yml should be stringed after read.

But precision sounds like more of a clue.

mstrelan’s picture

The Yaml decoder is interpreting the version as a float:

$ drush php:cli
Psy Shell v0.12.9 (PHP 8.4.8 — cli) by Justin Hileman
Drush Site-Install (Drupal 11.3-dev)
> var_dump(\Drupal\Core\Serialization\Yaml::decode(file_get_contents('modules/contrib/diff/diff.info.yml'))['php']);
float(8.1)

With precision 14:

> \Drupal\Core\Serialization\Yaml::decode('php: 8.1')['php'];
= 8.1

With precision 17 (or above):

> \Drupal\Core\Serialization\Yaml::decode('php: 8.1')['php'];
= 8.0999999999999996

If the version in info.yml file is wrapped in quotes then it is interpreted as a string.

> var_dump(\Drupal\Core\Serialization\Yaml::decode('php: "8.1"')['php']);
string(3) "8.1"

So we can either fix the yaml decoder, cast the version to a string in the version_compare, or wrap the PHP version in quotes.

mstrelan’s picture

Component: system.module » extension system

I think we should probably validate the Yaml and cast to the correct type in \Drupal\Core\Extension\ExtensionList::createExtensionInfo. Moving to extension component. Haven't looked for duplicates.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.