Bug Incorrect integer value: '' for column 'dbtech_shop_item_count'

Status
Not open for further replies.
PHP 7.4.11
Fresh installed XF 2.2.1 and DragonByte Shop 6.4.1.

I've got message on dashboard, that I should finish the task. But I can't, because this error:
Code:
XF\Db\Exception: MySQL query error [1366]: Incorrect integer value: '' for column 'dbtech_shop_item_count' at row 1 in src/XF/Db/AbstractStatement.php at line 228

    XF\Db\AbstractStatement->getException() in src/XF/Db/Mysqli/Statement.php at line 196
    XF\Db\Mysqli\Statement->getException() in src/XF/Db/Mysqli/Statement.php at line 77
    XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.php at line 94
    XF\Db\AbstractAdapter->query() in src/XF/Db/AbstractAdapter.php at line 322
    XF\Db\AbstractAdapter->update() in src/addons/DBTech/Shop/XF/Service/User/ContentChange.php at line 31
    DBTech\Shop\XF\Service\User\ContentChange->stepRebuildFinalCaches() in src/XF/MultiPartRunnerTrait.php at line 48
    XF\Service\User\ContentChange->runLoop() in src/XF/Service/User/ContentChange.php at line 203
    XF\Service\User\ContentChange->apply() in src/XF/Service/User/Merge.php at line 257
    XF\Service\User\Merge->stepReassignContent() in src/XF/MultiPartRunnerTrait.php at line 48
    XF\Service\User\Merge->runLoop() in src/XF/Service/User/Merge.php at line 90
    XF\Service\User\Merge->merge() in src/XF/Job/UserMerge.php at line 39
    XF\Job\UserMerge->run() in src/XF/Job/Manager.php at line 258
    XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 200
    XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 84
    XF\Job\Manager->runQueue() in src/XF/Admin/Controller/Tools.php at line 139
    XF\Admin\Controller\Tools->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 350
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 257
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2300
    XF\App->run() in src/XF.php at line 465
    XF::runApp() in admin.php at line 13

Solution


File \src\addons\DBTech\Shop\XF\Service\User\ContentChange.php

Add (int) for $count in two places.

Line 24:
Code:
$this->app->db()->update('xf_user', ['dbtech_shop_purchases' => (int)$count], 'user_id = ?', $this->newUserId);
And line 31:
Code:
$this->app->db()->update('xf_user', ['dbtech_shop_item_count' => (int)$count], 'user_id = ?', $this->newUserId);
 
Hey, thanks for reporting this :)

The more appropriate fix is in Repository/Item:
PHP:
    /**
     * @param int $userId
     *
     * @return int
     */
    public function getUserItemCount(int $userId): int
    {
        return (int)$this->db()->fetchOne("
            SELECT COUNT(item_id)
            FROM xf_dbtech_shop_item
            WHERE user_id = ?
                AND item_state = 'visible'
        ", $userId);
    }
This will be in the next version :)
 
Hello @DimitryMarvel,

We hope your ticket regarding DragonByte Shop has been addressed to your satisfaction. This ticket has now been scheduled to be closed.

If your ticket has not been resolved, you can reply to this thread at any point in the next 7 days in order to reopen the ticket, afterwards this thread will be closed.

Please do not reply to this thread if your ticket has been resolved.

Thank you.


- DragonByte Technologies, Ltd.
 
Status
Not open for further replies.

DragonByte Shop

XenForo 1.5.3+ XenForo 2.0.x XenForo 2.1.x XenForo 2.2.x XenForo 2.3.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
3,624
Customer rating
5.00 star(s) 3 ratings
Back
Top