Support » Plugin: Polylang » Fatal Error: Cannot use object of type Closure as array

  • Hello,

    I have been facing a fatal error in the last 3 updates of Polylang (since version 2.1.2). I know how to fix it, but I have to do the fix every time I update the plugin.

    The error message is : “Fatal error: Cannot use object of type Closure as array in Path/wp-content/plugins/polylang/frontend/frontend-filters.php on line 231″

    In the same file mentioned in the error message above, I changed this
    if ( ! isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! is_object( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! method_exists( $wp_registered_widgets[ $widget ]['callback'][0], 'get_settings' ) ) {

    to this:

    if (!is_array($wp_registered_widgets['callback']) || !isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! is_object( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! method_exists( $wp_registered_widgets[ $widget ]['callback'][0], 'get_settings' ) ) {

    Could you please include this fix in the future releases so that I don’t have to repeat it every time a new version is released.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chouby

    (@chouby)

    Hi,

    I am not sure that this is the right way to solve the issue. Could you identify which plugin (or theme) is conflicting?

    I am using custom theme on top of Gantry Framework. Well, you may be right. The issue would be related to the Framework I am using.

    I am not a developer. I found the fix on the Gantry Developer Website then applied it to the error file.

    Plugin Author Chouby

    (@chouby)

    I reproduced with Gantry 5.

    This plugin is doing a strange hack replacing the existing Widget display callback method by a closure. Probably no plugin developer can expect that and according to the second link, it looks like, at some point, it broke their own plugin too.

    I will fix that in the next version.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fatal Error: Cannot use object of type Closure as array’ is closed to new replies.