verbb / events

Craft CMS Plugin for events management and ticketing.
Other
22 stars 13 forks source link

PHP error when installing Craft with incomplete event type data #65

Closed brandonkelly closed 4 years ago

brandonkelly commented 4 years ago

Description

A PHP error occurred when attempting to install Craft with an existing project config with the following event type data:

events:
  eventTypes:
    ac9fd4a1-0283-49a4-9b88-48da86357101:
      eventFieldLayouts:
        39c4cb2a-fe71-4985-a50a-ea127450fc0b:
          tabs:
            -
              fields:
                0d295ac7-25d3-4831-95e5-258b65caeece:
                  required: false
                  sortOrder: 9
                1bb3a1d8-3493-4c09-8ce6-03998fb9b4f7:
                  required: true
                  sortOrder: 3
                2ec47bb4-9818-47bb-b43e-f90ba279860d:
                  required: true
                  sortOrder: 7
                31c82197-6788-49ab-a2e0-9e37fa549a60:
                  required: true
                  sortOrder: 4
                40fafe98-5cb1-4d78-833a-41574593979e:
                  required: true
                  sortOrder: 2
                41a3a33d-aca1-4738-9560-090bd1521619:
                  required: false
                  sortOrder: 6
                4358221a-38a0-4770-ba8e-bc72b00bcd3f:
                  required: true
                  sortOrder: 8
                4592d593-7648-4c5d-b690-2777f1bd6a11:
                  required: true
                  sortOrder: 1
                6d202f5e-7322-4d95-9b55-ad63f6a053be:
                  required: false
                  sortOrder: 14
                71f35e4f-2d79-4911-93df-485307dfc35d:
                  required: false
                  sortOrder: 13
                78f56154-2e19-4f09-93e2-368c9c966c46:
                  required: false
                  sortOrder: 12
                b18bf3db-5fd0-474c-9e03-0c29069b209c:
                  required: false
                  sortOrder: 11
                c279203f-f8a0-4ece-980c-8673ac0913c8:
                  required: true
                  sortOrder: 10
                d60694dd-060a-4f12-92a4-d7c9efccf6fe:
                  required: true
                  sortOrder: 5
              name: Event
              sortOrder: 1
            -
              fields:
                19c6f680-ef01-4174-a06b-a2d46c51a645:
                  required: false
                  sortOrder: 1
              name: SEO
              sortOrder: 2
      handle: general
      hasTickets: true
      hasTitleField: true
      name: General
      siteSettings:
        460a8e11-2b85-48ff-9075-e455cda11abc:
          hasUrls: true
          template: events/_event/
          uriFormat: 'event/{slug}'
      titleFormat: ''
      titleLabel: Title

verbb\events\services\EventTypes::handleChangedEventType() is expecting the data to contain icsTimezone, icsDescriptionFieldHandle, and icsLocationFieldHandle keys, which are not present in this case.

https://github.com/verbb/events/blob/dc155b56a3dd81e7b0acf9622ca3706953fbb87f/src/services/EventTypes.php#L286-L288

Presumably those properties were added at some point after this event type was created, and the event type was never re-saved afterward.

I was able to work around it by changing those lines to:

$eventTypeRecord->icsTimezone = $data['icsTimezone'] ?? null;
$eventTypeRecord->icsDescriptionFieldHandle = $data['icsDescriptionFieldHandle'] ?? null;
$eventTypeRecord->icsLocationFieldHandle = $data['icsLocationFieldHandle'] ?? null;

But not sure if null is in fact the right fallback value to use.

Additional info

engram-design commented 4 years ago

Fixed in 1.4.14, sorry about that, and thanks!