TheNAF / naflm

NAFLM - NAF League Manager
Other
35 stars 34 forks source link

Some SQL querys doesn't work #319

Closed dannythunder closed 4 years ago

dannythunder commented 4 years ago

Trying to delete the default message about changing root password: This appears at login, some actions doesn't work. Like deleting the default news post.

I can create a team, so not everything is broken.

**PHP Stack trace**:, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.610659 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP   1. {main}() www/index.php:0, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.610729 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP   2. sec_main() www/index.php:100, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.610797 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP   3. HTMLOUT::simpleLeagueSelector() www/sections.php:104, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.610864 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP   4. HTMLOUT::nodeList() www/lib/class_htmlout.php:496, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.610948 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP   5. Coach::allowedNodeAccess() www/lib/class_htmlout.php:744, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.611016 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP   6. mysql_fetch_object() www/lib/class_coach.php:406, referer: http://www.xyz.zyx/index.php?section=main
[Fri Sep 18 12:02:50.612161 2020] [:error] [pid 3444] [client 81.25.81.57:61937] PHP Warning:  mysql_fetch_object(): supplied argument is not a valid MySQL result resource in www/lib/class_coach.php on line 415, referer: http://www.xyz.zyx/index.php?section=main

This is the query being ran:

SELECT
  l.lid AS 'lid',
  d.did AS 'did',
  t.tour_id AS 'trid',
  t.locked AS 'locked',
  t.type AS 'type',
  t.f_did AS 'f_did',
  t.name AS 'tname',
  d.f_lid AS 'f_lid',
  d.name AS 'dname',
  l.tie_teams AS 'tie_teams',
  l.name AS 'lname'
FROM
  leagues AS l
LEFT JOIN
  divisions AS d ON d.f_lid = l.lid
LEFT JOIN
  tours AS t ON t.f_did = d.did
GROUP BY
  l.name ASC,
  did DESC,
  trid DESC

The sql error:

#1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'bloodbowl.l.lid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
This is true for changing password etc aswell. 

If I remove the GROUP BY the query come back empty: MySQL returned an empty result set (i.e. zero rows). (Query took 0.0009 seconds.)

PHP version 5.6,

Spun up a new server running php 7.4 and ran install.php, renamed it, tried to enter the site:

[php7:error] [client xyz.zyx:59943] PHP Fatal error: Uncaught TypeError: Argument 1 passed to mysql_fetch_object() must be an instance of mysqli_result, bool given, called in /bloodbowl/lib/class_coach.php on line 415 and defined in /bloodbowl/lib/mysqli_wrapper.php:135\nStack trace:\n#0 /bloodbowl/lib/class_coach.php(415): mysql_fetch_object()\n#1 /bloodbowl/lib/misc_functions.php(45): Coach::allowedNodeAccess()\n#2 /bloodbowl/header.php(172): setupGlobalVars()\n#3 /bloodbowl/index.php(6): require('/bloodbowl/h...')\n#4 {main}\n thrown in /bloodbowl/lib/mysqli_wrapper.php on line 135

dannythunder commented 4 years ago

The issue is that empty sql expression.

lib/class_coach.php:397
$query = "SELECT l.lid AS 'lid', d.did AS 'did', t.tour_id AS 'trid',".implode(',',$properFields)."
            FROM leagues AS l LEFT JOIN divisions AS d ON d.f_lid = l.lid LEFT JOIN tours AS t ON t.f_did = d.did ".
            ((!$GLOBAL_VIEW) ? "LEFT JOIN memberships AS m ON m.lid = l.lid WHERE m.cid = $cid" : '') . ' GROUP BY l.name ASC, did DESC, trid DESC';
        $result = mysql_query($query);

Which fails here:

lib/class_coach.php:416
while ($r = mysql_fetch_object($result)) {
dannythunder commented 4 years ago

This might have to do with the latest release. I've downloaded master branch, new problems. Investigating that problem now. Keeping this open in case the problem exists it master.

dannythunder commented 4 years ago

Closing this. Problem is in the latest release. Working in master, and the other problem is patched by me and created a PR