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
FatalError on SQL Manager #10316
Comments
@mickaelandrieu for info |
@mickaelandrieu i was able to track down why it breaks. The reason is this change: d7c9264 Explanation: |
@sarjon Do you mean that some "classic" SQL queries of Prestashop are being flagged as "invalid" by the updated PHPSQLParser ? |
not really @matks , if i remember correctly, In addition, wouldnt it be better to try to execute SQL and catch error instead of parsing and validating query as it is not 100% reliable? |
Issue improved by #10380 but root cause not fixed (yet) |
@sarjon Indeed the SQL validator has issues :/ however I am not fond of the solution "run the SQL query, catch error if there is one" it feels a bit ... raw 😅 . Like "to check if this wall is solid, let's hammer it, if it breaks it was not". Additionnaly a nice SQL validator should not only check a query is valid but also catch bad practices. The ideal solution is to fix/rebuild the SQL validator to have something working nice. But I dont know how long that would take 😢 I'm going to look at it |
i know its not the best solution to execute query, but building SQL parser that can parse any query does not sound fun at all. :/ |
@sarjon PierreRambaud suggested 1st the same solution you provided: execute the query and parse sql return. However if database is MyISAM, it does not allow the use of transactions (commit/rollback) so it cannot be done for INSERT/UPDATE queries. He suggested then we use sql "EXPLAIN" keyword :) to submit the query to mysql :) that would prevent the execution of INSERT/UPDATE queries. @mickaelandrieu this means a change of legacy code. Would it be considered a BC break andif yes, would it be acceptable ? |
@matks keep in mind that only SELECT sql statements are allowed. So INSERT/UPDATE/DELETE are invalid by default. |
@sarjon You are right:
https://github.com/PrestaShop/PrestaShop/blob/develop/classes/RequestSql.php#L191 Sorry for wasting your time @sarjon if I had read the code sooner I would have seen your solution was already implemented. So ... shall we just drop all the useless checks and just execute the query and parse |
Maybe we could revert the update of the library? It's sad but we could try to introduce it back during the freeze, wdyt @PierreRambaud ? |
We need to keep the latest version of PHPSQLparser, otherwise PrestaShop will be incompatible with PHP 7.2 :/ |
I don't like it, but it sounds like the perfect solution is not possible and this workaround sounds ok to me 👍 |
The migrated SQL Manager page has been hidden for 1.7.5 and will be back only for 1.7.6. However there is a new issue for 1.7.5, most of queries obtained by the scenario of this Issue |
Hi, LEFT JOIN pstoysproduct_lang pl ON(p.id_product = pl.id_product) LEFT JOIN pstoysspecific_price pr ON(p.id_product = pr.id_product) Could someone please tell me how can i fix this or if i have to upgrade to 1.7.5.0 so that i can export my products? |
You need to upgrade to the latest version of PrestaShop to get the fix :) |
Ok. Thanks a lot! |
Mmmm ... not sure. @marionf found the issue is fixed on |
ok..so i'll upgrade to 1.7.5 and see if it's working.. if not...what can I do? I really need to export my products. Can a module for export overwrite the issue ? |
@Madalina-nadari Is there something that prevents you from running your SQL query on your database ? |
When I make the query I wrote above, or any other one, i get the checkedform error - undefined.. The query can't be saved... I've tried the same query for another site with 1.7.0 and it's working just fine... |
And what about using phpmyadmin or a tool provide by your host? |
It's not fixed on 1.7.5.0 but it is on develop branch |
I'm not that good at that..i've tried and did not get the resultes i've wanted... I really need all the features and the images too..
Thanks for the info.. |
I confirm: it's not fixed on 1.7.5 |
Can i know if there is a way to correct this bug with some patch because i cant update the whole prestashop. |
Hi, basically the function If you are confident in your ability to check whether a SQL request is valid and harmless you can disable the custom checks to make the function look like this:
(maybe using an override) But please be aware:
|
Very good explanation. Thanks. Will try to use the "patch" and upgrade as soon as possible. |
Describe the bug
I have a FatalThrowableError when I try to export order sql query to sql manager
To Reproduce
Steps to reproduce the behavior:
Before on 1.7.4.2 I had this:
Additionnal information
PrestaShop version: develop
PHP version: N/A
The text was updated successfully, but these errors were encountered: