• Resolved GideonLupine

    (@gideonlupine)


    My error logs is being filled with these “Attempt to read property” PHP Warnings every 5 or 10 seconds.

    Below is just for the time of 20:10:20.

    I have no idea where it is coming from or why. It is making it hard to manage the server because the logs are filled with noise.

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state_province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "state" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "province" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 27

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "address" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 28

    [09-Aug-2024 20:10:20 UTC] PHP Warning: ?Attempt to read property "post_title" on int in /var/www/html/website/wp-content/plugins/the-events-calendar/src/views/v2/list/event/venue.php on line 32
Viewing 15 replies - 1 through 15 (of 31 total)
  • Plugin Support Chika Ibeneme

    (@chikaibeneme)

    Hi @gideonlupine

    Thanks for reaching out.

    Based on the error message, the plugin is trying to access some venue data from your events, however, the expected data values are not present. The warnings are indicating attempts to read properties such as?state_province,?state,?province,?address, and?post_title?on an integer. This suggests that the code is expecting an object (probably a venue object) but is receiving an integer instead.

    What I’d advise you to do first is to go thorugh your events and ensure that you have the correct venue data present and then if it looks good, I’d advise that you do a conflict test via this guide here:
    https://theeventscalendar.com/knowledgebase/testing-for-conflicts To try and narrow down the issue further.

    Thread Starter GideonLupine

    (@gideonlupine)

    How would I go through my events to ensure I have the correct venue data? I am not sure where to look.

    I have phpMyAdmin installed. Should I look through a table for something?

    Plugin Support tristan083

    (@tristan083)

    Hi @gideonlupine ,

    Thank you for your message.

    I would like to note here that these warnings are not a cause for concern, as these does not stop program execution.

    But, as my colleague, Chika, has mentioned, the warnings are due to missing data, especially the venue and/or venue fields.

    I recommend checking if you have events that are not associated with a venue, as that would cause the Attempt to read property "post_title" warning. I would also recommend checking each of your venues (in Events -> Venues), and see if your all your venues are populated with an address, state, and province, as these would trigger the warnings below.

    • Attempt to read property "address"
    • Attempt to read property "state"
    • Attempt to read property "province"
    Thread Starter GideonLupine

    (@gideonlupine)

    We have a team of programmers pushing custom code to production server.

    My first rule is NO PHP WARNING ERRORS errors from our stuff ever. Zip. Nadda.

    Type mismatch, undefined, etc. is a red flag for something is sloppy and your error handling is off. That is programming 101 stuff. Get a cup of coffee fix it.

    The problem is your plugin is filling my log with a gig or more of errors every morning. It was not so bad before, but recently it is going crazy. I don’t know what changed or why.

    Can’t you add a error check before it tries to read whatever it is reading?

    Whatever is missing must not be important because no reports of problems on the front end. Like you said, it must continue on regardless.

    The problem is for the Admin.

    It makes my job like trying to solve a murder mystery in a slaughterhouse. Yeah, I got a body, but there was blood everywhere before the murder. There is a severed hand over there, but is that my murder or someone else’s?

    As an Admin, I got 5 or 10 murders running around at once all the time. This no help. Throw me a bone.

    Thread Starter GideonLupine

    (@gideonlupine)

    I am in phpMyAdmin.

    Where would I look for the venue having a weird value that would cause the issue?

    Most of our events don’t have a venue. They have been fine until now. Why would they cause issue?

    Thread Starter GideonLupine

    (@gideonlupine)

    I am now seeing the following. What does this mean?

    [12-Aug-2024 05:49:04 UTC] the-events-calendar/common -  Log: Initializing Tribe Events on Aug, 12th at 05:08:04 am
    [12-Aug-2024 05:49:05 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:05 am
    [12-Aug-2024 05:49:05 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:05 am
    [12-Aug-2024 05:49:06 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:06 am
    [12-Aug-2024 05:49:06 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:06 am
    [12-Aug-2024 05:49:08 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:08 am
    [12-Aug-2024 05:49:09 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:09 am
    [12-Aug-2024 05:49:11 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:11 am
    [12-Aug-2024 05:49:11 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:11 am
    [12-Aug-2024 05:49:12 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:12 am
    Thread Starter GideonLupine

    (@gideonlupine)

    I am trying to figure out what events or venues have the offending value.

    I am not aware of any changes. I don’t think it is old events, because they are old, and we had no issues in the past.

    New events, look normal. Most have no venue.

    Maybe an old venue that was fine, got messed up somehow? Maybe even deleted?

    I am the admin, and know zip about your Event Plugin. I have a vague idea.

    Can you give me a clue of where to look in phpMyAdmin? I can search for things much easier there, and “see” values better.

    Just need to know where to look.

    This thing is making a mess, and it started fairly recently.

    Plugin Support tristan083

    (@tristan083)

    Hi @gideonlupine ,

    Thank you for your messages.

    Venues are stored in the database as posts (wp_posts table) with tribe_venue as their post_type. The address, state, and province of a venue, on the other hand, are stored as metadata (wp_postmeta table) in the database.

    For the [12-Aug-2024 05:49:04 UTC] the-events-calendar/common - Log: Initializing Tribe Events on Aug, 12th at 05:08:04 am log, this would happen if Debug mode is enabled in the WordPress Admin Dashboard -> Events -> Settings -> General (tab) -> Debugging (section).

    Thread Starter GideonLupine

    (@gideonlupine)

    In wp_posts, I have 1,303 posts of type tribe_events.

    Meta values for them begin with _Event in wp_postmeta.

    For _EventVenueID, I only found 396.

    All _EventVenueID have values that appear to be numbers.

    For post_type tribe_venue, I found 293.

    Meta values for them begin with _Venue.

    The more I look at this, this seems silly. I am going to look at your venue.php file, and see if I can put some error checking in it.

    Thread Starter GideonLupine

    (@gideonlupine)

    In your venue.php, I see one issue right off.

    Line 22:

    if (! $event->venues->count()) {

    I am changing to:

    if (! isset($event->venues) || ! is_array($event->venues) || ! $event->venues) {

    I am also returning if:

    if (! is_object($venue)) {

    Thread Starter GideonLupine

    (@gideonlupine)

    I added this:

    // FIX: Set default strings if not found.
    $append_after_address = array_filter(array_map('trim', [
    isset($venue->state_province) ? $venue->state_province : '',
    isset($venue->state) ? $venue->state : '',
    isset($venue->province) ? $venue->province : ''
    ]));
    // FIX: END

    Thread Starter GideonLupine

    (@gideonlupine)

    I changed line 22 to this:

    // FIX: Checks for event venue data integrity

    if (! isset($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is not set for event ID: ' . (isset($event->ID) ? $event->ID : 'unknown'));

    ? return;

    }

    if (! is_array($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is not an array for event ID: ' . (isset($event->ID) ? $event->ID : 'unknown') . '. Type: ' . gettype($event->venues));

    ? return;

    }

    if (empty($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is empty for event ID: ' . (isset($event->ID) ? $event->ID : 'unknown'));

    ? return;

    }

    // FIX: END

    I am now getting in the log:

    [13-Aug-2024 06:20:32 UTC] Event Venue Error: $event->venues is not an array for event ID: 6305. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6363. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6357. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6347. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6343. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6333. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6331. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6325. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6323. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6314. Type: object

    [13-Aug-2024 06:20:35 UTC] Event Venue Error: $event->venues is not an array for event ID: 6305. Type: object
    Thread Starter GideonLupine

    (@gideonlupine)

    Its an object not an array, so I tried this:

    <?php

    /**

    ?* View: List Single Event Venue

    ?*

    ?* Override this template in your own theme by creating a file at:

    ?* [your-theme]/tribe/events/v2/list/event/venue.php

    ?*

    ?* See more documentation about our views templating system.

    ?*

    ?* @link https://evnt.is/1aiy

    ?*

    ?* @version 6.2.0

    ?* @since 6.2.0 Added the
    tec_events_view_venue_after_address action.

    ?*

    ?* @var WP_Post $event The event post object with properties added by the tribe_get_event function.

    ?* @var string ?$slug ?The slug of the view.

    ?*

    ?* @see tribe_get_event() For the format of the event object.

    ?*/

    // FIX: Check for $event->venues existence and type

    if (!isset($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is not set for event ID: ' . (isset($event->ID) ? $event->ID : 'unknown'));

    ? return;

    } elseif (!is_object($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is not an object for event ID: ' .

    ? ? (isset($event->ID) ? $event->ID : 'unknown') .

    ? ? '. Actual type: ' . gettype($event->venues) .

    ? ? '. Value: ' . var_export($event->venues, true));

    ? return;

    }

    // FIX: END

    if (! $event->venues->count()) {

    ? return;

    }

    $separator ? ? ? ? ? ?= esc_html_x(', ', 'Address separator', 'the-events-calendar');

    $venue ? ? ? ? ? ? ? ?= $event->venues[0];

    // FIX: Add check for $venue being an object

    if (! is_object($venue)) {

    ? error_log('Event Venue Error: Venue is not an object for event ID: ' .

    ? ? (isset($event->ID) ? $event->ID : 'unknown') .

    ? ? '. Actual type: ' . gettype($venue) .

    ? ? '. Value: ' . var_export($venue, true));

    ? return;

    }

    // FIX: END

    // FIX: Add default empty strings for potentially undefined properties

    $append_after_address = array_filter(array_map('trim', [

    ? $venue->state_province ?? '',

    ? $venue->state ?? '',

    ? $venue->province ?? ''

    ]));

    // FIX: END

    // FIX: Add default empty strings for potentially undefined properties

    $address = ($venue->address ?? '') . (($venue->address ?? '') && ($append_after_address || isset($venue->city)) ? $separator : '');

    // FIX: END

    ?>
    Thread Starter GideonLupine

    (@gideonlupine)

    My logs now have:

    [13-Aug-2024 07:03:24 UTC] Event Venue Error: Venue is not an object for event ID: 6569. Actual type: integer. Value: 5633

    Thread Starter GideonLupine

    (@gideonlupine)

    Added one more default empty string value:

    <?php

    /**

    ?* View: List Single Event Venue

    ?*

    ?* Override this template in your own theme by creating a file at:

    ?* [your-theme]/tribe/events/v2/list/event/venue.php

    ?*

    ?* See more documentation about our views templating system.

    ?*

    ?* @link https://evnt.is/1aiy

    ?*

    ?* @version 6.2.0

    ?* @since 6.2.0 Added the
    tec_events_view_venue_after_address action.

    ?*

    ?* @var WP_Post $event The event post object with properties added by the tribe_get_event function.

    ?* @var string ?$slug ?The slug of the view.

    ?*

    ?* @see tribe_get_event() For the format of the event object.

    ?*/

    // FIX: Check for $event->venues existence and type

    if (!isset($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is not set for event ID: ' . (isset($event->ID) ? $event->ID : 'unknown'));

    ? return;

    } elseif (!is_object($event->venues)) {

    ? error_log('Event Venue Error: $event->venues is not an object for event ID: ' .

    ? ? (isset($event->ID) ? $event->ID : 'unknown') .

    ? ? '. Actual type: ' . gettype($event->venues) .

    ? ? '. Value: ' . var_export($event->venues, true));

    ? return;

    }

    // FIX: END

    if (! $event->venues->count()) {

    ? return;

    }

    $separator ? ? ? ? ? ?= esc_html_x(', ', 'Address separator', 'the-events-calendar');

    $venue ? ? ? ? ? ? ? ?= $event->venues[0];

    // FIX: Add check for $venue being an object

    if (! is_object($venue)) {

    ? error_log('Event Venue Error: Venue is not an object for event ID: ' .

    ? ? (isset($event->ID) ? $event->ID : 'unknown') .

    ? ? '. Actual type: ' . gettype($venue) .

    ? ? '. Value: ' . var_export($venue, true));

    ? return;

    }

    // FIX: END

    // FIX: Add default empty strings

    $append_after_address = array_filter(array_map('trim', [

    ? $venue->state_province ?? '',

    ? $venue->state ?? '',

    ? $venue->province ?? ''

    ]));

    // FIX: END

    // FIX: Add default empty strings

    $address = ($venue->address ?? '') . (($venue->address ?? '') && ($append_after_address || isset($venue->city)) ? $separator : '');

    // FIX: END

    ?>

    <address class="tribe-events-calendar-list__event-venue tribe-common-b2">

    ? <span class="tribe-events-calendar-list__event-venue-title tribe-common-b2--bold">

    ? ? <?php

    ? ? //FIX: Add default empty strings

    ? ? echo wp_kses_post($venue->post_title ?? '');

    ? ? //FIX: END

    ? ? ?>

    ? </span>

    ? <span class="tribe-events-calendar-list__event-venue-address">

    ? ? <?php

    ? ? echo esc_html($address);

    ? ? if (! empty($venue->city)) :

    ? ? ? echo esc_html($venue->city);

    ? ? ? if ($append_after_address) :

    ? ? ? ? echo $separator;

    ? ? ? endif;

    ? ? endif;

    ? ? if ($append_after_address) :

    ? ? ? echo esc_html(reset($append_after_address));

    ? ? endif;

    ? ? if (! empty($venue->country)):

    ? ? ? echo $separator . esc_html($venue->country);

    ? ? endif;

    ? ? ?>

    ? </span>

    ? <?php

    ? /**

    ? ?* Fires after the full venue has been displayed.

    ? ?*

    ? ?* @since 6.2.0

    ? ?*

    ? ?* @param WP_Post $event Event post object.

    ? ?* @param string ?$slug ?Slug of the view.

    ? ?*/

    ? do_action('tec_events_view_venue_after_address', $event, $slug);

    ? ?>

    </address>
Viewing 15 replies - 1 through 15 (of 31 total)
  • You must be logged in to reply to this topic.