• Note: this bug does not impact site function in any way. It just throws off error messages to logs in some circumstances… but error messages can be annoying, so it’s nice to avoid them.

    Site running PHP 7.1

    ERROR:

    PHP Warning: Division by zero in /.../wp-content/plugins/the-events-calendar/src/views/embed/image.php on line 42

    Trigger for Error:

    GET request to URL in this format:

    /event/event_title/embed/

    Line of /embed/image.php causing error:

    if ( $data['width'] / $data['height'] > $aspect_ratio ) {

    Cause of error: If height value for the post featured image is not found, the script will throw off a divide by zero error.

    FIX, change line 42 to:

    if ( ($data['height'] > 0) && $data['width'] / $data['height'] > $aspect_ratio ) {

    This can easily be done with a template override, but it would be better if the line in the default template was coded to avoid potential error in the first place.

    For more info re this error in WordPress distribution files – https://core.trac.wordpress.org/ticket/40931

    (It looks like the events image.php simply incorporates the same error that was reported in the WordPress default embed-content.php template)

    • This topic was modified 8 years, 10 months ago by Abigailm.
    • This topic was modified 8 years, 10 months ago by Abigailm.

The topic ‘Minor bug in template (with fix)’ is closed to new replies.