Hi,
I've been tackling this problem for weeks now, and now that the production website is online, the problem still persists... I am totally frustrated. My problem:
I have a complicated view (see below) which sorts many fields from user, usernode and profile to create a userlist. All goes well, the view works (and gets overridden by template.php for own-written layout). After a few hits on that view page, it breaks, showing the following SQL error:
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 'DESC, profile_naam_value ASC' at line 1 query: SELECT DISTINCT(node.nid), value, profile_naam.value AS profile_naam_value, profile_instrument.value AS profile_instrument_value, profile_voornaam.value AS profile_voornaam_value, users.uid AS users_uid, profile_telefoon.value AS profile_telefoon_value, profile_pro.value AS profile_pro_value, usernode_users.access AS usernode_users_access, usernode_users.login AS usernode_users_login, profile_rvb.value AS profile_rvb_value FROM node node INNER JOIN usernode usernode ON node.nid = usernode.nid LEFT JOIN users usernode_users ON usernode.uid = usernode_users.uid LEFT JOIN users_roles users_roles ON node.uid = users_roles.uid INNER JOIN users users ON node.uid = users.uid LEFT JOIN profile_values profile_naam ON users.uid = profile_naam.uid AND profile_naam.fid = '2' LEFT JOIN profile_values profile_instrument ON users.uid = profile_instrument.uid AND profile_instrument.fid = '3' LEFT JOIN profile_values profile_voornaam ON users.uid = profile_voornaam.uid AND profile_voornaam.fid = '1' LEFT JOIN profile_values profile_telefoon ON users.uid = profile_telefoon.uid AND profile_telefoon.fid = '6' WHERE (node.type IN ('usernode')) AND (usernode_users.status = '1') AND (users_roles.rid IN ('3')) ORDER BY DESC, profile_naam_value ASC in /mounted-storage/home74a/sub007/sc42330-HQFI/www/akademos/includes/database.mysql.inc on line 172.
I am going crazy, because when I edit and save the view again (without changing anything) the view's behaviour goes back to normal... Until the next crash of the script of course... It seems like a field that has to be sorted does NOT show up in the query, thus showing
ORDER BY DESC, some_fiel ASC ...
which produces an error of course. The field that should have been there between BY and DESC is profile_pro_value, which is extracted at the beginning of the query.
My View:
$view = new stdClass();
$view->name = 'ledenlijst';
$view->description = 'Lijst van alle leden van Akademos.';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'Ledenlijst';
$view->page_header = '<p>Op deze pagina vind je een lijst met alle huidige leden van Akademos.<br />
Klik op de foto van een persoon om naar zijn/haar profiel te gaan. Waar "pro" staat, gaat het om tijdelijke professionele versterking.<br />
De volgorde van de leden is totaal willekeurig.</p>';
$view->page_header_format = '2';
$view->page_footer = 'Zin gekregen om mee te spelen? Neem <a href="meespelen">hier</a> alvast een kijkje!';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'table';
$view->url = 'ledenlijst';
$view->use_pager = FALSE;
$view->nodes_per_page = '0';
$view->sort = array (
array (
'tablename' => 'profile_aanvoerder',
'field' => 'value',
'sortorder' => 'DESC',
'options' => '',
),
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'profile_instrument',
'field' => 'value',
'label' => 'Instrument',
),
array (
'tablename' => 'profile_voornaam',
'field' => 'value',
'label' => 'Voornaam',
),
array (
'tablename' => 'profile_naam',
'field' => 'value',
'label' => 'Naam',
),
array (
'tablename' => 'users',
'field' => 'uid',
'label' => 'Afbeelding',
),
array (
'tablename' => 'profile_telefoon',
'field' => 'value',
'label' => 'Telefoon',
),
array (
'tablename' => 'profile_pro',
'field' => 'value',
'label' => 'Professioneel',
),
array (
'tablename' => 'usernode_users',
'field' => 'access',
'label' => 'Laatste pagina bezocht',
'handler' => 'views_handler_field_date_small',
),
array (
'tablename' => 'usernode_users',
'field' => 'login',
'label' => 'Laatst ingelogd',
'handler' => 'views_handler_field_date_small',
),
array (
'tablename' => 'profile_rvb',
'field' => 'value',
'label' => '',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'usernode',
),
),
array (
'tablename' => 'usernode_users',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
array (
'tablename' => 'users_roles',
'field' => 'rid',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => '3',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(profile_aanvoerder, profile_instrument, profile_voornaam, profile_naam, users, profile_telefoon, profile_pro, usernode_users, profile_rvb, node, users_roles);
$views[$view->name] = $view;
If tried removing and re-enabling some sort fields, but of course, it's just updating the page that repairs it temporarily.
Please advise soon. Thank you.
SabbeRubbish
Comments
Comment #1
SabbeRubbish commentedPlease advise, this is a very critical and published/exposed error. Thank you.
SabbeRubbish
Comment #2
chriszz commentedI have exactly the same problem!
http://drupal.org/node/167889
Comment #3
SabbeRubbish commentedThank you chriszz for pointing out that thread.
It has made me realize a very important thing, which MAY have solved the problem, and may well show me that this is not a bug, but desired functionality.
What I was doing wrong (or better: which was rather badly documented) is that - when using views - profile data that is PRIVATE (one of the two types of private), it can't be used in queries for users that don't have the privileges to see those fields.
Therefore, sorting was impossible for me, as the field data was not available to regular users.
The reason why this sometimes didn't happen, is because the view was stored in cache. Therefore, only sometimes when an unprivileged user accessed that page, there was an error.
I am waiting for other users to confirm this, before closing this ticket.
SabbeRubbish
Comment #4
chriszz commentedThank you, SabbeRubbish, i am trying out this idea - i made all fields visibility = 3 - so there should be no right-problem anymore. if that is true i will be honestly relieved - it sounds sound.
I will come back next week and tell, if it works now. What about your project - does it work now?
Regards
chriszz
Comment #5
SabbeRubbish commentedSo far so good, let's hope this is one problem solved for other users to enjoy the solution :)
Greetz,
SabbeRubbish
Comment #6
catchLooks like this is fixed then.
Comment #7
chriszz commentedYes - it works now for me - it is "by design" i guess - because the way it works is still not the way i would expect it to work.
In my opinion it should never show fields, if there lecks an access right - not show sometimes, and other times show failures. But if one knows, it is okay.
Comment #8
SabbeRubbish commentedIndeed by design, as showing the fields is indeed prohibited, but using them to sort or as a criterion should still be possible I guess.
SabbeRubbish
Comment #9
chriszz commentedWell - it should be prohibited - but that does not work - because it shows them anyway - and sometimes they break - and that is because of the caching-System, i guess - and therefore "by design"
regards
Christian