• Resolved Neil

    (@neilgilmour)


    WCLDN 2018 Contributor

    Hi Tobias,

    I’m getting lots (hundreds) of these PHP Warnings after changing from PHP 7.0 to 7.2

    PHP message: PHP Warning: nl2br() expects parameter 1 to be string, array given in /www/my_server/public/wp-content/plugins/tablepress/classes/class-render.php on line 766

    PHP message: PHP Warning: substr() expects parameter 1 to be string, array given in /www/my_server/public/wp-content/plugins/tablepress/classes/class-render.php on line 562

    Is this anything to worry about?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    This is strange. From what I can see, this can only happen if the internal table data format is somehow broken (that is, if the individual cells are not strings but arrays).
    If possible, I’d like to take a direct look at this on your site. Could you therefore please create a temporary admin account for me and send me the details via email (the address is in the main plugin file “tablepress.php”)? That way, I can investigate this directly. Thanks!

    Regards,
    Tobias

    Thread Starter Neil

    (@neilgilmour)

    WCLDN 2018 Contributor

    You were absolutely right – we had cell data stored as arrays instead of strings. I should have realised that! For anyone else who finds this topic, we added this to convert the arrays:

    
    // Make sure col content is a string type.
    +		foreach ( $table['data'] as $row_id => $row ) {
    +			foreach ( $row as $col_id => $content ) {
    +				if ( is_array( $content ) ) {
    +					$content = implode( ', ', $content );
    +				}
    +				$content = (string) $content;
    +
    +				$table['data'][ $row_id ][ $col_id ] = $content;
    +			}
    +		}
    +
    

    Thanks Tobias for a great plugin. Donation on its way…

    • This reply was modified 6 years, 6 months ago by Neil. Reason: formatting
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    good to hear that this helped!

    Now I’m curious though: Why do you have an array in the cell content? Are you doing some special/custom data manipulation in the database, like direct SQL queries?

    Regards,
    Tobias

    Thread Starter Neil

    (@neilgilmour)

    WCLDN 2018 Contributor

    Hiya, it’s because we have a column which displays two bits of info in each cell – both CPT titles. These are related so we need to show both in the cell.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ok, so you are retrieving/storing them in the TablePress table data using a custom method?

    Regards,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Warning in PHP 7.2 with TablePress 1.9’ is closed to new replies.