Bug when tables have prefixes

neochief - February 20, 2008 - 03:16
Project:Views Date Range Filter
Version:5.x-1.6
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

Hello.

I found nice bug in your module when database has table prefixes. It crashed my site :)
I fixed bug and made patch. Please review it.

AttachmentSize
daterange_node_created_argument_handler.patch980 bytes

#1

douggreen - February 20, 2008 - 12:20

Thanks! Is the ensure_table really needed? I thought that all views were based on nodes.

#2

neochief - February 21, 2008 - 20:17

Yes it is required, because query builds like "...select * from prefix_node as node..." (or something like that) and your code in WHERE will be "prefix_node.created" , but not "node.created" as it should be

#3

douggreen - February 22, 2008 - 00:28

So what your saying is {node}.created isn't expanded with the database prefix. If that's the case, then I think the solution is to expand it here rather than including the node table again.

Does my attached patch solve your problem?

AttachmentSize
224124.patch 1.03 KB

#4

neochief - February 22, 2008 - 03:21

Ive tried, but, nope, it still wrong.

here is the full buggy query with your patch

SELECT count( DISTINCT (
node.nid
) )
FROM m2b_node node
LEFT JOIN m2b_votingapi_cache votingapi_cache_vote_points_sum ON node.nid = votingapi_cache_vote_points_sum.content_id
AND votingapi_cache_vote_points_sum.content_type = 'node'
AND votingapi_cache_vote_points_sum.value_type = 'points'
AND votingapi_cache_vote_points_sum.tag = 'vote'
AND votingapi_cache_vote_points_sum.function = 'sum'
LEFT JOIN m2b_votingapi_cache votingapi_cache_vote_points_average ON node.nid = votingapi_cache_vote_points_average.content_id
AND votingapi_cache_vote_points_average.content_type = 'node'
AND votingapi_cache_vote_points_average.value_type = 'points'
AND votingapi_cache_vote_points_average.tag = 'vote'
AND votingapi_cache_vote_points_average.function = 'average'
WHERE (
(
node.type NOT
IN (
'buzz', 'event', 'group'
)
OR node.type IS NULL
)
)
AND (
votingapi_cache_vote_points_sum.value >0
)
AND (
m2b_node.created >1203563825
)

#1109 - Unknown table 'm2b_node' in where clause

as you see, your module puts "m2b_node.created", but it must put "node.created" to be fine

#5

douggreen - February 22, 2008 - 18:33

Hmm, then it's possible that this is the patch needed.

AttachmentSize
224124.patch 1020 bytes

#6

neochief - February 23, 2008 - 03:47

Maybe you are right, but I saw other modules putting ensure_table() in this situation anyway. Actually I do not know what it's doing :) It's just works for me. And without it too.

#7

douggreen - February 24, 2008 - 15:51

I'm not completely sure what you just said. Does the patch in #5 solve your problem? If so, then I'll commit it to th e project.

#8

neochief - February 25, 2008 - 11:08

Yes, it solved the problem.

#9

douggreen - February 25, 2008 - 11:24
Status:needs review» fixed

Thanks, committed

#10

Anonymous (not verified) - March 10, 2008 - 11:33
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.