• manujacquet

    (@manujacquet)


    My configuration WP:

    • – Version of WordPress : 6.4.3
    • – Version of PHP/MySQL : 8.1.16 / 5.7.23
    • –Version of event manager : Events Manager (6.4.6.4)

    My problem :

    In the file errorlog-php, I’ve got some recursive errors (one every about 5 minutes) :

    [27-Feb-2024 07:23:24 UTC] PHP Warning: Array to string conversion in /srv/data/web/vhosts/…/htdocs/wp-content/plugins/events-manager/classes/em-calendar.php on line 494

    I’ve seen in this support forum, some people have the same error.

Viewing 15 replies - 1 through 15 (of 15 total)
  • joneiseman

    (@joneiseman)

    To figure out what’s causing this error you need to temporarily modify wp-content/plugins/events-manager/classes/em-calendar.php

    Make a backup copy of em-calendar.php and then change line 494 from this:

    if( is_array($value) ) $value = implode(',', $value);

    To this:

    if ( is_array( $value ) ) {
      foreach ( $value as $el ) {
        if (is_array($el)) {
          error_log('$arg[' . $name . '] contains an array element. The value is:' . print_r( $value, true ) );
          break;
        }
      }
      $value = implode(',', $value);
    }

    Then post the new error output here.

    Thread Starter manujacquet

    (@manujacquet)

    Thanks for your response. I changed the line and here the new error output:

    [02-Mar-2024 16:12:08 UTC] $arg[panels_info] contains an array element. The value is:Array ( [class] => EM_Widget_Calendar [grid] => 4 [cell] => 1 [id] => 11 [widget_id] => 194e29ab-e739-4f87-aa57-43139a341c71 [style] => Array ( [background_image_attachment] => [background_display] => tile ) [cell_index] => 0 [widget_index] => 11 )

    [02-Mar-2024 16:12:08 UTC] PHP Warning: Array to string conversion in /srv/data/……../wp-content/plugins/events-manager/classes/em-calendar.php on line 501

    joneiseman

    (@joneiseman)

    The function EM_Calendar::output is getting called with a $args array and it has an entry $args[‘style’] which is equal to array([background_image_attachment => “”, background_display=> “tile”)

    This doesn’t seem to be coming from the Events Manager plugin. Are you using Events Manager Pro? Looks like this error comes when displaying the Events Calendar Widget. Are then any url parameters when dispaying the page? Is there some way to specify the background style when adding widgets in your theme?

    You could try the following code snippet to fix this problem:

    add_filter('em_widget_calendar_get_args', function( $args ) {
        if ( is_array( $args ) && array_key_exists( 'style', $args ) {
            unset( $args['style'] );
        }
        return $args;
    });

    You can use the Code Snippets plugin to add this code snippet.

    Thread Starter manujacquet

    (@manujacquet)

    Hi,

    I searched for css code that I had added and actually, yes, I added that code to my stylesheet :

    .tribe-events-widget .tribe-events-widget-events-list__event-row--featured .tribe-events-widget-events-list__event-date-tag-datetime::after
    {
    background-color: #f0ab06 !important;
    }
    
    
    .tribe-events-widget .tribe-events-widget-events-list__view-more-link:visited
    {
    color: #685800 !important;
    }
    

    I deleted it but it didnt change anything.

    I tried to add your code with the widget code snippets but that’s no effect.

    And I don’t use the pro version.

    joneiseman

    (@joneiseman)

    Try modifying the code snippet to this:

    add_filter('em_calendar_get_args', function( $args ) {
        if ( is_array( $args ) && array_key_exists( 'style', $args ) {
            unset( $args['style'] );
        }
        return $args;
    });
    Thread Starter manujacquet

    (@manujacquet)

    I tried but not effect.

    Even I added the missing parenthesis after $args ) to fix the syntax error.

    joneiseman

    (@joneiseman)

    There was no syntax error in my code snippet:

    You must have made a mistake when copying and pasting the code snippet. Make sure you copy the code snippet from the code block in this thread (not from the email).

    Thread Starter manujacquet

    (@manujacquet)

    Snippet automatically deactivated due to an error on line 3:

    Syntax error, unexpected token “unset”.

    The correction in bold in that code :

    add_filter('em_calendar_get_args', function( $args ) {
        if ( is_array( $args ) && array_key_exists( 'style', $args ) ) {
            unset( $args['style'] );
        }
        return $args;
    });
    joneiseman

    (@joneiseman)

    The error must have occurred when you copied the code snippet. I copied and pasted my code snippet and I didn’t get any syntax error.

    Thread Starter manujacquet

    (@manujacquet)

    But in your condition, it miss an ” ) ” at the end :

    if ( is_array( $args ) && array_key_exists( 'style', $args )

    Thread Starter manujacquet

    (@manujacquet)

    Otherwise, I assure you that I copied your code correctly without any errors. The widget does show a syntax error, which I fixed by adding a parenthesis at the end of the ‘if’ condition line.

    joneiseman

    (@joneiseman)

    You’re correct, there was a missing paren in my code snippet. Hopefully, the plugin author will add a check to prevent the PHP Warning that you are reporting in a future release.

    • This reply was modified 9 months ago by joneiseman.
    Thread Starter manujacquet

    (@manujacquet)

    thank you for taking time. I will continue my research. If someone have an other idea ..

    joneiseman

    (@joneiseman)

    Make sure you activated the code snippet (in the Code Snippets plugin).

    Thread Starter manujacquet

    (@manujacquet)

    yes, it was ??

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘PHP error “Array to string conversion”’ is closed to new replies.