Skip to main content

Finalising a deployment to Drupal 10 and reviewing the latest log messages.

 

Flysystem - $context is deprecated

Deprecated function: Creation of dynamic property Drupal\flysystem\FlysystemBridge::$context is deprecated in Drupal\Core\File\FileSystem->doScanDirectory() (line 720 of /var/www/html/content/core/lib/Drupal/Core/File/FileSystem.php)
#0 /var/www/html/content/core/includes/bootstrap.inc(164): _drupal_error_handler_real(8192, 'Creation of dyn...', '/var/www/html/c...', 720)
#1 [internal function]: _drupal_error_handler(8192, 'Creation of dyn...', '/var/www/html/c...', 720)

This error indicates that your Drupal installation is using a deprecated function related to the creation of dynamic properties in the Drupal\flysystem\FlysystemBridge class. The deprecated function is specifically mentioned as doScanDirectory() in the Drupal\Core\File\FileSystem class.

For this issue, I needed a patch regarding to resolve it - go to https://www.drupal.org/project/flysystem/issues/3387094#comment-15229040

 

Renderer::doTrustedCallback()

TypeError: Drupal\Core\Render\Renderer::doTrustedCallback(): Argument #1 ($callback) must be of type callable, array given, called in /var/www/html/content/core/lib/Drupal/Core/Render/Renderer.php on line 797 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 57 of /var/www/html/content/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).

Assess this error by adding a debug before the call to \Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback and inspecting what is the value of $callback when it's not a callable:

if (!is_callable($callback)) {
 xdebug_break();
}

 

SQLSTATE[40001]: Serialization failure: 1213 Deadlock

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO "cache_entity" ("cid", "expire", "created", "tags", "checksum", "data", "serialized") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6), (:db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13), (:db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20), (:db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27), (:db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34) ON DUPLICATE KEY UPDATE "cid" = VALUES("cid"), "expire" = VALUES("expire"), "created" = VALUES("created"), "tags" = VALUES("tags"), "checksum" = VALUES("checksum"), "data" = VALUES("data"), "serialized" = VALUES("serialized"); Array ( [:db_insert_placeholder_0] => values:menu_link_content:2 [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1699506969.405 [:db_insert_placeholder_3] => entity_field_info menu_link_content_values [:db_insert_placeholder_4] => 1268 [:db_insert_placeholder_5] => O:47:"Drupal\menu_link_content\Entity\MenuLinkContent":29:

This issue is related to a database deadlock in Drupal. A deadlock occurs when two or more database transactions are unable to proceed because each is waiting for the other to release a lock.

Explanation

The error message indicates a database exception related to a deadlock situation.
The SQLSTATE [40001] is associated with a serialization failure.
The error code 1213 specifically points to a deadlock.

Potential Causes

Concurrent transactions trying to modify the same set of data.
Transactions not releasing locks in a timely manner.

Begin by executing a Drush cache rebuild command

drush cr

Next update the settings.php file by adding the following

$databases['default']['default']['init_commands'] = [
	'isolation' => "SET SESSION tx_isolation='READ-COMMTTED'",
	'lock_wait_timeout' => "SET SESSION innodb_lock_wait_timeout = 20",
	'wait_timeout' => "SET SESSION wait_timeout = 600"
];

 

ArgumentCountError: Too few arguments

ArgumentCountError: Too few arguments to function Drupal\search_api\Utility\FieldsHelper::__construct(), 4 passed in /var/www/html/content/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 5 expected in Drupal\search_api\Utility\FieldsHelper->__construct() (line 87 of /var/www/html/content/modules/contrib/search_api/src/Utility/FieldsHelper.php)
#0 /var/www/html/content/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\search_api\Utility\FieldsHelper->__construct(Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Entity\EntityFieldManager), Object(Drupal\Core\Entity\EntityTypeBundleInfo), Object(Drupal\search_api\Utility\DataTypeHelper))

Next, remove the module completely and try re-installing it.

Otherwise, review the the following two files

  • …/search_api/src/Processor/ProcessorPluginManager.php (the line containing public function __construct) and
    …/search_api/search_api.services.yml (the line after the one containing ProcessorPluginManager)

 

Future planning

When completing a deployment to Drupal 10 or any upgrade and reviewing recent log messages, there are several steps you can take to ensure a smooth deployment and address any issues that may arise. Here are some key areas to follow:

Backup Your Site

Before making any significant changes, including Drupal updates, always create a backup of your site and database. This ensures that you can easily revert to a previous state if any issues occur during the deployment.

Update Drupal Core

Ensure that you are using the latest version of Drupal 10. Use Composer to update Drupal core:

composer update drupal/core-recommended --with-dependencies

Update Contributed Modules

Update all contributed modules to their latest versions, ensuring compatibility with Drupal 10

composer update drupal/* --with-dependencies

Update the database

The drush updatedb --no-cache-clear command is used to update the Drupal database schema without clearing the cache. 

drush updatedb --no-cache-clear

Here's a breakdown of what this command does:

drush: This is the command-line interface for managing Drupal.
updatedb or updb: This Drush command is used to apply any pending database updates required by Drupal core or contributed modules. It updates the database schema to match the current codebase.
--no-cache-clear: This option prevents Drush from clearing the cache after running database updates. Clearing the cache is a standard step after running database updates, but using this option skips that part of the process.

When you run drush updatedb --no-cache-clear, it performs any necessary database updates without affecting the cache. This can be useful in situations where you want to apply updates but delay clearing the cache until a later point.

Remember to clear the cache separately if needed, using drush cache-clear or a similar command, after you've completed any other tasks that might be affected by a cache clear.

 

Clear Caches

After updating Drupal core, contributed modules, or custom code, clear the Drupal cache to ensure that the changes take effect

drush cr

This command is helpful in scenarios where you want to clear and rebuild the entire cache, ensuring that all caches are up-to-date and consistent.  Here's a breakdown of what the command does:

drush: This is the command-line interface for managing Drupal.
cache:rebuild or cr: This is the specific Drush command for rebuilding the cache.
When you run drush cache:rebuild, Drush performs the following actions:

  1. Clears the Cache - It clears all caches, removing any cached data that may have become outdated.
  2. Rebuilds the Cache - It rebuilds the cache by regenerating the necessary cache entries based on the current state of the Drupal site. This ensures that caches are populated with up-to-date information.

Review Recent Log Messages

Navigate to the Drupal admin interface and go to "Reports" > "Recent log messages." Review any warning or error messages for information on potential issues. Address any deprecated functions or other warnings.

Check for Deprecated Code

If you encounter deprecated warnings, use tools like Drupal Check or Upgrade Status to identify and address deprecated code

composer require drupal/devel
drush devel:check

Update Configuration

If your site relies on custom configurations, ensure they are updated and compatible with Drupal 10. Some modules may introduce new configuration options.

Performance Testing

Perform performance testing to ensure that your site meets performance expectations. Use tools like Google Lighthouse or GTmetrix to analyse page speed.

Monitor Site Health

Set up monitoring tools to keep an eye on your site's health post-deployment. This includes monitoring server resources, error rates, and user experience.

Documentation

Update or create documentation for your team regarding any changes, configurations, or custom code introduced during the deployment.

Rollback Plan

In case of any critical issues, have a rollback plan in place to revert to the previous version of your site.

 

By following these steps, you can ensure a smooth deployment to Drupal 10 and address any issues that may arise during the process. Always test changes in a staging environment first to minimize the impact on your live site.

 

Related articles