COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Phoca Guestbook - creating guestbooks in Joomla! CMS
kleini78
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 01 Jun 2023, 15:02

COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by kleini78 »

Hi
When i publish/unpublish a entry in the guestbook, there's a error on my new updated Joomla site.
COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Call stack
# Function Location
1 () JROOT/components/com_phocaguestbook/controllers/phocaguestbook.php:549
2 PhocaguestbookControllerPhocaguestbook->changeState() JROOT/components/com_phocaguestbook/controllers/phocaguestbook.php:520
3 PhocaguestbookControllerPhocaguestbook->unpublish() JROOT/libraries/src/MVC/Controller/BaseController.php:678
4 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_phocaguestbook/phocaguestbook.php:20
5 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
6 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
7 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
8 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
9 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
10 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
11 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
12 require_once() JROOT/index.php:32


I've updated the site from Joomla 3.10.11 to 4.3.2 and after that i've installed phoca guestbook on Joomla 4.3.2.


Joomla 4.3.2
PHP: 8.0.28
MySQL 5.7.39-0ubuntu0.18.04.2
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by Jan »

Hi,

please try to open this file:
components/com_phocaguestbook/controllers/phocaguestbook.php on line 549

and change FROM:

Code: Select all

if (count( $entryid ) < 1) {
TO:

Code: Select all

if ((int)$entryid < 1) {
and save. Did this change help?

Jan
If you find Phoca extensions useful, please support the project
kleini78
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 01 Jun 2023, 15:02

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by kleini78 »

Thank you for your help. This error is now solved. Now i've got the next one:

CALL TO UNDEFINED METHOD JOOMLA\DATABASE\MYSQLI\MYSQLIDRIVER::QUERY()

all stack
# Function Location
1 () JROOT/components/com_phocaguestbook/models/guestbook.php:577
2 PhocaguestbookModelGuestbook->publish() JROOT/components/com_phocaguestbook/controllers/phocaguestbook.php:554
3 PhocaguestbookControllerPhocaguestbook->changeState() JROOT/components/com_phocaguestbook/controllers/phocaguestbook.php:520
4 PhocaguestbookControllerPhocaguestbook->unpublish() JROOT/libraries/src/MVC/Controller/BaseController.php:678
5 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_phocaguestbook/phocaguestbook.php:20
6 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
7 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
8 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
9 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
10 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
11 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
12 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
13 require_once() JROOT/index.php:32
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by Jan »

Hi, thank you for the info, can you try to edit the code on line 577 ( components/com_phocaguestbook/models/guestbook.php )
FROM:

Code: Select all

if (!$this->_db->query()) {
TO:

Code: Select all

if (!$this->_db->execute()) {
and let me know if this is OK?
If you find Phoca extensions useful, please support the project
kleini78
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 01 Jun 2023, 15:02

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by kleini78 »

Hi
Thanks for your help. Now it works great.

I've also changed the line 556 (components/com_phocaguestbook/models/guestbook.php )

Code: Select all

if(!$this->_db->execute()) {
and line 499 ( components/com_phocaguestbook/models/guestbook.php ) to

Code: Select all

if ((Int)$cid < 1) {
(for delete an entry)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by Jan »

Hi, thank you for the info, will be changed in next version.

Thank you, Jan
If you find Phoca extensions useful, please support the project
kleini78
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 01 Jun 2023, 15:02

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by kleini78 »

Sorry. I've seen, there is an error in my last post. Here is the full description:

components/com_phocaguestbook/controllers/phocaguestbook.php on line 499

Code: Select all

if (count( $cid ) < 1) {
To:

Code: Select all

if ((int)$cid < 1) {


components/com_phocaguestbook/controllers/phocaguestbook.php on line 549

Code: Select all

if (count( $entryid ) < 1) {
To:

Code: Select all

if ((int)$entryid < 1) {


components/com_phocaguestbook/models/guestbook.php on line 577

Code: Select all

if (!$this->_db->query()) {
To:

Code: Select all

if (!$this->_db->execute()) {


components/com_phocaguestbook/models/guestbook.php on line 577

Code: Select all

if (!$this->_db->query()) {
To:

Code: Select all

if(!$this->_db->execute()) {
christine
Phoca Hero
Phoca Hero
Posts: 2818
Joined: 28 Nov 2010, 17:20

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by christine »

Hi,

Thanks for the infos & correction. 8) We noticed this in another thread.

The wrong file was this:
... and line 499 ( components/com_phocaguestbook/models/guestbook.php ) to .....

instead of: components/com_phocaguestbook/controllers/phocaguestbook.php

Kind regards
Christine
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by Jan »

Hi, should be OK in version 4.0.3
https://www.phoca.cz/news/1245-phoca-gu ... 3-released

Jan
If you find Phoca extensions useful, please support the project
kleini78
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 01 Jun 2023, 15:02

Re: COUNT(): ARGUMENT #1 ($VALUE) MUST BE OF TYPE COUNTABLE|ARRAY, INT GIV

Post by kleini78 »

No. The same issue in 4.0.3. But on other line

Call to undefined method Joomla\Database\Mysqli\MysqliDriver::query()

Call stack
# Function Location
1 () JROOT/components/com_phocaguestbook/models/guestbook.php:605
2 PhocaguestbookModelGuestbook->checkReference() JROOT/components/com_phocaguestbook/models/guestbook.php:103
3 PhocaguestbookModelGuestbook->store() JROOT/components/com_phocaguestbook/controllers/phocaguestbook.php:451
4 PhocaguestbookControllerPhocaguestbook->submit() JROOT/libraries/src/MVC/Controller/BaseController.php:678
5 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_phocaguestbook/phocaguestbook.php:20
6 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
7 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
8 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
9 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
10 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
11 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
12 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
13 require_once() JROOT/index.php:32


To solve:
components/com_phocaguestbook/models/guestbook.php on line 605

From

Code: Select all

if (!$this->_db->query()) {
To:

Code: Select all

if (!$this->_db->execute()) {
Post Reply