Closed (fixed)
Project:
IndexPage
Version:
4.6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
3 Jun 2005 at 01:56 UTC
Updated:
28 Jul 2006 at 06:18 UTC
I have a drupal 4.6.1 distro with indexpage installed. One index is set up for the amazon-node type (from the Amazon Tools module). When I'm logged in as user 1 it works fine. But, when I try to access the index page as an anoymous user I get the following sql error:
user error: Unknown table 'na' in where clause
query: SELECT count(type) FROM node WHERE type = "amazon-node" AND na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0') in /home/thebeowu/public_html/includes/database.mysql.inc on line 66.
It's set up so anonymous users can access index pages. The index I have set up uses a vocabulary navigation and does not use an alphabetical listing.
Comments
Comment #1
soupp commentedOther authenticated users can not access this module too with the same issue. It works for user 1 only.
Comment #2
soupp commentedI'm not good at PHP (only remember it from my school) so I'm not sure this is the way to fix it... but here is fast and dirty fix:
In
function indexpage_page()there is a line:$exist_type = @db_result(db_query('SELECT count(type) FROM {node} WHERE type = "'.arg(1).'"'.($access ? ' AND '.$access : '')));I've changed it to:
$exist_type = @db_result(db_query('SELECT count(type) FROM {node} WHERE type = "'.arg(1).'"'));It works fine for me now.
Comment #3
ergophobe commentedActually, I think soupp's solution will prevent you from having proper access control. I'm totally new to Drupal and this is the first error I've gotten, first time I've looked at the code, but unfortunately there's some pretty bad abstraction going on here for reasons I don't understand. Be that as it may, the "na" is coming from the function that controls access parameters in the sql WHERE clause. This is found in node.module, line 1891
So you can see why it is not a problem for the admin - the function returns without effect if the current user can administer nodes. In the other case, though, it attaches the $node_access_alias.
The problem is that this function is apparently intended to be used with function _node_access_join_sql
Since this is all procedural, though, there's nothing to require that the two get used together (that's what I mean by bad abstraction). This is hte case in the indexpage.module. Since there is no INNER JOIN, there is no alias.
The Quick Hack
The quick hack is simply to add another table to the FROM clause, though this might cause issues for the admin b/c the table won't be mentioned in the WHERE clause.
In any case the query needs to get updated like so
$exist_type = @db_result(db_query('SELECT count(type) FROM {node}, {node_access} na WHERE type = "'.arg(1).'"'.($access ? ' AND '.$access : '')));
This is probably not the best solution, but it seems to work okay.
Comment #4
ergophobe commentedHmm... I don't seem to be able to edit my post. Sorry about the sidescroll caused by the <pre> tags
Comment #5
ergophobe commentedArgggh. Sorry for the spam. I just wanted to say that when I say "there's some pretty bad abstraction" I'm talking about the access routines in the nodes module, not the indexpage module, which is just using that. Still far from seeing the whys and wherefores of Drupal as I'm just now checking it out. I didn't mean to come off ungrateful or anything.
Comment #6
firebus commentedthanks rick_deckard. that worked for me (admin seems to have no problems with it either)
+1 to this patch getting included in the next release of the module.
Comment #7
ChickenStone commentedGreat work!! Everything looks like working fine, thx again Robert :D
Comment #8
pianoroad commentedI am having this problem, as well, and I'm not an advanced programmer, so I need an easier solution. I have granted permission to everyone to view indexpages, but users are getting:
index page for story
ERROR: That node type doesn't exist, there are no entries, or the index page for this node type is disabled.
I'll keep searching here for help, if I can't figure it out, I'll just remove the story module or disable it.
Thanks for any help.
Doug
Comment #9
MADLaker commentedThanks Rick,
Worked like a charm!
Comment #10
norberto commentedesto es una prueba
Comment #11
Uwe Hermann commentedCan you please speak english here? I have no idea what you said and why you changes the bug details.
Comment #12
ankur commented"esto es una prueba" translates to "this is a test".
As for why the issue has been changed from pertaining to the "IndexPage" module to the "location" module, I am not sure. That must be a mistake. Switching project back to "IndexPage". Get off my queue, issue!
-Ankur
Comment #13
webmestre@www.coll-vallcarca.net commentedThanks to this patch, now it runs right.
To those who are scared about programming, the only thing that they have to do is open the indexpage.module file with a text editor, find the $exist_type setence and replace the line. Save it, and upload. And the problem will be solved.
Thanks for your help.
Comment #14
Taylor Hewitt commentedgr8 patch thanks
Comment #15
HelpMeRick commentedThanks for the simple directions webmestre@www.coll-vallcarca.net. I can now use Indexpage module again.
Comment #16
cluckk commentedI tried the hack with no luck. I still get the same error for unregistered users. I like IndexPage and would like to use but will be unable to if I can't get this problem resolved.
Comment #17
cluckk commentedI got it to work. For those like me who tried the hack and found it did not help, deactivate the module and reactivate it from the Admin-->modules page. It works fine now. Thanks for the hack.
Comment #18
alexmc commentedPLEASE can someone incorporate these patches into the main code? Do we have to wait for someone? Can someone else take over CVS responsibility?
Comment #19
chuseq commentedI had the same problem with indexpage module, and before I saw this thread, I came up with a solution that worked. Basically it uses the _node_access_join_sql function to add the node_access table to do the join
Can someone please tell me if this patch is right? I mean, it resolved the problem, and it works fine now, but it is ok to use the _node_access_join_sql function here?
Thanks
Comment #20
carlosparamio commentedReally strange, yes. I will commit the solution proposed by rick_deckard, and I note it for investigate.
Thanks a lot!
Comment #21
carlosparamio commented