SQL Error is thrown on User Roles fields. Patch attached.

Comments

oschuetze’s picture

Great! This Patch works fine.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine.

javlinsharp’s picture

StatusFileSize
new1.24 KB

I have found this bug in 6.x-2.12, the GA release version as well. However, the patch above is not appropriate for this version and obviously does not work.

Anyway, seems to be a different problem as the patch does a - and + on code I could not find in this version.

Any chances of a backfill?

Error msg
user warning: 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 ' 37, 41, 43, 44, 45, 46, 48, 34, 36) ORDER BY r.name' at line 1 query: SELECT u.uid, u.rid, r.name FROM role r INNER JOIN users_roles u ON u.rid = r.rid WHERE u.uid IN (, 37, 41, 43, 44, 45, 46, 48, 34, 36) ORDER BY r.name in /home/vldevelo/public_html/betadev/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc on line 26.

View Export attached

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Please generate patches from the views module root.

Committed to D6.x-3.x -- doesn't apply to 7.x, not sure if it needs to.

dawehner’s picture

bojanz’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Patch (to be ported) » Fixed
thinkinghuman’s picture

Version: 6.x-3.x-dev » 6.x-2.2
Status: Fixed » Needs review

Hi, I faced this error again and looked at the file itself (views_handler_field_user_roles.inc ). My file was truncated at line 26. Somehow in the middle of the SQL statement.

What I did is to download this file again from http://drupalcontrib.org/api/drupal/contributions--views--modules--user-...
and replace it.

This is weird. Seems to me like some module wanted to update this file and truncated it.

Best,

Sina

PS: Initially what did not work was that when I wanted to edit my Views in Drupal there was a Javascript error. By tracing it, I came to this file.

bojanz’s picture

Status: Needs review » Fixed

There's nothing to review here. Good to know you've solved your problem.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Uxi’s picture

Priority: Major » Normal
Status: Closed (fixed) » Active

I am still getting an error at line 26 when trying to display roles and the uid is empty (node-based view with -not required- relationship to referenced user and some user(s) is/are not present in a result set of multiple displayed rows).

user warning: 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 ' , 67, 10663, 10661, 10662, 10656, 10657, 10658) ORDER BY r.name' at line 1 query: SELECT u.uid, u.rid, r.name FROM role r INNER JOIN users_roles u ON u.rid = r.rid WHERE u.uid IN (3, , , 67, 10663, 10661, 10662, 10656, 10657, 10658) ORDER BY r.name in C:\xampp\htdocs\mijnwebs\nieuwnsijp\sites\all\modules\contrib\views\modules\user\views_handler_field_user_roles.inc on line 26.

IMO there should be a test if the result is empty or not in the for each loop at line 20.
This is what I ended up with:

    foreach ($values as $result) {
      $tempres = $this->get_value($result);
      if ($tempres) {
        $uids[] = $tempres;
      }
    }

At least that is what works for me.

Unfortunately at this stage I do not know how to submit this here, since I am a total drupal.org newbie, this being my first contribution ever. Still I hope this can help in some way?

dawehner’s picture

See http://drupal.org/node/707484 of a handbook how to create patches.

In general you should try to choose a describing variable name.
Can you update the used views version?

mustanggb’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)