Views lets you create views from templates now. We need to have a template for each available date field to easily create a calendar for that field.

This will make it possible to create a new calendar at any time for any date field, and will allow us to quit using default views for that purpose.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

Status: Active » Fixed

This has been committed.

KarenS’s picture

FileSize
62.06 KB

When clicking on the option to create a view from a template, you now see something like this. Click 'Add' next to one of them to create the view:

arlinsandbulte’s picture

Category: feature » bug
Status: Fixed » Active

After the commit that added this feature, I get the following error when I click on the option to create a view from a template:

Fatal error: Call to undefined function date_views_fields() in /home/quickstart/websites/example.dev/sites/all/modules/calendar/includes/calendar.views_template.inc on line 29 Call Stack: 0.0052 644368 1. {main}() /home/quickstart/websites/example.dev/index.php:0 0.3866 31742832 2. menu_execute_active_handler() /home/quickstart/websites/example.dev/index.php:21 0.4105 34011200 3. call_user_func_array() /home/quickstart/websites/example.dev/includes/menu.inc:503 0.4105 34011568 4. views_ui_add_template_page() /home/quickstart/websites/example.dev/includes/menu.inc:0 0.4105 34011568 5. views_get_all_templates() /home/quickstart/websites/example.dev/sites/all/modules/views/includes/admin.inc:5158 0.4222 34896488 6. calendar_views_templates() /home/quickstart/websites/example.dev/sites/all/modules/views/views.module:1271

Note: the undefined function date_views_fields() *IS* found in the file: date_views.views.inc line 145.

This is on a fresh D7.10 site
Ctools: 7.x-1.0-rc1.110-dev
Views: 7.x-3.1.17-dev
Date: 7.x-2.0-rc1.69-dev
Calendar: 7.x-3.0-alpha2.4-dev
(Note the new -dev release number notation from #1314180: Make dev release numbers useful)

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

I can't replicate any problem, they work fine for me. But that function is in an .inc file and maybe there are some times when it isn't loaded in time. I tried moving it to the .module file. See if that helps.

http://drupalcode.org/project/date.git/commit/587af42

arlinsandbulte’s picture

Assigned: Unassigned » arlinsandbulte

Hmmm very strange... after pulling the latest from git (all required modules) I not get a new undefined function error:

Fatal error: Call to undefined function _views_prepare_handler() in /home/quickstart/websites/example.dev/sites/all/modules/views/views.module on line 1146 Call Stack: 0.0006 644320 1. {main}() /home/quickstart/websites/example.dev/index.php:0 0.3032 31454904 2. menu_execute_active_handler() /home/quickstart/websites/example.dev/index.php:21 0.3272 33723416 3. call_user_func_array() /home/quickstart/websites/example.dev/includes/menu.inc:503 0.3272 33723784 4. views_ui_add_template_page() /home/quickstart/websites/example.dev/includes/menu.inc:0 0.3272 33723784 5. views_get_all_templates() /home/quickstart/websites/example.dev/sites/all/modules/views/includes/admin.inc:5158 0.3344 34049688 6. calendar_views_templates() /home/quickstart/websites/example.dev/sites/all/modules/views/views.module:1271 0.3363 34204760 7. date_views_fields() /home/quickstart/websites/example.dev/sites/all/modules/calendar/includes/calendar.views_template.inc:29 0.3377 34207432 8. _date_views_fields() /home/quickstart/websites/example.dev/sites/all/modules/date/date_views/date_views.module:63 0.4223 35957704 9. views_get_handler() /home/quickstart/websites/example.dev/sites/all/modules/date/date_views/includes/date_views_fields.inc:56

I am going to completely tear-down and build from scratch & supply more info & a step-by-step shortly.

arlinsandbulte’s picture

Step-by-step instructions to reproduce the problem:

  1. Download & install Drupal 7.10. Use default install profile. Clean URLs are enabled.
  2. goto /admin/config/regional/settings & set Default Country to United States. All other settings at default. Save configuration.
  3. goto /admin/config/regional/date-time & click Save Configuration (leaving all at defaults... not sure if this is needed, but I think it was at one point...)
  4. Git Clone into Date, Calendar, Views, & Ctools.
  5. Checkout Date 7.x-2.x (latest git-dev)
  6. Checkout Calendar 7.x-3.x (latest git-dev)
  7. Checkout Views 7.x-3.x (latest git-dev)
  8. Checkout Ctools 7.x-1.x (latest git-dev)
  9. Enable Calendar, Date, & Views UI on the modules page. (Click continue to enable all required dependencies too).
  10. Visit /admin/config/regional/settings and click Save Configuration without saving anything (I think there is an issue about this needed to be done somewhere)
  11. Visit /admin/config/regional/date-time and click Save Configuration without saving anything (I think there is an issue about this needed to be done somewhere)
  12. Goto /admin/structure/views & click "Add view from template" <-- This causes a WSOD with the above error.

Here is a list of my site configuration info (using the quickstart VM):
Database system: MySQL, MariaDB, or equivalent
Database system version: 5.1.54-1ubuntu4-log
PHP: 5.3.5-1ubuntu7.4
Web server: Apache/2.2.17 (Ubuntu)

[EDIT] After all the above steps I did the following:

  1. I tried clearing the cache at /admin/config/development/performance and received the same WSOD & error message.
  2. Then, I hit the BACK button, clicked 'Clear all caches' again and DID NOT get an error!
  3. Click 'Clear all caches' again -- no error!
  4. Visit /admin/structure/views & click "Add view from template" -- Error is shown.
  5. Goto /admin/config/development/performance & click 'Clear all caches' -- Error is shown.
  6. Click the BACK button, click 'Clear all caches' again -- No Error!

This is really strange....

KarenS’s picture

Assigned: arlinsandbulte » Unassigned
Status: Postponed (maintainer needs more info) » Active

Just out of curiosity, see what happens when you try to use the default template that comes with views (there is an image gallery template). Do you get an error with that? If so, this may be a bug in the Views template system. I already ran into one small issue with that, and I don't think it's been used much so errors haven't been bled out of it yet.

Also see if clearing the cache and trying again does anything.

arlinsandbulte’s picture

Cross-post during my edit: see my edit in #6 above regarding clearing the cache.

Regarding the default template that comes with views, that seems ok so long as calendar is not enabled (which causes the WSOD & error message when clicking on the link).

arlinsandbulte’s picture

All of my work so far has been done on my local machine using the Quickstart VM on my windows laptop.
I am now going to try reproducing this on my dreamhost server (using a sub-domain).

KarenS’s picture

I'm guessing this is something to do with using this on a site that has no date fields. Try creating a date field and see if things work right then.

arlinsandbulte’s picture

I thought the same before and I think I tried that, but still got the error... but I will verify again.

KarenS’s picture

Works fine for me on existing site, but I haven't tried a new install yet, so I'll try that now and see if I can figure out what would be different.

arlinsandbulte’s picture

Fresh install on my dreamhost server failed with same error.
I followed the steps in #5, but I added a date field to the article content type before step #12.

Maybe I need some content (nodes)... trying that now:
Nope, adding an article node does not solve the problem.

KarenS’s picture

It's tripping on this code in date_views.fields.inc:

    if (!$handler = views_get_handler($table_name, $field_name, 'filter')) {
      continue;
    }

The message is as though the views module does not exist, even though we're doing this in views. The function it cannot find, _views_prepare_handler(), seems not to be available at this point.

I haven't found the magic thing that makes it start working, but I can assure you it works fine on another site with lots of views and fields. This is really odd.

arlinsandbulte’s picture

Well, at least we know the problem is reproducible. That is 90% of the battle....

arlinsandbulte’s picture

Title: Add Calendar templates » Fatal error: Call to undefined function _views_prepare_handler() when trying to add Calendar templates

Updating title to make it easier to search for & find.

Also, the views issue KarenS mentioned in #7 is #1411478: Notice when saving a View created from a template
BUT, I am not sure that is directly related to this issue, as this one creates a WSOD before creating the view and that one deals with saving the new view.

jide’s picture

I encountered the same error while updating from alpha2 to latest dev. After disabling APC and restarting the server, the error went away.
EDIT: and after enabled APC again, still no error...

jide’s picture

Hum okay, must have done something too fast.
The error still shows up at every call to update.php one time, and after I refresh the page, everything is fine.

Would be interesting if you could reproduce : Try to update any module that has database updates, and run update.php.

arlinsandbulte’s picture

The error still shows up at every call to update.php one time, and after I refresh the page, everything is fine.

I had a similar experience when clearing the cache, see the #6 edit.

KarenS’s picture

The code that causes the problems is trying to find all the core date fields (like node posted date) so we can create templates for them as well as Field date fields. I have to use views functions to identify those, and those are the functions that are failing. I think if I just pull that out and only create templates for Date fields that will fix this problem (because I can easily find those fields without using the Views API). That will leave us without templates for other fields, but I guess that is just the way it will have to work.

I don't have time to do this right now, I have to get on a plane and will be en route most of the day. So I'll have to get back to this later.

dhalbert’s picture

This was also complained about in a Views issue: #1413200: undefined function _views_prepare_handler(). A Views maintainer came up with a fix, so perhaps it's not really something that needs to be fixed in Calendar.

arlinsandbulte’s picture

Assigned: Unassigned » arlinsandbulte

I will test this with the updated views code and report back when I get the chance... time for bed now.

arlinsandbulte’s picture

Assigned: arlinsandbulte » Unassigned
Status: Active » Fixed

Looks like #1413200: undefined function _views_prepare_handler() fixed this issue. I no longer get an error with the latest Views code.

Thanks dhalbert!

Status: Fixed » Closed (fixed)

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

rajmataj’s picture

Version: 7.x-3.x-dev » 7.x-3.0-rc1

Have a basic site with no content yet. Have activated:

  • Views
  • Views UI
  • Date
  • Date API
  • Date Repeat Field
  • Date Views

...and all was working well. However, when I activated the Calendar 7.x-3.0-rc1 module, received this error on a white screen:

Fatal error: Call to undefined function _views_prepare_handler() in /var/www/clients/client1/web37/web/sites/all/modules/contrib/views/views.module on line 1146

Only way to get around was to press the back button and disable the Calendar 7.x-3.0-rc1 module in the modules list. Any help would be appreciated. Thanks.

jide’s picture

Version: 7.x-3.0-rc1 » 7.x-3.x-dev

@rajmataj: The issue is fixed in 7.x-3.x-dev. See #1413200: undefined function _views_prepare_handler().

loopy1492’s picture

Replacing my views.module with the one from the dev release seems to have fixed this problem. It also seems to have fixed a 500 error I was getting when refreshing my cache.

I'll keep an eye on it and let you know what happens.

loopy1492’s picture

This resolution is looking very promising. All errors have stopped. I'll let it sit and run until next week before I make a final verdict.

webengr’s picture

confirm,
...Call to undefined function _views_prepare_handler()....
I also saw this error on feb 17, 2010 when trying to update.php to rc1, and googled to this page.

I changed views module from 7.x-3.1 2012-Jan-16 to the dev, 7.x-3.x-dev 2012-Feb17
and then when I ran update with the Feb 14 date and calendar module updates I did not get that error.

reckon the update was based upon dev views not stable.

PESTO3567’s picture

I just had the same problem here. The fix is easy, you have to reset the calander view and do your customization again, thats it.

UPDATE: Well, I can clear the cache sometimes ...and sometimes not. There's still something serious wrong and broken!

arlinsandbulte’s picture

#30:
Did you try the latest -dev version of Views?
This *IS* fixed in views, that is what I confirmed in #23 above.

deryck.henson’s picture

Title: Fatal error: Call to undefined function _views_prepare_handler() when trying to add Calendar templates » Fatal error: Call to undefined function _views_prepare_handler() after installing Calendar module
Status: Closed (fixed) » Needs work

Maybe I'm doing something horribly wrong, but after upgrading to calendar 3.x-dev AND views 3.x-dev, WSOD is all I get no matter what page it is (dev versions as of today).

Fatal error: Call to undefined function date_views_base_tables() in /var/www/df2/sites/all/modules/calendar/includes/calendar.views.inc on line 18

And I'm not sure how any of you even got to the template page. This occurs right after I hit "enable". Even update.php gets WSOD treatment, like #18 and #19 experienced.

Drupal 7.12
Views 3.x-dev
Calendar 3.x-dev

arlinsandbulte’s picture

Status: Needs work » Closed (fixed)

#32 is a different error not related to this issue.
It is, however, a duplicate of this one: #1441244: Fatal error: Call to undefined function date_views_base_tables, which states you need the latest -dev of the DATE module too.

deryck.henson’s picture

Good looks, that fixed it. Thanks.

nickgrace’s picture

Many thanks. Updating to the latest dev versions of Views and Date resolved the error for me.

michaelrajchandra’s picture

You said you fixed it but how is it possible to update when all you can see is Fatal error: Call to undefined function date_views_base_tables() in /home/user/public_html/sites/all/modules/calendar/includes/calendar.views.inc on line 18
No page is visible

Please help asap I am stuck

arlinsandbulte’s picture

@ZaDeveloper:
Are you trying to use the drupal web interface to update? If so, yes, you might be unable to do so if something is causing a fatal error on your website.

So, instead of using the web interface to update, you must use ftp.
Or if you are a more advanced administrator, you can use the command line, ssh, and/or drush. But ftp is the easiest to start with.

Follow the instructions here: http://drupal.org/node/672472
You will not be able to log onto your drupal site and put it into maintenance mode, but that's ok.

michaelrajchandra’s picture

@ arlinsandbulte

Thanks for your prompt reply...

Yes I was trying to use the drupal web interface to update and it failed with the Fatal Error.
"Fatal error: Call to undefined function date_views_base_tables() in E:\UCDC Site\sites\all\modules\calendar\includes\calendar.views.inc on line 18"

On your suggestion I used ftp and uploaded the latest Dev version of Date module and overwrote the existing files and folders and it worked like magic...

Thanks again for taking the time out to help...

batigolix’s picture

confirming that updating to the latest version fixes the problem:

  • views-7.x-3.3
  • date-7.x-2.2
  • calendar-7.x-3.0