Skip to content

Instantly share code, notes, and snippets.

View junaidpv's full-sized avatar

Junaid P V junaidpv

View GitHub Profile
@junaidpv
junaidpv / register-invoked-post-updates.php
Created August 28, 2023 11:24
This is a PHP script to run with drush on a drupal site that is giving error when updating from D9.4 to D9.5. The erros appearing like as reported at https://www.drupal.org/project/drupal/issues/3206215 and https://stackoverflow.com/questions/68598939/missing-updates-for-media-drupal-9
<?php
$post_update_registry = \Drupal::service('update.post_update_registry');
$modules = [
'block',
'block_content',
'comment',
'contextual',
'datetime_range',
'dblog',
@junaidpv
junaidpv / config_split-folder-relative-to-site-directory.patch
Created July 3, 2023 18:27
Modify the config_split module Folder storage option to look relative to the site directory instead of Drupal root.
diff --git a/src/ConfigSplitManager.php b/src/ConfigSplitManager.php
index 575680e..a85a2f0 100644
--- a/src/ConfigSplitManager.php
+++ b/src/ConfigSplitManager.php
@@ -512,7 +512,7 @@ protected function getSplitStorage(ImmutableConfig $config, StorageInterface $tr
}
if ('folder' === $storage) {
// Here we could determine to use relative paths etc.
- $directory = $config->get('folder');
+ $directory = \Drupal::getContainer()->getParameter('site.path') . '/' . $config->get('folder');
@junaidpv
junaidpv / config_split-config-export.patch
Last active May 29, 2023 05:51
Patch to bring feature allowing to export config split configurations.
diff --git a/config_split.module b/config_split.module
index 0cd7135..adcbb4b 100644
--- a/config_split.module
+++ b/config_split.module
@@ -9,6 +9,8 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\StreamWrapper\StreamWrapperManager;
+use Drupal\config_split\Controller\ConfigDownloadController;
@junaidpv
junaidpv / computed_field-fix-deprecation-warnings.patch
Created February 21, 2023 05:40
To fix this warning message originated from the computed_field module: Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).
diff --git a/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php b/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php
index 36be5e9..697c3ba 100644
--- a/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php
@@ -57,9 +57,9 @@ class ComputedStringFormatter extends ComputedFormatterBase {
protected function prepareValue($value) {
if ($this->getSetting('sanitized')) {
- return nl2br(Html::escape($value));
+ return !empty($value) ? nl2br(Html::escape($value)) : $value;
@junaidpv
junaidpv / 3328849-3-wwm-modified.patch
Last active January 2, 2023 19:41
It is rerolling of patch https://www.drupal.org/project/commerce/issues/3328849#comment-14850565 to apply over other patches already applied there.
diff --git a/modules/checkout/config/schema/commerce_checkout.schema.yml b/modules/checkout/config/schema/commerce_checkout.schema.yml
index 95d17db5..2acd96eb 100644
--- a/modules/checkout/config/schema/commerce_checkout.schema.yml
+++ b/modules/checkout/config/schema/commerce_checkout.schema.yml
@@ -78,6 +78,9 @@ commerce_checkout.commerce_checkout_pane.login:
register_form_title:
type: string
label: 'Title For New Customer Form'
+ register_form_mode:
+ type: string
diff --git a/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml b/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml
index c350ab28..630c7852 100644
--- a/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml
+++ b/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml
@@ -11,6 +11,7 @@ configuration:
login:
allow_guest_checkout: true
allow_registration: false
+ new_registration_mail: ''
step: login
@junaidpv
junaidpv / 3328849-2-wwm-modified.patch
Created December 22, 2022 15:23
It is rerolling of patch https://www.drupal.org/project/commerce/issues/3328849#comment-14840464 to apply over other patches already applied there.
diff --git a/modules/checkout/config/schema/commerce_checkout.schema.yml b/modules/checkout/config/schema/commerce_checkout.schema.yml
index a3ae1bcf..680b8ef6 100644
--- a/modules/checkout/config/schema/commerce_checkout.schema.yml
+++ b/modules/checkout/config/schema/commerce_checkout.schema.yml
@@ -75,6 +75,9 @@ commerce_checkout.commerce_checkout_pane.login:
register_form_title:
type: string
label: 'Title For New Customer Form'
+ register_form_mode:
+ type: string
@junaidpv
junaidpv / commerce-checkout-user-register-respect-field-group-settings.patch
Created December 20, 2022 18:15
To process field group settings on user register form in checkout pane.
diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php
index 2bdc785b..b1908d91 100644
--- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php
+++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Login.php
@@ -282,6 +282,7 @@ class Login extends CheckoutPaneBase implements CheckoutPaneInterface, Container
'#type' => 'email',
'#title' => $this->t('Email address'),
'#required' => FALSE,
+ '#weight' => -100,
];
@junaidpv
junaidpv / webform-ip-ban-integration.patch
Last active November 17, 2022 06:43
Patch for the webform module to integrate wtih the core ban module to block the IP address of a submission.
diff --git a/src/WebformSubmissionListBuilder.php b/src/WebformSubmissionListBuilder.php
index b684647ec..48cc91c43 100644
--- a/src/WebformSubmissionListBuilder.php
+++ b/src/WebformSubmissionListBuilder.php
@@ -1114,6 +1114,19 @@ class WebformSubmissionListBuilder extends EntityListBuilder {
'url' => $this->requestHandler->getUrl($entity, $this->sourceEntity, 'webform_submission.log'),
];
}
+
+ if ($this->moduleHandler()->moduleExists('ban') && $this->currentUser->hasPermission('ban IP addresses')) {
@junaidpv
junaidpv / update-drushrc-db-credentials.php
Created October 26, 2022 07:34
Script showing how db credentials in drushrc.php of an Aegir site can be updated.
<?php
$password = 'blahblahblacksheep1';
$user = 'db_user';
$db_name = 'test';
$lines = file('drushrc.php');
foreach ($lines as $index => $line) {
if (preg_match('/^\$options\[\'db_passwd\'\]\s*\=\s*\'.*?\'\s*\;/', $line)) {