• Resolved Paul

    (@headwall)


    Hi

    We’ve been picking up lots of PHP warnings regarding “ect-class-vc.php” with versions 2.4.3 and 2.4.4 (line 26). Can you please add some protection when accessing $term->name and $term->slug, maybe like this?

    if( is_array( $term ) && !array_key_exists( 'name', $term ) ) {
    // ...
    } else {
    $ect_categories[$term->name] = $term->slug;
    }

    We’re having to patch this at our end for now to keep the error-log size manageable.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support vishali009

    (@vishali009)

    Hi @headwall,

    We have tested this at our end and did not get this issue. Could you please share the scenario of exactly what you are doing? This will help us to assist you better.

    Thanks & Regards

    Thread Starter Paul

    (@headwall)

    Hi

    This is a redacted version of what we were seeing in the logs this morning. The logs were full of it :

    [Mon Dec 02 06:14:31.223317 2024] [proxy_fcgi:error] [pid XXX:tid XXX] [remote XX.XX.XX.XX]
    AH01071: Got error '
    PHP message: PHP Warning: Attempt to read property "name" on array in /XXX/XXX/wp-content/plugins/template-events-calendar/admin/visual-composer/ect-class-vc.php on line 26;
    PHP message: PHP Warning: Attempt to read property "slug" on array in /XXX/XXX/wp-content/plugins/template-events-calendar/admin/visual-composer/ect-class-vc.php on line 26;
    PHP message: PHP Warning: Attempt to read property "name" on array in /XXX/XXX/wp-content/plugins/template-events-calendar/admin/visual-composer/ect-class-vc.php on line 26;
    PHP message: PHP Warning: Attempt to read property "slug" on array in /XXX/XXX/wp-content/plugins/template-events-calendar/admin/visual-composer/ect-class-vc.php on line 26
    ', referer: https://XXX.XXX.XXX/wp-admin/index.php

    I suspect it’s actually caused by another plugin that filtering the event taxonomy terms, but I don’t have time to chase that down.

    Does that help?

    Plugin Support vishali009

    (@vishali009)

    Hi @headwall,

    Please share the list of plugins so we can check it. Additionally, it would be helpful if you could provide a video recording of the issue you are experiencing. Also, could you clarify what you mean by “redacted version”?

    Thanks & Regards

    Thread Starter Paul

    (@headwall)

    Sorry for the delay – it’s been a busy couple of days.

    By “redacted”, I just mean I removed some IP addresses and filesystem paths from the log.

    When I investigate further with this patch in “ect-class-vc.php” (around line 26)…

    if( is_array( $term ) && !array_key_exists( 'name', $term ) ) {
    error_log( 'FAIL: ' . json_encode( $term ) ); // << Added diagnostic info
    } else {
    $ect_categories[$term->name] = $term->slug;
    }

    …I get this in the error logs…

    PHP message: FAIL: {"invalid_taxonomy":["Invalid taxonomy."]}; PHP message: FAIL: []

    So that’s two iterations of the foreach() loop where $term->name and $term->slug do not exist, which is causing an error in PHP8.3. One iteration returns some invalid taxonomy error, and the other iteration seems to have $term as an empty array? Weird.

    Can you please just add some protection in the loop to check that $term contains valid data before you access the name and slug?

    Thanks

    Paul

    Plugin Support vishali009

    (@vishali009)

    Hi @headwall,

    Sorry for the late reply.
    Please replace the code with the one provided below, and let us know if you still face the same issue.

    For more, you can refer to the screenshot.

    if (!empty($terms) && !is_wp_error($terms)) {
    foreach ($terms as $term) {
    if (is_object($term) && isset($term->name, $term->slug)) {
    $ect_categories[$term->name] = $term->slug;
    } else {
    error_log('Invalid term: ' . json_encode($term));
    }
    }
    }

    I hope this will help you.

    Thanks & Regards

    Plugin Support vishali009

    (@vishali009)

    Hi there,

    I just wanted to follow up and see if the solution we provided worked for you. Since we haven’t heard back, I’ll close this ticket for now.

    If you still need any help, feel free to open a new ticket—we’re always happy to assist you!

    Thanks for reaching out, and have a great day!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.