Project:Resource Conflict
Version:6.x-2.0
Component:Code
Category:bug report
Priority:critical
Assigned:raphaelhuefner
Status:closed (fixed)

Issue Summary

If I have revisions turned on for the content type that I am using for resource conflict, then it doesn't check that its only checking the current version's date. To explain...

I create a "Booking" with date 01/10/09 - 02/10/09
I then modify the booking to 03/10/09 - 04/10/09
with revisions turned on, there is an entry in the "content_type_booking" table in the database for both revisions.

The resource conflict is not checking for only the current revision, it kind of is but if I have understood correctly, in an incorrect manner. In resource_conflict.module line 384, instead of:

$query = "SELECT DISTINCT nid FROM $date_table
WHERE('%s' >= $start_field_name AND '%s' < $end_field_name)
OR('%s' > $start_field_name AND '%s' <= $end_field_name)
OR('%s' <= $start_field_name AND '%s' >= $end_field_name)";

Maybe...

$query = "SELECT MAX(vid) FROM $date_table
WHERE('%s' >= $start_field_name AND '%s' < $end_field_name)
OR('%s' > $start_field_name AND '%s' <= $end_field_name)
OR('%s' <= $start_field_name AND '%s' >= $end_field_name)";

and then query the vid?

Thanks
Will Eaton
Drupal Developer
http://www.williameaton.co.uk

Comments

#1

Priority:normal» critical

Yes, that sounds reasonable. Doing by only nid is a bit of an oversight.

I'm marking as critical, since revisions are a core feature. Instead of MAX(), it should probably be a join from {node}.vid. Feel free to write up a patch :).

#2

Assigned to:Anonymous» raphaelhuefner

I'm working on this for one of my clients. Hope to have a patch out until 2010-03-14.

#3

Thanks for the update - I'll be glad to review whatever you come up with.

#4

I went for the JOIN ... ON {node}.vid solution. The biggest delay was to separate this change from the change for #641850: repeat dates are not checked for conflicts in my working copy, which also modifies the SQL.

AttachmentSize
resource_conflict-2.0-590200.patch 2.03 KB
resource_conflict-2.x-dev-590200.patch 2.15 KB

#5

New patches, replacing the ones in #4. This time without wrong event table SQL. I shouldn't have touched the event-module-integration stuff, in the first place.

BTW: integration of the event module seems to be broken, at least with their current 2.x-dev version, which I checked as detailed here: http://drupal.org/node/3238/cvs-instructions/HEAD

AttachmentSize
resource_conflict-2.0-590200-1.patch 1.23 KB
resource_conflict-2.x-dev-590200-1.patch 1.33 KB

#6

Status:active» needs review

#7

Thanks for the note about Event integration. Due to the state of Event, I'm tempted to remove Event support entirely. That will likely happen for D7, but belongs in a new issue.

The code looks good on this - anyone else given it a try?

#8

Status:needs review» fixed

I've committed the patch in #5.

#9

Status:fixed» closed (fixed)

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