• Resolved tmpete

    (@tmpete)


    The latest update can’t be activated due to triggering a fatal error. If the plugin is already installed and it auto-updates it will bring the entire site down.

    PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-content/plugins/enable-cors/src/Helpers/Cors.php:125\nStack trace:\n#0 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-content/plugins/enable-cors/src/Helpers/Cors.php(125): implode(',', 'GET,POST,OPTION...')\n#1 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-content/plugins/enable-cors/src/Plugin.php(111): Enable\\Cors\\Helpers\\Cors-]headers()\n#2 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-content/plugins/enable-cors/enable-cors.php(67): Enable\\Cors\\Plugin::init()\n#3 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-settings.php(462): include_once('/is/htdocs/wp10...')\n#4 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-config.php(97): require_once('/is/htdocs/wp10...')\n#5 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-load.php(50): require_once('/is/htdocs/wp10...')\n#6 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-blog-header.php(13): require_once('/is/htdocs/wp10...')\n#7 /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/index.php(17): require('/is/htdocs/wp10...')\n#8 {main}\n thrown in /is/htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-content/plugins/enable-cors/src/Helpers/Cors.php on line 125

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Dev Kabir

    (@devkabir)

    Hi @tmpete,

    Thank you for providing the error message. It appears that the issue is caused by a type error. The error message indicates that the?implode()?function is being called with a string as its second argument, while it expects an array.

    I have updated plugin with 1.1.8 version.

    However, if you have access to the following file: /htdocs/wp1033564_9MD5WDX7NZ/www/staging/wp-content/plugins/enable-cors/src/Helpers/Cors.php, you can resolve this issue by making the following changes to lines 124-129 in the code:

    if ( array_key_exists( 'allowedMethods', $options ) ) {
    				header( 'Access-Control-Allow-Methods: ' . is_array( $options['allowedMethods'] ) === 1 ? implode( ',', $options['allowedMethods'] ) : $options['allowedMethods'] );
    			}
    			if ( array_key_exists( 'allowedHeader', $options ) ) {
    				header( 'Access-Control-Allow-Headers: ' . is_array( $options['allowedHeader'] ) === 1 ? implode( ', ', $options['allowedHeader'] ) : $options['allowedHeader'] );
    			}
    Plugin Author Dev Kabir

    (@devkabir)

    if ( array_key_exists( 'allowedMethods', $options ) && gettype( $options['allowedMethods'] ) === 'array' ) {
    				header( 'Access-Control-Allow-Methods: ' . implode( ',', $options['allowedMethods'] ) );
    			}
    			if ( array_key_exists( 'allowedHeader', $options ) && gettype( $options['allowedHeader'] ) === 'array' ) {
    				header( 'Access-Control-Allow-Headers: ' . implode( ', ', $options['allowedHeader'] ) );
    			}
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin update triggers fatal error’ is closed to new replies.