• Resolved inigo

    (@inigo)


    First of all: GREAT plugin. Simple & effective.
    But a small & easy to fix php deprecated message appearing in debug.log problem.

    Could you please fix the
    trim(): Passing null to parameter #1 ($string) of type string is deprecated


    notice in

    wp-content/plugins/m-chart/components/class-m-chart-parse.php:61



    like so:

    THX
    Regards Inigo

    		if ( 'first_column' == $this->value_labels_position ) {
    			foreach ( (array) $this->data as $columns ) {
    				if ( '' != trim((string) $columns[0] ) ) {
    					$this->value_labels[] = $this->clean_labels( $columns[0] );
    				}
    			}
    		}
    		elseif ( 'first_row' == $this->value_labels_position ) {
    			foreach ( (array) $this->data[0] as $column ) {
    				if ( '' != trim((string) $column ) ) {
    					$this->value_labels[] = $this->clean_labels( $column );
    				}
    			}
    		}
    		elseif ( 'both' == $this->value_labels_position ) {
    			foreach ( (array) $this->data as $columns ) {
    				if ( '' != trim((string) $columns[0] ) ) {
    					$this->value_labels['first_column'][] = $this->clean_labels( $columns[0] );
    				}
    			}
    
    			foreach ( (array) $this->data[0] as $column ) {
    				if ( '' != trim((string) $column ) ) {
    					$this->value_labels['first_row'][] = $this->clean_labels( $column );
    				}
    			}
    		}

    O btw

    [16-May-2023 13:17:49 UTC] PHP 9. wp_filter_nohtml_kses($data = NULL) /Users/inigogrimbergen/Local Sites/webthema/app/public/wp-content/plugins/m-chart/components/class-m-chart.php:483

    [16-May-2023 13:17:49 UTC] PHP 10. stripslashes($string = NULL) /Users/inigogrimbergen/Local Sites/webthema/app/public/wp-includes/kses.php:2180

    [16-May-2023 13:17:49 UTC] PHP Deprecated: stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/inigogrimbergen/Local Sites/webthema/app/public/wp-includes/kses.php on line 218

    can simply be fixed by:

    $value        = $value ?? '';
    foreach ( $data as $key => $value ) {
       if ( is_array( $value ) ) {
    	$data[ $key ] = $this->validate_data( $value );
       } else {
    	$value        = $value ?? '';
    	$data[ $key ] = wp_filter_nohtml_kses( $value );
       }
    }
    • This topic was modified 1 year, 5 months ago by inigo.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Simple to fix php notice’ is closed to new replies.