Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters - php

When I try to install any theme to wordpress this error shows up, what should I do?
Fatal error: Uncaught ArgumentCountError: array_merge() does not
accept unknown named parameters in
D:\xampp\htdocs\wordpress\wp-includes\widgets.php:1261 Stack trace: #0
D:\xampp\htdocs\wordpress\wp-includes\widgets.php(1261):
array_merge(wp_inactive_widgets: Array, sidebar-1: Array, sidebar-2:
Array, sidebar-3: Array) #1
D:\xampp\htdocs\wordpress\wp-includes\widgets.php(1216):
retrieve_widgets(true) #2
D:\xampp\htdocs\wordpress\wp-includes\class-wp-hook.php(289):
_wp_sidebars_changed('Twenty Twenty') #3 D:\xampp\htdocs\wordpress\wp-includes\class-wp-hook.php(311):
WP_Hook->apply_filters(NULL, Array) #4
D:\xampp\htdocs\wordpress\wp-includes\plugin.php(478):
WP_Hook->do_action(Array) #5
D:\xampp\htdocs\wordpress\wp-includes\theme.php(2974):
do_action('after_switch_th...', 'Twenty Twenty', Object(WP_Theme)) #6
D:\xampp\htdocs\wordpress\wp-includes\class-wp-hook.php(287):
check_theme_switched('') #7
D:\xampp\htdocs\wordpress\wp-includes\class-wp-hook.php(311):
WP_Hook->apply_filters(NULL, Array) #8
D:\xampp\htdocs\wordpress\wp-includes\plugin.php(478):
WP_Hook->do_action(Array) #9
D:\xampp\htdocs\wordpress\wp-settings.php(540): do_action('init') #10
D:\xampp\htdocs\wordpress\wp-config.php(90):
require_once('D:\xampp\htdocs...') #11
D:\xampp\htdocs\wordpress\wp-load.php(37):
require_once('D:\xampp\htdocs...') #12
D:\xampp\htdocs\wordpress\wp-blog-header.php(13):
require_once('D:\xampp\htdocs...') #13
D:\xampp\htdocs\wordpress\index.php(17):
require('D:\xampp\htdocs...') #14 {main} thrown in
D:\xampp\htdocs\wordpress\wp-includes\widgets.php on line 1261

This is a poorly asked question as you have provided no context around the error message presented. Given the error appears to be coming from within WordPress code, I am guessing you do not have direct control over the underlying function call that is triggering this error. My best guess is that you are running an old version of WordPress on a system with PHP 8.0+ deployed (see explanation below). Either upgrade WordPress or downgrade to PHP 7.4.
For anybody else that comes this way in search of an answer to why this error is thrown in their code, the error is related to a new feature of PHP 8.0 called 'Named Parameters'. In the case of array_merge, the error can be thrown if you invoke it in the following manner, using a string-keyed array:
call_user_func_array('array_merge', [
'key1'=>['abc', 'def'],
'key2'=>['ghi', 'jkl']
]);
-> Error
This is because call_user_func_array will interpret the top-level array keys as parameter names to be passed into the array_merge, and these keys will not match the function arguments.
The solution here is to use array_values to strip away the keys first:
call_user_func_array('array_merge', array_values([
'key1'=>['abc', 'def'],
'key2'=>['ghi', 'jkl']
]));
-> ['abc','def','ghi','jkl']

I tried composer update, composer self-update everything
but finally this one fixed my issue:
Change:
$choices = call_user_func_array( 'array_merge', $choices );
to:
$choices = call_user_func_array( 'array_merge', array_values($choices) );
This fixed it for me

The following worked for me when I ran into these issues on my Bluehost WordPress site:
Downgrade PHP from 8.0 to 7.4 using the MultiPHP Manager
Upgrade WordPress from 5.3 to 5.9 via wp-admin
Upgrade PHP from 7.4 to 8.1 using the MultiPHP Manager

Had same issue after upgrading to php 8.x
Fixed with:
sudo composer self-update

Recommendation: just install the latest version of the composer in Linux and define it globally and run it on the project directory and the issue is resolved.
Composer 1.10.1 ----> to ------> Composer version 2.3.4
Hint: if same then revoke the composer.lock and vendor folder and run it again.

Related

Error when run "setup:di:compile" in Magento ver. 2.4.5-p1, PHP 8.1

After upgrading to magento 2.4.5-p1 and to php 8.1
I get this error while I try to compile
I tried to delete the vendor folder and did composer update but same results.
any way to solve this issue?
public_html$ bin/magento setup:di:compile
Compilation was started.
Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 115.0 MiBsyntax error, unexpected token "readonly", expecting identifier#0 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->includeClass()
#1 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->extract()
#2 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->getList()
#3 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator->doOperation()
#4 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): Magento\Setup\Module\Di\App\Task\Manager->process()
#5 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Command/Command.php(255): Magento\Setup\Console\Command\DiCompileCommand->execute()
#6 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Application.php(1021): Symfony\Component\Console\Command\Command->run()
#7 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#8 /home/0.cloudwaysapps.com/bmd/public_html/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun()
#9 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun()
#10 /home/0.cloudwaysapps.com/bmd/public_html/bin/magento(23): Symfony\Component\Console\Application->run()
#11 {main}
Thanks alot
Kobi
I'm from Cloudways Magento Community
Need to reproduce the steps for resolving the issue:
Downgrade your PHP version and check if its works
It seems some of your extensions create conflict in it, so what you can do is launch another application with the latest version and deploy each of your extensions one by one. This will let you know what causes the conflicts.
Check file permissions: https://support.cloudways.com/en/articles/5126387-how-can-i-reset-file-and-folder-permissions
Check the class which has a readonly keyword because:
readonly is a reserved keyword in PHP 8.1. Any existing classes or other symbols that use the name readonly (case insensitive) will result in a syntax error in PHP 8.1.
It is not possible to port the readonly functionality to older PHP versions. However, the #readonly / #property-read annotations is understood by static analyzers such as Psalm.
Thanks
It seems like a syntax error in your code, please check the last code that you added before deployment.
go to the Magento root folder and open the var/log folder, here you can check the log files, and you will find the error records here.
after that run, all deployment commands with di: compile one by one.
Thanks.

WooCommerce php 8.1 + WordPress 5.7.2

I have an issue with using new PHP 8.1 on WordPress 5.7.2. Everything work just fine, until turn on WooCommerce 5.3.0. Then whole site fall down.
Here is error message what I'm getting:
Fatal error: Uncaught Error: Call to undefined function putenv() in
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php:37
Stack trace: #0
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(49):
WC_Regenerate_Images_Request->__construct() #1
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-includes/class-wp-hook.php(292):
WC_Regenerate_Images::init('') #2
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-includes/class-wp-hook.php(316):
WP_Hook->apply_filters(NULL, Array) #3
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-includes/plugin.php(484):
WP_Hook->do_action(Array) #4
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-settings.php(560):
do_action('init') #5
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-config.php(90):
require_once('/data/web/virtu...') #6
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-load.php(37):
require_once('/data/web/virtu...') #7
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-admin/admin.php(34):
require_once('/data/web/virtu...') #8
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-admin/plugins.php(10):
require_once('/data/web/virtu...') #9 {main} thrown in
/data/web/virtuals/2036/virtual/www/domains/e-biowa.cz/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php
on line 37
Please does anyone know, if there is any problem with compatibility? I didn't find any information about it.
This isn't a problem with 8.1 over 8.0.
PHP has a function blacklist.
Remove putenv from the blacklist. This worked for me when I received this error using PHP 8.0.
WordPress is not ready yet for PHP 8.1. If you install on 8.1 you can show dozens of errors about deprecated methods like ltrim() or count, even if install WordPress 5.8.2. You can fix most of the issues in this reference
but its not worth that. My advice is you wait for the compatible version of Wordpress.
Remove or change this lines from php ini or config file:
//either put colon or remove this whole line
;disable_functions = passthru,exec,putenv,system,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv

Class Wikibase\DataModel\Entity\ItemId not found WikiBase installation

I am currently trying to follow this tutorial: https://www.mediawiki.org/wiki/Wikibase/Installation
I have the latest version of both MediaWiki and WikiBase (1.35) I'm currently trying to run the maintenance scripts.
I have installed both Wikibase Repository and Wikibase Client.
When I try to run "php maintenance/update.php" it gives me this error:
Error from line 47 of /Applications/XAMPP/xamppfiles/htdocs/mywikiname/extensions/Wikibase/lib/WikibaseLib.entitytypes.php: Class "Wikibase\DataModel\Entity\ItemId" not found
#0 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/extensions/Wikibase/repo/includes/WikibaseRepo.php(695): require()
#1 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/extensions/Wikibase/repo/includes/WikibaseRepo.php(410): Wikibase\Repo\WikibaseRepo::getDefaultEntityTypes()
#2 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/extensions/Wikibase/repo/includes/WikibaseRepo.php(460): Wikibase\Repo\WikibaseRepo::newInstance()
#3 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/extensions/Wikibase/repo/includes/RepoHooks.php(115): Wikibase\Repo\WikibaseRepo::getDefaultInstance()
#4 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/includes/HookContainer/HookContainer.php(321): Wikibase\Repo\RepoHooks::onSetupAfterCache()
#5 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/includes/HookContainer/HookContainer.php(132): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#6 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/includes/HookContainer/HookRunner.php(3417): MediaWiki\HookContainer\HookContainer->run(string, array)
#7 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/includes/Setup.php(694): MediaWiki\HookContainer\HookRunner->onSetupAfterCache()
#8 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/includes/WebStart.php(89): require_once(string)
#9 /Applications/XAMPP/xamppfiles/htdocs/mywikiname/index.php(44): require(string)
#10 {main}
How can I fix this? I've tried updating Composer and reinstalling it numerous times. If anyone can help, that would be great! :)
I hit the same error, and in my case, it was because my compose.local.json, (copied from composer.local.json-sample,) was pointing to "extensions/example/composer.json" rather than "extensions/Wikibase/composer.json". Fixing this to Wikibase, deleting composer.lock, running composer install --no-dev again, and finally running update.php fixed the issue.

problem in verification code of google drive api

I am working on a application that uploads and shows file from google drive to a website and for that i am using google drive api in php and i have followed the quickstart.php when i enter the verification code it shows me some error
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:67
Stack trace:
#0 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(67): count()
#1 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(141): GuzzleHttp\Handler\CurlFactory->release()
#2 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError()
#3 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish()
#4 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke()
#5 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(51): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler{closure}()
#6 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\PrepareBodyMiddleware.php(72): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler{closure}()
#7 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Middleware.php(30): GuzzleHttp\PrepareBodyMiddleware->__invoke()
#8 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\RedirectMiddleware.php(68): GuzzleHttp\Middleware::GuzzleHttp{closure}()
#9 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Middleware.php(57): GuzzleHttp\RedirectMiddleware->__invoke()
#10 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\HandlerStack.php(67): GuzzleHttp\Middleware::GuzzleHttp{closure}()
#11 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Client.php(268): GuzzleHttp\HandlerStack->__invoke()
#12 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Client.php(96): GuzzleHttp\Client->transfer()
#13 D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Client.php(104): GuzzleHttp\Client->sendAsync()
#14 D:\xampp\htdocs\google-drive-api\vendor\google\auth\src\HttpHandler\Guzzle6HttpHandler.php(34): GuzzleHttp\Client->send()
#15 D:\xampp\htdocs\google-drive-api\vendor\google\auth\src\OAuth2.php(492): Google\Auth\HttpHandle#16 D:\xampp\htdocs\google-drive-api\vendor\google\apiclient\src\Google\Client.php(184): Google\Auth\OAuth2->fetchAuthToken()
#17 D:\xampp\htdocs\google-drive-api\google-drive.php(52): Google_Client->fetchAccessTokenWithAuthCode()
#18 D:\xampp\htdocs\google-drive-api\google-drive.php(70): getClient()
#19 {main}
thrown in D:\xampp\htdocs\google-drive-api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67
Must be a problem with the php version . I was on php8 and was facing the same issue but when once I change to php7.3 the error became warning. Since the major changes in php7.4 and greater that might be causing the error of count()
As of PHP 7.2, the count() function will throw a warning when a value passed into it is not countable. Later on, this was made to throw a fatal error in PHP 8.0
See https://www.php.net/manual/en/function.count.php
Changelog
Version
Description
PHP 7.2
count() will now yield a warning on invalid countable types passed to the value parameter.
Since PHP 8.0 is a relatively new (and major) release that just came out 4 months ago in November, there is a good chance that a very large portion of PHP libraries aren't up to date yet. (I'm still developing in PHP 7.4 because of this.)
Assuming you're using the google/apiclient package, you should be good to go now as it seems to have been updated to support PHP 8.0 on Jan 19th in v2.9.0 (almost a month after you asked this question).
Edit: This is all based on the assumption you're running PHP 8.0, as this is the only version of PHP that throws a fatal error when passing a non countable variable into count().

Internal server error after upgrading from php 5.2 to 7.2

After upgrading php from 5.2 to 7.2 , while checking out on woocomeerce getting internal server error, when i check the error log in woocommerce it gives the following.
CRITICAL Uncaught ArgumentCountError: Too few arguments to function iwc_display_payment_method_email_order(), 1 passed in /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-includes/class-wp-hook.php on line 288 and exactly 2 expected in /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-content/themes/lensa/functions.php:133
Stack trace:
#0 /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-includes/class-wp-hook.php(288): iwc_display_payment_method_email_order(Object(WC_Order))
#1 /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#2 /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-content/themes/lensa/woocommerce/emails/email-order-details.php(89): do_action('woocommerce_ema...', Object(WC_Order), true, false, Object(WC_Email_New_Order))
#4 /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-content/plugins/woocomm in /home/content/n3pnexwpnas04_data01/18/41356818/html/wp-content/themes/lensa/functions.php on line 133
You can't easily update your Wordpress in such a way. You have to update your Software and all of the dependencies and make them PHP 7.2 compatible. So before your switch to the newest version update your Wordpress and all Plugins.
Then you can switch your PHP-Version and try to fix all other problems. I think in your case with such a big step forward. You should install a new Wordpress and try to migrate all the plugins step by step and fix the problems.

Categories