Skip to main content

Attempting to apply a patch in Drupal 10.2.4 that had been working until this version.  Now I'm seeing the following error

Could not apply patch! Skipping. The error was: The process "patch '-p1' --no-backup-if-mismatch -d '/Users/andrewfletcher/Sites/codebales/modules/contrib/facets' < '/Users/andrewfletcher/Sites/codebales/patches/3336646-function-is-deprecated.patch'" exceeded the timeout of 300 seconds.

 

This error indicates that the patching process exceeded the maximum execution time limit of 300 seconds. This timeout issue could be due to various reasons, such as system performance, the complexity of the patch, or how the patch command is handling files. 

1. Increase the Timeout Limit

If you're applying the patch through a script or a tool that allows you to configure execution time limits, consider increasing the timeout setting. However, since the timeout is happening at the command line level, this might not be directly applicable.

 

2. Apply the Patch Manually

Given the relatively straightforward nature of the patch, you could manually apply the changes. This involves opening the Result.php file in an editor and inserting the new properties transliterateDisplayValue and termWeight as indicated by the patch. This manual process ensures that the patch's intended changes are applied without depending on the patch command's performance.

Manual Patching Steps:

Open Result.php located in src/Result/.

Locate the last property declaration in the class. Based on your file content, it should be right after the $children property declaration.
Insert the new property declarations for transliterateDisplayValue and termWeight exactly as shown in the patch. Ensure that you maintain the correct PHP syntax and formatting.

Here's how the insertion would look based on the patch:

/**
* Children results.
*
* @var \Drupal\facets\Result\ResultInterface[]
*/
protected $children = [];
/**
* The facet transliterate display value.
*
* @var string
*/
public $transliterateDisplayValue;
/**
* The term weight.
*
* @var int
*/
public $termWeight;
/**
* Constructs a new result value object.
*
* ...
*/


3. Verify Patch Application

After manually applying the changes, ensure that your application behaves as expected. Testing is crucial to verify that the manual patch application hasn't introduced any syntax errors or other issues.

 

Review your composer.json file to check the patch

"patches": {
     "drupal/facets": {
          "deprecated function": "patches/3336646-function-is-deprecated.patch"
     }
},

 

Related articles

Andrew Fletcher04 Apr 2025
Managing .gitignore changes
When working with Git, the .gitignore file plays a critical role in controlling which files and folders are tracked by version control. Yet, many developers are unsure when changes to .gitignore take effect and how to manage files that are already being tracked. This uncertainty can lead to...
Andrew Fletcher26 Mar 2025
How to fix the ‘Undefined function t’ error in Drupal 10 or 11 code
Upgrading to Drupal 10.4+ you might have noticed a warning in their code editor stating “Undefined function ‘t’”. While Drupal’s `t()` function remains valid in procedural code, some language analysis tools — such as Intelephense — do not automatically recognise Drupal’s global functions. This...
Andrew Fletcher17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...