Bug at Recent.php at line 1083

Started by creatures, March 17, 2015, 03:13:14 AM

Previous topic - Next topic

creatures

My smf forum version is 2.0.9
I have upgraded mysql database from 5.5 to 5.7
They changed distinct and order by method I think

File: Recent.php at line 1083
Original sql
            SELECT DISTINCT t.id_last_msg,t.id_topic
            FROM {db_prefix}topics AS t
               INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
               INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : '
               LEFT JOIN {db_prefix}members AS mems ON (mems.id_member = ms.id_member)') . '
               LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
               LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})
            WHERE t.' . $query_this_board . '
               AND t.id_last_msg >= {int:min_message}
               AND (IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0))) < t.id_last_msg
               AND t.approved = {int:is_approved}
            ORDER BY {raw:order}
            LIMIT {int:offset}, {int:limit}',
            array_merge($query_parameters, array(
               'current_member' => $user_info['id'],
               'min_message' => (int) $min_message,
               'is_approved' => 1,
               'order' => $_REQUEST['sort'] . ($ascending ? '' : ' DESC'),
               'offset' => $_REQUEST['start'],
               'limit' => $context['topics_per_page'],
               'sort' => $_REQUEST['sort'],

Runned sql and finished with error
SELECT DISTINCT t.id_topic FROM smf_topics AS t INNER JOIN smf_messages AS m ON (m.id_topic = t.id_topic AND m.id_member = 1) LEFT JOIN smf_log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = 1) LEFT JOIN smf_log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = 1) WHERE t.id_board IN (6, 8, 11, 14, 15, 16, 18, 27, 28, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 69, 70, 71, 73, 75, 77, 78, 88, 89, 92, 94, 98, 99, 100, 101, 102, 107, 108, 109, 113, 119, 120, 122, 123, 124, 125, 127, 128, 129, 130, 131, 134, 135, 141, 142, 144, 145, 146, 147, 151, 161, 163, 164, 165, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 187, 190, 192, 196, 197, 199, 200, 201, 202, 204, 206, 207, 208, 209, 211, 213, 214, 215, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 239, 240, 241, 242, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322) AND t.id_last_msg >= 2597649 AND (IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0))) < t.id_last_msg AND t.approved = 1 ORDER BY t.id_last_msg DESC LIMIT 0, 50

Error Code: 3065. Expression #1 of ORDER BY clause is not in SELECT list, references column 'gilbaz_forumdb.t.id_last_msg' which is not in SELECT list; this is incompatible with DISTINCT


After changing the select with that program is gone
Modified sql
SELECT DISTINCT  t.id_last_msg,t.id_topic FROM....


Kindred

Thanks for the report.   Be aware that 5.7 is not currenyly supported by smf
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

creatures

Quote from: Kindred on March 17, 2015, 09:15:55 AM
Thanks for the report.   Be aware that 5.7 is not currenyly supported by smf
Oh, I didn't know that.
I just know below
"MySQL 5.0 or higher and PHP MySQL client API version 5.0 or higher if using MySQL."
http://download.simplemachines.org/requirements.php

I think there is a parameter in mysql to force the query in order to return the records.

Kindred

Yes, we need to rewrite that. At the time it was written, 5.6 was the latest version
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori

Quote from: Kindred on March 17, 2015, 05:37:01 PM
Yes, we need to rewrite that. At the time it was written, 5.6 was the latest version

it has not been updated in years. not just when 5.6 was the latest version.

the docs team is trying to update the page, starting with the version on the wiki.

http://www.simplemachines.org/community/index.php?topic=533466.0

Advertisement: