Problem/Motivation

Steps to reproduce:

  1. Create a date_recur field
  2. Install fullcalendar module
  3. Create a view that uses fullcalendar display and add the date_recur field created in 1

You will see error:

Call to undefined method Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem::getOccurrenceHandler() in Drupal\fullcalendar\Plugin\views\style\FullCalendar->prepareEvents()

Proposed resolution

Fullcalendar does not supports 2.x version of date_recur and is using 1.x API. The code needs to support 2.x. date_recur 1.x will only get maintenance fixes. 2.x will be maintained actively.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

subhojit777 created an issue. See original summary.

dpi’s picture

Title: Call to undefined method DateRecurItem::getOccurrenceHandler » Fullcalendar incompatible with Date Recur 2.x
Project: Recurring Dates Field » FullCalendar
Version: 8.x-2.x-dev » 8.x-1.x-dev

The error is showing because the API no longer exists for 2.x. Fullcalendar was built using DR 1.x API's.

I encourage FC to upgrade, as users of DR 1.x have an upgrade path to 2.x: https://www.drupal.org/docs/8/modules/recurring-dates-field/date-recur-1...

Functionality of old API's are easy to replicate, see API guide: https://www.drupal.org/docs/8/modules/recurring-dates-field/date-recur-f...

subhojit777’s picture

Status: Active » Needs review
FileSize
2.06 KB
subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

FileSize
1.83 KB
1.63 KB

The patch in #3 was causing issues with timezone. The dates were displayed in UTC. Fixed it now. The solution is also simpler.

MrPaulDriver’s picture

I am getting views errors after patching. Not sure if I'm doing anything wrong.

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Database\DatabaseExceptionWrapper</em>: Exception in Calendar[calendar]: SQLSTATE[42000]: Syntax error or access violation: 1064 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 &#039; &#039;%Y-%m-%d\T%H:%i:%s&#039;) BETWEEN DATE_FORMAT(&#039;2019-03-01T00:00:00&#039;, &#039;%Y-%m-%d\T%H:&#039; at line 2: SELECT COUNT(*) AS expression
FROM
(SELECT DISTINCT node_field_data.nid AS nid, 1 AS expression
FROM
{node_field_data} node_field_data
LEFT JOIN {date_recur__node__field_date_time} date_recur__node__field_date_time_node_field_data ON node_field_data.vid = date_recur__node__field_date_time_node_field_data.revision_id
WHERE (((DATE_FORMAT(.field_date_time_value, &#039;%Y-%m-%d\T%H:%i:%s&#039;) BETWEEN DATE_FORMAT(&#039;2019-03-01T00:00:00&#039;, &#039;%Y-%m-%d\T%H:%i:%s&#039;) AND DATE_FORMAT(&#039;2019-03-31T23:00:00&#039;, &#039;%Y-%m-%d\T%H:%i:%s&#039;))) OR (((DATE_FORMAT(.field_date_time_value, &#039;%Y-%m-%d\T%H:%i:%s&#039;) &lt;= DATE_FORMAT(&#039;2019-03-01T00:00:00&#039;, &#039;%Y-%m-%d\T%H:%i:%s&#039;) AND DATE_FORMAT(.field_date_time_end_value, &#039;%Y-%m-%d\T%H:%i:%s&#039;) &gt;= DATE_FORMAT(&#039;2019-03-01T00:00:00&#039;, &#039;%Y-%m-%d\T%H:%i:%s&#039;))))) AND ((node_field_data.status = :db_condition_placeholder_0) AND (node_field_data.type IN (:db_condition_placeholder_1)))) subquery; Array
(
    [:db_condition_placeholder_0] =&gt; 1
    [:db_condition_placeholder_1] =&gt; event
)
 in <em class="placeholder">Drupal\views\Plugin\views\query\Sql-&gt;execute()</em> (line <em class="placeholder">1543</em> of <em class="placeholder">core/modules/views/src/Plugin/views/query/Sql.php</em>). <pre class="backtrace">Drupal\views\ViewExecutable-&gt;execute(NULL) (Line: 1454)
Drupal\views\ViewExecutable-&gt;render() (Line: 183)
Drupal\views\Plugin\views\display\Page-&gt;execute() (Line: 1630)
Drupal\views\ViewExecutable-&gt;executeDisplay(&#039;page_3&#039;, Array) (Line: 77)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber-&gt;onViewRenderArray(Object, &#039;kernel.view&#039;, Object)
call_user_func(Array, Object, &#039;kernel.view&#039;, Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(&#039;kernel.view&#039;, Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>
SocialNicheGuru’s picture

Status: Needs review » Needs work

I get that error too @MrPaulDriver

elaman’s picture

Status: Needs work » Needs review
FileSize
1.5 KB

The last patch didn't work. Here is the fix, where instead of pushing occurrences into $event array, I push it into $events array.

Using latest dev FullCalendar and latest stable Date Recur 2.0.

elaman’s picture

This might be a better approach, given that view results, might override date occurrences if they have the same index/delta.

elaman’s picture

Fix compatibility with regular date fields for the previous patch.

DuaelFr’s picture

Hi @elaman,
Thanks a lot for your patches!
I think something went wrong with your last patch, though. It seems to be replacing the entire FullCalendar.php file without focusing on your real changes. Would you try to upload it again? It would also be really appreciated if you could add an interdiff to only show the things you changed since your previous patch.

grahl’s picture

FileSize
2.07 KB

10 has an additional one-line change:

499c499
<           $event = $this->prepareEvent($entity, $field, $index, $event_start, $event_end);
---
>           $event[] = $this->prepareEvent($entity, $field, $index, $event_start, $event_end);

Attaching what would be 10 without replacement. The cause for this issue is #3098523: Convert CRLF to LF.

Still working on actually getting that running on my end.

grahl’s picture

Attached is a slightly different approach which tries to simplify event aggregation in that function and adds a workaround for unlimited events (this should be taken from some source in the field but is hardcoded for now at 100). I've removed variables which were no longer needed after those changes.

This patch will likely not apply without #3098523: Convert CRLF to LF already applied.

Note that $date_range is not used and probably should be.