Closed (fixed)
Project:
Pathauto
Version:
8.x-1.9
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2022 at 09:35 UTC
Updated:
23 Mar 2022 at 20:04 UTC
Jump to comment: Most recent
When creating a new node and on that node you have an AJAX submit for example when inserting media from the media library you will receive some deprecation warnings.
In PathAutoState.php
/**
* Gets the data value currently stored in database.
*
* @return mixed
* The data value.
*/
protected function getOriginalValue() {
if ($this->originalValue === NULL) {
// If no value has been set or loaded yet, try to load a value if this
// entity has already been saved.
$this->originalValue = \Drupal::keyValue($this->getCollection())
->get(static::getPathautoStateKey($this->parent->getEntity()->id()));
}
return $this->originalValue;
}
this function will pass NULL because the entity is new.
Thus in my patch I will stop it here/fix it here.
Nonetheless the warnings come from here:
public static function getPathautoStateKey($entity_id) {
$entity_id_is_ascii = mb_check_encoding($entity_id, 'ASCII');
if ($entity_id_is_ascii && strlen($entity_id) <= 128) {
// The original entity ID, if it's an ASCII of 128 characters or less.
return $entity_id;
}
return Crypt::hashBase64($entity_id);
}Question?: Should we add an extra check in here?
Review + Answer question
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
Comment #5
berdirI'd say the fix is fine, the function does not support passing in NULL. I'd say once we require PHP 8 we could add a int|string type definition there and then it will fail earlier, but for now, this is good enough. Merged.