Problem/Motivation

User gets the error below after saving a block containing empty link field:

Deprecated function: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Database\Connection->escapeLike() (line 1089 of core/lib/Drupal/Core/Database/Connection.php).
Drupal\Core\Database\Connection->escapeLike() (Line: 158)
Drupal\domain_path\DomainAliasRepository->lookupByAliasAndDomain() (Line: 39)
Drupal\domain_path\Plugin\Validation\Constraint\DomainPathUniqueConstraintValidator->validate() (Line: 231)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints() (Line: 172)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 190)
...

Steps to reproduce

On a fresh Drupal 11.4.4 and domain_path 3.0.0

  1. Add at least one domain record: admin/config/domain
  2. Create a test block with at least one Link field
  3. Activate Layout builder to any Content Type
  4. Create a test node and try to add the test Block with empty link field
  5. The page is saved but huge warning is displayed

Proposed resolution

Early return if we have a empty alias
if (empty($value->alias)) ?? return;

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

igorgoncalves created an issue. See original summary.

igorgoncalves’s picture

Status: Active » Needs review

mably made their first commit to this issue’s fork.

mably’s picture

Hi @igorgoncalves, thanks for your MR.

Can you give a try to MR 123 and tell me if it fixes your problem?

igorgoncalves’s picture

Hey @mably

Yes, the MR 123 fix also works on my project and the warning/error is gone.

thanks for you fast check on this one!

  • mably committed 388940de on 3.x
    fix: #3611433 Fixing warning of: 'Deprecated function: addcslashes...'...

  • mably committed b6ef3fbc on 2.x
    fix: #3611433 Fixing warning of: 'Deprecated function: addcslashes...' (...
mably’s picture

Status: Needs review » Fixed

Thanks @igorgoncalves for your feedback, it's merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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