WordPress.org

Forums

amr ical events lists
[resolved] Warning: substr() expects parameter 3 to be long (3 posts)

  1. knaveenchand
    Member
    Posted 1 year ago #

    I use the amr-ical-events-list plugin along with event manager. The plugin was working normal until I recently discovered this error message on the calendar page on my site:

    Warning: substr() expects parameter 3 to be long, string given in /home/thecoach/public_html/wp-content/plugins/amr-ical-events-list/includes/amr-ical-events-list-main.php on line 802

    This is the link to my site where the error is appearing: http://www.thecoachingroom.com.au/calender.html

    The code on Line 801, 802, 803 is this:

    $excerpt = substr( $desc,0, // start
    				apply_filters('excerpt_length', 55))
    				.'...'; //length

    How do I remove the error message from displaying on my site. Any help will be highly appreciated.

    thanks,
    naveen

    https://wordpress.org/plugins/amr-ical-events-list/

  2. anmari
    Member
    Plugin Author

    Posted 1 year ago #

    HI it seems you have something that is adding a filter for the excerpt length and whatever it is returning is not a number.

    so when the code does

    substr ($desc, 0 , $length)

    where $length = apply_filters('excerpt_length', 55);

    the "$length" is not a number, so substr gives warning.

    IN next version of my code it will detect this and ignore the filter.

    For you, either usual method: deactivate other plugins/theme till message goes away so you know what is causing it.

    or change code to this (will be in next update):

    $length = apply_filters('excerpt_length', 55);
    // in case a filter returns garbage;
    if (!is_int($length))  $length = 55;
    $excerpt = substr(
    	$desc,
    	0, // start
    	$length) //length
    	.'...';

    for info:
    https://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length

  3. knaveenchand
    Member
    Posted 1 year ago #

    @anmari

    Thanks for the response. For now, I have custom generated the event list using event manager plugin itself. Nevertheless, I have used the code you supplied on my demo site and its working well. The error message disappeared after replacing the code.

    Thanks,
    Naveen

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic