Problem/Motivation
Following error is thrown while upgrading from Drupal 8.7 to Drupal 9.4:
Deprecated function: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Database\Connection->escapeLike() (line 1525 of core/lib/Drupal/Core/Database/Connection.php).
Drupal\Core\Database\Connection->escapeLike(NULL) (Line: 420)
Drupal\Core\Database\Query\Select->escapeLike(NULL) (Line: 118)
Drupal\Core\Entity\Query\Sql\Condition::translateCondition(Array, Object, ) (Line: 63)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 176)
Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 80)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 81)
Drupal\dspace_harvester\Controller\HarvesterController->harvest() (Line: 31)
dspace_harvester_cron(Object)
call_user_func('dspace_harvester_cron', Object) (Line: 325)
Drupal\ultimate_cron\Entity\CronJob->invokeCallback() (Line: 471)
Drupal\ultimate_cron\Entity\CronJob->run(Object) (Line: 24)
Drupal\ultimate_cron\Controller\JobController->runCronJob(Object)
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: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
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: 49)
Asm89\Stack\Cors->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: 21)
Steps to reproduce
Proposed resolution
I have already tried the steps mentioned in the below url but, still the error occurs:
https://www.drupal.org/project/paragraphs/issues/3253545
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Comments
Comment #2
cilefen commentedI would look into the contributed or custom modules shown in the stack trace.
Comment #3
cilefen commenteddspace_harvester seems the likely root cause.
Comment #4
longwaveBetter title, but I also think this is a custom code issue; looks like your
HarvesterController::harvest()method is passing NULL where a string is expected.Comment #5
cilefen commentedComment #6
tushar.k commented@cilefen and @longwave thankyou
I'll recheck the code once again and get back to you.
Comment #7
jfuentes commentedThis issue happens to me adding a custom block (of core).... Just after upgrade from 9.4.5 to 9.4.8 and PHP 8.1
Comment #9
cilefen commentedComment #10
aaronelborg commentedI think I fixed this by updating to the latest and greatest Paragraphs module. Does that sound familiar to anyone else?
Comment #11
paintingguy commentedDeprecated function: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Database\Connection->escapeLike() (line 1525 of core/lib/Drupal/Core/Database/Connection.php
I’m getting this when creating new registrations.
Php 8.1 Drupal core 9.5.3
Comment #12
tahirpatel commentedIt's not recommended to modify core files in Drupal. This can cause issues with future updates and maintenance of the site. Instead, you should create a patch file and add it to composer.
here are the steps to create a patch file and add it to composer:
Create a copy of the file Connection.php in the directory core/lib/Drupal/Core/Database to preserve the original file.
Edit the Connection.php file and replace the following code:
With:
Navigate to the root directory of your Drupal installation in the terminal/command prompt.
Run the following command to create a patch file:
git diff > path/to/your/patch/file.patchReplace path/to/your/patch/file.patch with the path where you want to save the patch file.
Open the composer.json file located in the root directory of your Drupal installation.
Add the following code to the extra section of the composer.json file:
Replace EscapeLike function with a short description of the patch, and path/to/your/patch/file.patch with the actual path where you saved the patch file.
Save the composer.json file and run the following command to apply the patch:
composer installThis will download the latest version of Drupal core and apply the patch automatically. If you have already installed Drupal core, you can run composer update instead of composer install.
That's it! The escapeLike() function will now return the original string if it is not set, and the patch will be applied automatically whenever you update or install Drupal core using composer.
=============
if the patch not applies, you need to install composer 'cweagans/composer-patches'.
The cweagans/composer-patches package is a Composer plugin that allows you to apply patches to third-party packages that you've installed via Composer.
To use this plugin, you can follow these steps:
Install the cweagans/composer-patches package via Composer:
composer require cweagans/composer-patchesAdd the patch to your composer.json file:
Run
composer installorcomposer update drupal/coreto apply the patch.Comment #13
tahirpatel commentedif patch not working you need to install 'cweagans/composer-patches'
The cweagans/composer-patches package is a Composer plugin that allows you to apply patches to third-party packages that you've installed via Composer.
To use this plugin, you can follow these steps:
Install the cweagans/composer-patches package via Composer:
composer require cweagans/composer-patchesAdd the patch to your composer.json file:
Run 'composer install' or 'composer update drupal/core' to apply the patch.