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().
Related
Kindly assist me to resolve this error after installing my WordPress on a live server and the local one gave me this error and warning i couldn't get the site on the local server. I'm using Laragon for the local server. Please assist. The error message I got is below.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_add_default_theme_supports' not found or invalid function name in C:\laragon\www\rsbenterprise\wp-includes\class-wp-hook.php on line 307
Fatal error: Uncaught Error: Call to undefined function wp_json_file_decode()
in C:\laragon\www\rsbenterprise\wp-includes\blocks.php:238
Stack trace:
#0 C:\laragon\www\rsbenterprise\wp-includes\blocks\archives.php(119): register_block_type_from_metadata('C:\\laragon\\www\\...', Array)
#1 C:\laragon\www\rsbenterprise\wp-includes\class-wp-hook.php(307): register_block_core_archives('')
#2 C:\laragon\www\rsbenterprise\wp-includes\class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#3 C:\laragon\www\rsbenterprise\wp-includes\plugin.php(470): WP_Hook->do_action(Array)
#4 C:\laragon\www\rsbenterprise\wp-settings.php(578): do_action('init')
#5 C:\laragon\www\rsbenterprise\wp-config.php(90): require_once('C:\\laragon\\www\\...')
#6 C:\laragon\www\rsbenterprise\wp-load.php(50): require_once('C:\\laragon\\www\\...')
#7 C:\laragon\www\rsbenterprise\wp-admin\admin.php(34): require_once('C:\\laragon\\www\\...')
#8 C:\laragon\www\rsbenterprise\wp-admin\index.php(10): require_once('C:\\laragon\\www\\...')
#9 {main} thrown in C:\laragon\www\rsbenterprise\wp-includes\blocks.php on line 238
There has been a critical error on this website. Please check your site admin email inbox for instructions.
The wp_json_file_decode() utility function first appeared in version 5.9 of WordPress.
Your error message points to an incomplete or somehow corrupted update from a previous WordPress version to 5.9.
A good approach to fixing this problem: go to a working version of your site, then use a migration plugin to capture the working site and migrate it to a new server.
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.
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
I am trying to upgrade laravel 5.3 from 5.2 but I keep seeing these two errors in my log file:
Symfony\Component\Debug\Exception\FatalErrorException: Uncaught Error: Call to undefined method Illuminate\Auth\Access\Gate::abilities() in /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
And this one:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Log\Writer::setHandlers() in Command line code:1
Full stack outputs:
[2020-08-13 08:26:58] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught Error: Call to undefined method Illuminate\Auth\Access\Gate::abilities() in /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
Stack trace:
#0 Command line code(1): Illuminate\Support\Facades\Facade::__callStatic('abilities', Array)
#1 {main}
thrown in /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
[2020-08-13 08:26:58] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Log\Writer::setHandlers() in Command line code:1
Stack trace:
#0 [internal function]: VscodeLaravelExtraIntellisenseProvider->boot()
#1 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Array, Array)
#2 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(769): Illuminate\Container\Container->call(Array)
#3 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(752): Illuminate\Foundation\Application->bootProvider(Object(VscodeLaravelExtraIntellisenseProvider))
#4 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(VscodeLaravelExtraIntellisenseProvider), 2)
#5 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(753): array_walk(Array, Object(Closure))
#6 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#7 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(113): Illuminate\Foundation\Console\Kernel->bootstrap()
#10 Command line code(1): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I have no idea where these are coming from and how to resolve them.
UPDATE: I see these errors every minute at 41 secs. Example 13:35:41
But according to my crontab in homestead, I don't have any crons scheduled
UPDATE 2: https://github.com/illuminate/auth/blob/5.5/Access/Gate.php the abilities method is present in 5.5. But I am still at 5.3. Weird but I don't know what is calling that code already. Maybe a third party package.
https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense
This VS Code extension was causing the 2 errors, and it was trying to compile something every minute and hence it was very confusing and felt like a cron job running in the background.
Try to find on official documentation for upgrade guide. They cover a lot of issues and maybe you find yours. It's a very specific issue and you are missing something in your code, but from a question, we can't know. https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0
Also try Rector for upgrade or any issue after upgrade https://github.com/rectorphp/rector
When I opened the project,I get back this error message :
Fatal error: Uncaught Error: Class 'String' not found in /dev/local/lib/Cake/Utility/Debugger.php:339 Stack trace: #0 /dev/local/lib/Cake/Utility/Debugger.php(741): Debugger::trace(Array) #1 /dev/local/lib/Cake/Error/ErrorHandler.php(219): Debugger->outputError(Array) #2 /dev/local/lib/Cake/Core/App.php(565): ErrorHandler::handleError(2, 'Declaration of ...', '/dev/local...', 25, Array) #3 /dev/local/lib/Cake/Core/App.php(565): include() #4 [internal function]: App::load('TradeLog') #5 [internal function]: spl_autoload_call('TradeLog') #6 /dev/local/lib/Cake/Utility/ClassRegistry.php(145): class_exists('TradeLog') #7 /dev/local/app/Controller/Component/UserComponent.php(61): ClassRegistry::init('TradeLog') #8 /dev/local/app/Controller/Component/PlatformAgentComponent.php(24): UserComponent->__construct(Object(ComponentCollection), Array) #9 /Us in /dev/local/lib/Cake/Utility/Debugger.php on line 339
The newly configured environment in mac os.
When I paste the project into a folder, this error occurs. What's the matter?
This is a compatibility issue between Cakephp 2.4 and PHP7 (because string became reserved word in PHP7, so Cakephp cannot use it as a class name). Using of newer version of Cakephp is suggested. Also downgrading your PHP to 5.6 could solve the problem.
You need to upgrade to CakePHP > 2.8 which is compatible with PHP7
https://github.com/cakephp/cakephp/releases/2.8.0