Setup

  • Drupal Core version: 9.4.8
  • Search API version: 8.x-1.27

Issue

After updating to version 1.27, I get the following error.

ParseError: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in Composer\Autoload\includeFile() (line 58 of /modules/contrib/search_api/src/Plugin/views/query/SearchApiQuery.php).

The error is caused from the following line in the SearchApiQuery.php file.

public int $offset = 0;

Typed properties are available only in PHP 7.4 and higher. The minimum PHP version required from Drupal 9.4.x is PHP 7.3, which doesn't support typed properties.

Either the module requires at least PHP 7.4 or it doesn't use typed properties.

CommentFileSizeAuthor
#3 3316587-3-typed-properties-fix.patch415 bytesrehansyed89

Comments

rehansyed89 created an issue. See original summary.

rehansyed89’s picture

Issue summary: View changes
rehansyed89’s picture

StatusFileSize
new415 bytes
avpaderno’s picture

Version: 8.x-1.27 » 8.x-1.x-dev
Issue summary: View changes
Status: Active » Needs review
nvaken’s picture

We were also experiencing this on some external hosting platforms. Even though we do not condone running 7.3, the system requirements page indicates that Drupal 9 should be supporting >=7.3. But conversely I do see the module (since this typed property was introduced) has defined the use of php 7.4 in it's .info file, which puzzles me; does that condone the use of 7.4 features that break 7.3? I do see that the PHP property allows a module to define the minimal version, though is that allowed to be higher than the Drupal 9 support version? If so, I would still question if using PHP 7.4 features in this small of a change is worth the possible breaks that it causes on existing environments.

I think, if this typed property is to be removed, the php statement in the .info file could also be removed? If 7.4 is here to stay for this module, shouldn't we be able to set the php requirement for 7.4 in the composer.json so that existing projects won't upgrade to this version if on 7.3?

avpaderno’s picture

Status: Needs review » Needs work

The 8.x-1.25 release didn't require PHP 7.4. That requirement was added in the 8.x-1.26 release. IMO, that was a change to do in a different branch.

A site that updates to release 8.x-1.26 should get an error about the PHP version not being the one required from the module, but that happens when update.php is run.

@nielsva You are correct; If the typed properties are removed, then also the PHP requirement should be removed.

At this point, this is a decision only maintainers can take.

drunken monkey’s picture

Priority: Critical » Normal
Status: Needs work » Closed (won't fix)