froot Posted November 30, 2022 Share Posted November 30, 2022 I have an issue with selectors, whenever there is a comma in the selected value… $foo = $item->foo; // "what, ever, with, commas" $bar = pages()->get("template=foo_template, title=$foo"); then I get Fehler: Exception: Unknown Selector operator: '[empty]' -- was your selector value properly escaped? (in wire/core/Selectors.php line 222) Because it thinks that what ever is after the comma is the next selector. Though the value in question is not expected to have commas, this shouldn't happen. How can I escape it properly? And then, also, even though I'm NOT in config debug mode, Tracy Debugger is NOT active and I am NOT logged in, i.e. not superuser, I still get the error in the frontend, breaking the entire output script, showing me no CSS (I use markup regions). That's of course not a good user experience. Shouldn't it show a white page instead? Do I have to use a try-catch code block? Link to comment Share on other sites More sharing options...
3fingers Posted November 30, 2022 Share Posted November 30, 2022 Sorry, in hurry: 2 Link to comment Share on other sites More sharing options...
froot Posted November 30, 2022 Author Share Posted November 30, 2022 thanks, ->selectorValue seems good BUT it breaks when the value contains Umlaute (äöü) It puts the value in between double quotes "" which breaks the rest of the selector and whatnot. ? Link to comment Share on other sites More sharing options...
3fingers Posted November 30, 2022 Share Posted November 30, 2022 Does this helps? Link to comment Share on other sites More sharing options...
froot Posted November 30, 2022 Author Share Posted November 30, 2022 I tried that. First of all, I don't see utf8mb4 in the list of charsets, as suggested in the stackOverflow answers, so I cannot select it. Then, trying to change the collation to utf8mb4_unicode_ci or utf8mb4_german2_ci doesn't help, I think it requires the charset to be set to utf8mb4 as well. If I check "Change all tables collations" and "Change all tables columns collations" I get an error like so The behaviour in the frontend of my project doesn't change anyway. I'm not very knowledgeable in that area anyway, so thanks for help! Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 6 hours ago, fruid said: First of all, I don't see utf8mb4 in the list of charsets What is your MySQL version? utf8mb4 support started with version 5.5. This query will list all available charsets: SHOW CHARACTER SET; Link to comment Share on other sites More sharing options...
froot Posted December 1, 2022 Author Share Posted December 1, 2022 I cannot find the MySQL version. It's not in the database settings in the host and there's no Database server widget when I click on the home icon in phpMyAdmin and also I do not have SSH access. Something so simple, so far… Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 3 minutes ago, fruid said: I cannot find the MySQL version. It's not in the database settings in the host and there's no Database server widget when I click on the home icon in phpMyAdmin and also I do not have SSH access. Something so simple, so far… In phpMyAdmin click on the Home icon. Now click on the tab "SQL" and insert "SHOW CHARACTER SET;" into the query editor. Now click GO in the bottom right. This should give you a list of available charsets like Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 To see the MySQL version, run this query: "SHOW VARIABLES LIKE 'version';" Link to comment Share on other sites More sharing options...
froot Posted December 1, 2022 Author Share Posted December 1, 2022 it says 5.7.33-log Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 14 minutes ago, fruid said: it says 5.7.33-log Then it should have utf8mb4 charset. Is it in the list of charsets when you run the query "SHOW CHARACTER SET;" like described above? Link to comment Share on other sites More sharing options...
froot Posted December 1, 2022 Author Share Posted December 1, 2022 yes it is in the list. Actually I don't know anymore where to set the CharSet at all (let alone that I didn't find utf8mb4 in the list). I think mixed it up with the dropdown in the import tab. So how to set the CharSet to begin with? And then, I thought I changed the collation for one specific database but it seems like that's a setting that applies to the whole server? Not good… Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 1 minute ago, fruid said: yes it is in the list. Actually I don't know anymore where to set the CharSet at all (let alone that I didn't find utf8mb4 in the list). I think mixed it up with the dropdown in the import tab. So how to set the CharSet to begin with? And then, I thought I changed the collation for one specific database but it seems like that's a setting that applies to the whole server? Not good… You can set the collation per database. See here: https://dev.mysql.com/doc/refman/8.0/en/charset-database.html You can run this query for a database to see current charset and collation: USE db_name; SELECT @@character_set_database, @@collation_database; You can run this query for a database to change charset and collation: ALTER DATABASE db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci 1 Link to comment Share on other sites More sharing options...
froot Posted December 1, 2022 Author Share Posted December 1, 2022 I ran the first query, it says @@character_set_database utf8mb4 @@collation_database utf8mb4_german2_ci so that setting doesn't solve my problem after all… should I try with utf8mb4_german2_ci ? Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 Don't think this is DB related then. Umlauts in sanitized selector value are not breaking the selector in my case $val = $sanitizer->selectorValue("äöü"); db($pages->find("title=$val")); // results in: // ProcessWire\PageArray // count: 0 // items: array (0) // selectors: 'title="äöü"' Link to comment Share on other sites More sharing options...
froot Posted December 1, 2022 Author Share Posted December 1, 2022 I will look into that and post my code eventually. thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now