Skip to content
Snippets Groups Projects
Commit cd840f08 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2046097 by Berdir, Gábor Hojtsy: Fixed Very long URL (>255) leads to...

Issue #2046097 by Berdir, Gábor Hojtsy: Fixed Very long URL (>255) leads to PDO exception when translation source locations are updated.
parent f770a28f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -146,6 +146,8 @@ protected function updateLocation($string) {
$created = FALSE;
foreach ($locations as $type => $location) {
foreach ($location as $name => $lid) {
// Make sure that the name isn't longer than 255 characters.
$name = substr($name, 0, 255);
if (!$lid) {
$this->dbDelete('locales_location', array('sid' => $string->getId(), 'type' => $type, 'name' => $name))
->execute();
......
......@@ -105,6 +105,19 @@ function testStringCRUDAPI() {
$this->assertFalse($string, 'Successfully deleted source string.');
$deleted = $search = $this->storage->getTranslations(array('lid' => $lid));
$this->assertFalse($deleted, 'Successfully deleted all translation strings.');
// Tests that locations of different types and arbitrary lengths can be
// added to a source string. Too long locations will be cut off.
$source_string = $this->buildSourceString();
$source_string->addLocation('javascript', $this->randomString(8));
$source_string->addLocation('configuration', $this->randomString(50));
$source_string->addLocation('code', $this->randomString(100));
$source_string->addLocation('path', $location = $this->randomString(300));
$source_string->save();
$rows = db_query('SELECT * FROM {locales_location} WHERE sid = :sid', array(':sid' => $source_string->lid))->fetchAllAssoc('type');
$this->assertEqual(count($rows), 4, '4 source locations have been persisted.');
$this->assertEqual($rows['path']->name, substr($location, 0, 255), 'Too long location has been limited to 255 characters.');
}
/**
......@@ -166,6 +179,9 @@ function testStringSearchAPI() {
/**
* Creates random source string object.
*
* @return \Drupal\locale\StringInterface
* A locale string.
*/
function buildSourceString($values = array()) {
return $this->storage->createString($values += array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment