I got this error when running this module with Drupal 9.3 and PHP 8.1:

Deprecated function: substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\schema\SchemaDatabaseSchema_mysql->inspect() (line 203 of modules/contrib/schema/src/SchemaDatabaseSchema_mysql.php).
Drupal\schema\SchemaDatabaseSchema_mysql->inspect() (Line: 331)
schema_compare_schemas(Array) (Line: 53)
schema_requirements('runtime')
call_user_func_array(Object, Array) (Line: 426)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'schema') (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('requirements', Object) (Line: 433)
Drupal\Core\Extension\ModuleHandler->invokeAll('requirements', Array) (Line: 109)
Drupal\system\SystemManager->listRequirements() (Line: 93)
Drupal\system\SystemManager->checkRequirements() (Line: 124)
Drupal\system\Controller\SystemController->overview('system.admin_config')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 159)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Normally happens when I access the configurations page as administrator, I didn't check other pages.

Comments

fkatsukawa created an issue. See original summary.

fkatsukawa’s picture

Title: PHP 8.1 Incompatibility Issues » PHP 8.1 Compatibility Issues
fkatsukawa’s picture

StatusFileSize
new625 bytes

Here is a patch for this.

fkatsukawa’s picture

Status: Active » Needs review
jrglasgow’s picture

patch in #3 is working for me

avpaderno’s picture

Title: PHP 8.1 Compatibility Issues » substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\schema\SchemaDatabaseSchema_mysql::inspect()
Issue tags: +PHP 8.1
avpaderno’s picture

Version: 2.0.0-alpha1 » 2.x-dev
avpaderno’s picture

Status: Needs review » Needs work
-      if (substr($r->collation_name, -4) == '_bin') {
+      if (substr((string) $r->collation_name, -4) == '_bin') {

It doesn't make much sense to verify the last four characters are '_bin' when $r->collation_name doesn't contain a string.

adaucyj’s picture

I'll try another approach.

adaucyj’s picture

Status: Needs work » Needs review
StatusFileSize
new649 bytes

Please, let me know if it makes sense.

avpaderno’s picture

Status: Needs review » Reviewed & tested by the community

Yes, that works! is_string() doesn't complain about getting a value that isn't a string and the patch avoids the deprecation error.

avpaderno’s picture

Assigned: fkatsukawa » Unassigned

  • b9314c9 committed on 2.x
    Issue #3309766 by fkatsukawa, adaucyj, apaderno, jcnventura:  substr():...
jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.