• Resolved Jeffinho2016

    (@jeffinho2016)


    3.4.1.. still same mess as 3.4, with pages completely breaking.

    AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught TypeError: str_starts_with(): Argument #1 ($haystack) must be of type string, float given in /wp-content/plugins/tablepress/classes/class-render.php:280
    Stack trace:
    #0 /wp-content/plugins/tablepress/classes/class-render.php(280): str_starts_with()
    #1 /wp-content/plugins/tablepress/classes/class-render.php(150): TablePress_Render->_process_render_data()
    #2 /wp-content/plugins/tablepress/controllers/controller-frontend.php(851): TablePress_Render->get_output()
    #3 /wp-includes/shortcodes.php(434): TablePress_Frontend_Controller->shortcode_table()
    #4 [internal function]: do_shortcode_tag()
    #5 /wp-includes/shortcodes.php(273): preg_replace_callback()
    #6 /public_html/wp-includes/class-wp-hook.php(353): do_shortcode()
    #7 /public_html/wp…’

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi @jeffinho2016,

    Thanks for your post and sorry for the trouble! Indeed, this seems to be another instance of a problem that is already solved in another place. I will add a workaround for this shortly!

    In the meantime, the actual solution is to fix the internal table data. For that please follow these steps: https://wordpress.org/support/topic/fatal-error-on-wordpress-search-after-updating-to-tablepress-3-4/#post-19033249

    Best wishes,
    Tobias

    Thread Starter Jeffinho2016

    (@jeffinho2016)

    Hi @tobiasbg

    actual table data is pretty much empty, since it gets populated via the “tablepress_table_render_data” filter.
    I can most likely just typecast the values to get them to string, but it would have been nice to have some clear breaking changes notices before we update and figure days down the line that some pages are completely broken.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi @jeffinho2016,

    Ah, I see. Yes, then the culprit is that you are not returning a data array of strings in that filter hook. To achieve that, it should be sufficient to add something like

    // Make sure that cells are stored as strings.
    array_walk_recursive(
    $data,
    static function ( &$cell_content, $col_idx ) {
    $cell_content = (string) $cell_content;
    }
    );

    to the end of your filter hook handler function (assuming that your table array is named $data here).

    Please note that this wasn’t directly intended to be a breaking change, which is why this wasn’t in e.g. the changelog. I just had missed that this can happen when turning on strict type checking, as TablePress only deals with table data arrays that are strings only. I’ll therefore restore the previous behavior (by doing the string typecast before rendering), but the ideal fix is to only provide proper data to begin with.

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.