I'm having virtually identical SQL errors when viewing any of the links provided by this module (except the add resource and add bookings pages).

* warning: Invalid argument supplied for foreach() in C:\wamp\www\drupal6\sites\all\modules\views\includes\query.inc on line 879.
* warning: Invalid argument supplied for foreach() in C:\wamp\www\drupal6\sites\all\modules\views\includes\query.inc on line 856.
* warning: Invalid argument supplied for foreach() in C:\wamp\www\drupal6\sites\all\modules\views\includes\query.inc on line 879.
* 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 'FROM bookings_resources bookings_resources LIMIT 0, 10' at line 2 query: SELECT FROM bookings_resources bookings_resources LIMIT 0, 10 in C:\wamp\www\drupal6\sites\all\modules\views\includes\view.inc on line 685.

Note: I've had to manually fix an issue with Call-time pass-by-reference being depreciated, hopefully I figured this out properly. I basically redefined the bookingsapi_expand function like so:


function bookingsapi_extend($hook_name, $op = null, &$data = null, &$config = null) {

then looked for all instances of this function being called, and carefully defining the $data and $config variables where necessary, and removing the Call-time pass-by-reference in the function.

Any further suggestions? I feel like this issue is related to the views code being used by this function, but I cannot figure out what the problem is.

CommentFileSizeAuthor
#8 bookingsapi.patch29.31 KBdwees
#8 publicbookings.patch19.09 KBdwees

Comments

4drian’s picture

I too am getting this error. Unfortunately I'm not a coder so can't help much. Is this related to Views 2 API changes? Seems to have hit a number of other modules that use Views 2.

dwees’s picture

That was my thought too. However 4-5 hours of pouring through Views 2 API and the code used by this module drew a blank for me. I guess I'm not a ninja php person. We need to recruit one of those to look into this for us.

Dave

dwees’s picture

I've been thinking about this, and really the one place where I did not spend enough time debugging was the hook_views_data or whatever it is called. It may be that the way the data tables are defined for Views has changed slightly, or that there is an error in one of the definitions. It's worth looking into.

Dave

4drian’s picture

May the force be with you dwees

dwees’s picture

Okay made some head-way just writing it down in case someone else decides to run with this.

Both the bookingsapi.module and the publicbooking.module are missing hook_views_api which should look like:


/**
 * Implementation of hook_views_api().
 */
function publicbookings_views_api() {
  return array(
    'api' => '2.0',
  );
}

and is required before views will load any external .views.inc files.

Next step:

solve:

Fatal error: Class 'views_handler_field_date' not found in C:\wamp\www\drupal6\sites\all\modules\bookingsapi\bookingsapi.views.inc on line 443

dwees’s picture

Okay figured out the classes. They need to be placed in separate files, and the modules bookingsapi and publicbookings need to both implement hook_views_handlers().

I'll be posting a somewhat monolithic path soon, stay tuned.

Next step, fix it so that one can actually create a booking request, the current code returns a bunch of errors.

Dave

dwees’s picture

Priority: Normal » Critical
Status: Active » Needs review

Okay so attached are 2 patches, one for each of bookingsapi.module and publicbookings.module, which basically do the following:

1. Fix the date repeat, I thought that rrule was required, now I'm not sure. Anyway.
2. Adds hook_views_api to both modules (so that our views get found)
3. Adds hook_views_handlers to both modules (so that our handlers get found)
4. Refactors the handlers into separate files, as suggested by the Views 2 documentation
5. Fixes this module to work with Php 5 where call-time pass-by-reference is depreciated.

Sorry for the monolithic patch, I just did a bunch of work to try and get everything working, and didn't keep very good track of my intermediate stages.

This module seems to require a patch from #273669: Fatal errors in Date Repeat in order to work properly. Not totally sure why, but couldn't get it to work without a modification of the patch suggested here. Unfortunately this patch is for the date_repeat module.

Also linking #314213: Bookings API doesn't work with newest version of Views 2 to this issue.

dwees’s picture

StatusFileSize
new19.09 KB
new29.31 KB

Patches vanished, trying again.

doughold’s picture

Thanks for the patch, worked great!

c.lam’s picture

Status: Needs review » Fixed

Hi everyone; sorry for disappearing this month - I'm swamped.

Dwees, I've committed your patches. I skimmed them and they seem fine, although I'm not able to test them right now. Ooy, Views.

In retrospect it makes sense to remove 'ical_' from those column names too.

Thanks so much!

dwees’s picture

Yeah I just removed it because I was trying to get the repeat stuff looking as much like what the Date Repeat functions do. I don't know if it's critical or not, but it also made it slightly easier to debug.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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