Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Funktioniert nicht mit reservierte MySQL Keywords, fehlendes Escaping #49

Closed
alxndr-w opened this issue May 20, 2019 · 11 comments
Closed

Comments

@alxndr-w
Copy link
Contributor

image

@tbaddade
Copy link
Owner

Funktioniert nicht unter Subdomains ohne www.

wie genau sieht diese bei dir aus?

Bei uns klappt diese Kombination
https://projekt.arbeitsdomain.de

Du könntest auch mal das hier aufrufen
/redaxo/index.php?page=watson&watson_query=Test

Eventuell erhälst du einen Fehler.

@alxndr-w
Copy link
Contributor Author

Error while executing statement " SELECT id, name AS name FROM rex_dance_voucher_order WHERE (to LIKE "%Test%") OR (euro LIKE "%Test%") OR (name LIKE "%Test%") OR (street LIKE "%Test%") OR (zip LIKE "%Test%") OR (city LIKE "%Test%") OR (phone LIKE "%Test%") OR (email LIKE "%Test%") OR (kname LIKE "%Test%") OR (iban LIKE "%Test%") OR (blz LIKE "%Test%") OR (message LIKE "%Test%") ORDER BY id LIMIT 20"! SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to LIKE "%Test%") OR (euro LIKE "%Test%") OR (name LIKE "%Test%") OR (street LIK' at line 1

Es gibt kein Feld to

Ich habe das Phänomen bisher tatsächlich nur in Seiten, die nicht www. als Subdomain haben. Evtl. funktioniert bei dir / bei euch automatisch www.projekt.arbeitsdomain.de - aber vielleicht hast du recht, und das ist hier ein anderer Fehler.

@tbaddade
Copy link
Owner

tbaddade commented May 20, 2019

Das to Feld müsste in deiner YForm Tabelle existieren, da Watson die Felder von YForm abholt.

Kannst du mal diese Zeile hier anpassen
https://github.com/tbaddade/redaxo_watson/blob/master/lib/Watson/Foundation/Command.php#L126

Alt

$w[] = $field.' LIKE "%'.$command_part.'%"';

Neu

$w[] = '`'.$field.'` LIKE "%'.$command_part.'%"';

Und danach die obige Url direkt aufrufen.

@alxndr-w
Copy link
Contributor Author

Dann bekomme ich

Error while executing statement " SELECT a.id, a.clang_id, CONCAT(a.id, "|", a.clang_id) as bulldog FROM rex_article AS a WHERE (`a.id` LIKE "%Test%") OR (`a.name` LIKE "%Test%") GROUP BY bulldog LIMIT 20"! SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a.id' in 'where clause'

ich korrigiere mich: to ist auf jeden Fall vorhanden, ich habe in der falschen Tabelle geschaut.

@tbaddade
Copy link
Owner

Ok dann müsste das anders gelöst und Watson umgebaut werden … Aber es liegt an deinem Feld to … Siehe https://dev.mysql.com/doc/refman/5.7/en/keywords.html#keywords-5-7-detailed-T

@staabm
Copy link
Contributor

staabm commented May 21, 2019

ich vermute du brauchst sowas

if (strpos($field, '.') !== false) {
  $field = '`' .str_replace('.', '`.`, $field). '`';
} else {
  $field = '`'. $field .'`';
}

ich denke hier in deinem like fehlt noch weiteres escaping
$command_part = str_replace(['_', '%'], ['\_', '\%'], $command_part);

Ungetestet!

@tbaddade tbaddade changed the title Funktioniert nicht unter Subdomains ohne www. Funktioniert nicht mit reservierte MySQL Keywords, fehlendes Escaping May 21, 2019
@dpf-dd
Copy link

dpf-dd commented Dec 2, 2019

Ich habe das Issue heute entdeckt und kann den Fehler exakt wie Alex beschrieben hat bestätigen. Bei mir triggert einer Column "alter" den Fehler...

@staabm
Copy link
Contributor

staabm commented Dec 2, 2019

Funktioniert der vorgeschlagene fix ein Kommentar weiter oben für dich?

@dpf-dd
Copy link

dpf-dd commented Dec 2, 2019

Düdüm. Ich hatte vergessen die Backticks unten in der Zeile rauszunehmen, nachdem ich deinen Fix eingebaut hatte. Jetzt haut es hin und Watson funktioniert wieder! :) Danke!
Das passst so und ich verstehe sogar den Fehler und was deine zwei Zeilen dagegen tun. Genial. Warum ist der Issue dann hier eigentlich noch offen? Soll ich eine PR draus machen?

Danke!

@staabm
Copy link
Contributor

staabm commented Dec 3, 2019

Gerne einen PR machen.

Das issue ist offen weil noch niemand einen Fix bereitgestellt hat (und der fix bisher nicht getestet war - sondern eher geraten).

dpf-dd pushed a commit to dpf-dd/redaxo_watson that referenced this issue Dec 3, 2019
Fix für Issue 49, Lösung von @staabm getestet, für gut befunden und eingebaut :)
tbaddade#49
@tbaddade
Copy link
Owner

tbaddade commented Dec 3, 2019

Das issue ist offen weil noch niemand einen Fix bereitgestellt hat (und der fix bisher nicht getestet war - sondern eher geraten).

Hatte den Fix schon seit einer Weile Lokal drin wohl nur vergessen zu committen. Sorry dafür.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants