lat9 / usu

Ultimate SEO URLs for Zen Cart
GNU General Public License v3.0
1 stars 5 forks source link

Update various SQL queries, recognizing where fields are integers #30

Closed lat9 closed 4 years ago

lat9 commented 4 years ago

Many of the SQL queries used by the usu class include single-quotes around integer fields. For future-proofing, let's remove those.

webchills commented 4 years ago

There is a faulty query in the current includes/classes/usu.php around line 1240: if (USU_FORMAT == 'parent' || USU_CATEGORY_DIR == 'short') { $sql = "SELECT c.categories_id AS id, c.parent_id, cd.categories_name AS cName, cd2.categories_name as pName FROM " . TABLE_CATEGORIES . " AS c, " . TABLE_CATEGORIES_DESCRIPTION . " AS cd LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS cd2 ON c.parent_id = cd2.categories_id AND cd2.language_id = {$this->languages_id} WHERE c.categories_id = cd.categories_id AND cd.language_id = {$this->languages_id}"; } else { $sql = "SELECT categories_id AS id, categories_name AS cName FROM " . TABLE_CATEGORIES_DESCRIPTION . " WHERE language_id = {$this->languages_id}"; } Using MySQL 5.6 and PHP 7.3.6 and Zen Cart 1.5.6 the first query fails with: PHP Fatal error: 1054:Unknown column 'c.parent_id' in 'on clause' :: SELECT c.categories_id AS id, c.parent_id, cd.categories_name AS cName, cd2.categories_name as pName FROM categories AS c, categories_description AS cd LEFT JOIN categories_description AS cd2 ON c.parent_id = cd2.categories_id AND cd2.language_id = 1 WHERE c.categories_id = cd.categories_id AND cd.language_id = 1 ==> (as called by) /xxx/xxx/includes/classes/usu.php on line 1255 which prevents the whole admin from loading