Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I use the views_natural_sort_remove_symbols transformation with the following symbols:
#"'\()[]«?!»¡¿
Somehow it manages to turn
Cuando...se abre, ¿dará algún tipo de señal?
into
Cuando...se abre, dar? algún tipo de señal
With the following result when field is inserted into db
WD node: PDOException: in views_natural_sort_store() (line 203 of
/Users/nirbhasa/Documents/htdocs/libry/sites/all/modules/views_natural_sort/views_natural_sort.module).
WD php: PDOException: in views_natural_sort_store() (line 203 of
/Users/nirbhasa/Documents/htdocs/libry/sites/all/modules/views_natural_sort/views_natural_sort.module).
I fixed by making adding the unicode (u) modifier to the preg_replace regex, but I am still not 100% sure what is happening. It does strip ¿ from other fields, but there is some combination of ¿ and á that is making it go funny:
My modified function:
function views_natural_sort_remove_symbols($string) {
$symbols = variable_get('views_natural_sort_symbols_remove', '');
if (strlen($symbols) == 0) {
return $string;
}
return preg_replace(
'/[' . preg_quote($symbols) . ']/u',
'',
$string
);
}
Comments
Comment #2
generalredneckAre you able to always reproduce it with that string? Like in other fields? Maybe on a fresh install? Just a quick question... to see if it's not a database encoding thing. If it's possible can you email me a sanatized sql dump? Generalredneck at Gmail dot com. Or at the very least double check the database encoding for me and make sure it's utf8_general_ci.
But I bet it's me using a unicorn unsafe function somewhere.
In the mean time I'll see what I can do as far as testing. I may not get a fast turn around on this one though. Good call on the /u anyway... it probably should be there.
Comment #3
generalredneckI was revisiting this issue. Here was some info I found on PHP.net
http://php.net/manual/en/reference.pcre.pattern.modifiers.php#107498
Since this is the case, it would be prudent to actually put this on all the preg_replaces I have. I'm going to do that and run my tests against it.
This might also explain some of the funkiness you found... Though I couldn't reproduce it at the time.
Comment #4
generalredneckComment #6
generalredneckSo I went ahead and committed this without review because I wrote a test to double check the removal function. See bdd421d.
Comment #8
generalredneckPorted to D8 as well.