Hello everyone,
first, I'd like to congratulate the maintainers for this great module.

Second, I'd like to report an unexpected error when we try to set conditions greater than 64 characters.

The website encountered an unexpected error. Please try again later.Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1:
UPDATE {abjs_condition} SET
name=:db_update_placeholder_0,
script=:db_update_placeholder_1,
changed=:db_update_placeholder_2,
changed_by=:db_update_placeholder_3
WHERE cid = :db_condition_placeholder_0;
Array
(
[:db_update_placeholder_0] => The path is /redacted-123456789-123456789-123456789-123456789-123456789-123456789-123456789
[:db_update_placeholder_1] => return window.location.pathname == '/redacted-123456789-123456789-123456789-123456789-123456789-123456789-123456789';
[:db_update_placeholder_2] => 1563545945
[:db_update_placeholder_3] => 1
[:db_condition_placeholder_0] => 5
)

There is some specific reason to have this limit of characters?
How should we handle this problem?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andre.bonon created an issue. See original summary.

mhavelant’s picture

Hi!

The name field is added by the base module abjs.
I haven't looked at the code for a while, but glancing through it I can see that when a condition is added we auto-generate the name with "The path is $conditionPath". Note, there's a todo about displaying proper validation messages.

Adding a new field for condition names, so users have to enter them manually, would probably be a proper solution for this.
Maybe truncating the auto-generated name to 64 characters, but that might lead to some confusion for users in some cases.

Alternatively, you could open an issue for abjs for allowing longer names (in this case a schema update would be needed).

andre.bonon’s picture

Hi @mhavelant,

As you said, creating a new field for condition name is a better solution, but it'll demand more effort regarding implementation and testing.
I analysed the code and I think that if we truncate the condition name it'll not cause unexpected issues.
The condition name is displayed on AB JS condition list page only.

So, I created a patch to fix that and it is working fine.
Please take a look and tell me what do you think.

mhavelant’s picture

I tested the patch, works great, thank you!

mhavelant’s picture

Status: Active » Reviewed & tested by the community

  • mhavelant committed da8804c on 8.x-1.x authored by andre.bonon
    Issue #3068973 by andre.bonon: Database error when trying to save a URL...
mhavelant’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in the new beta7 release.

Status: Fixed » Closed (fixed)

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