givanz / Vvveb

Powerful and easy to use cms to build websites, blogs or ecommerce stores.
https://www.vvveb.com
GNU Affero General Public License v3.0
241 stars 49 forks source link

install fails. filterArray is empty? #42

Closed bAndie91 closed 9 months ago

bAndie91 commented 9 months ago

i'm installing vvveb with sqlite backend.

it brings me to the page where i enter the website name, then click "finish install".

seems like $filterArray is empty in $params['admin']= $this->db->filter($params['admin'], $filterArray,false);

also, where is the code in git?


Error

Unable to prepare statement: 1, near "WHERE": syntax error
UPDATE admin 

            SET            

        WHERE 

            username = 'admin'
 - UPDATE admin 

            SET            

        WHERE 

            username = :username
File

/srv/web/vvveb/hmvhp/system/db/sqlite.php209
Code

        try {

            //echo $origSql;

            //echo $sql;

            $stmt = self::$link->prepare($sql);

        } catch (\Exception $e) {

            $message = $e->getMessage() . "\n" . $this->debugSql($origSql, $params, $paramTypes) . "\n - " . $origSql;

            throw new \Exception($message, $e->getCode());   // <==

        }

        if ($stmt && ! empty($paramTypes)) {

            foreach ($parameters as $key => $value) {

                $type  = $types[$key] ?? 's';

                $type  = ($type == 'i') ? SQLITE3_INTEGER : SQLITE3_TEXT;
Trace

#0 /srv/web/vvveb/hmvhp/storage/model/install/adminsql.sqlite.php(521): Vvveb\System\Db\Sqlite->execute()
#1 /srv/web/vvveb/hmvhp/system/user/admin.php(59): Vvveb\Sql\AdminSQL->edit()
#2 /srv/web/vvveb/hmvhp/install/controller/index.php(225): Vvveb\System\User\Admin::update()
#3 [internal function]: Vvveb\Controller\Index->install()
#4 /srv/web/vvveb/hmvhp/system/core/frontcontroller.php(226): call_user_func()
#5 /srv/web/vvveb/hmvhp/system/core/frontcontroller.php(297): Vvveb\System\Core\FrontController::call()
#6 /srv/web/vvveb/hmvhp/system/core/frontcontroller.php(362): Vvveb\System\Core\FrontController::redirect()
#7 /srv/web/vvveb/hmvhp/system/core/startup.php(365): Vvveb\System\Core\FrontController::dispatch()
#8 /srv/web/vvveb/hmvhp/index.php(144): Vvveb\System\Core\start()
#9 /srv/web/vvveb/hmvhp/install/index.php(51): include('...')
#10 /srv/web/vvveb/hmvhp/public/install/index.php(26): include('...')
#11 {main}
givanz commented 9 months ago

Hi

Can you provide more info like sqlite and php version?

$filterArray should contain the table column names like this

$filterArray = [
    'admin_id' => [
        't' => 'INTEGER',
        'd' => NULL,
        'n' => true,
    ],
    'username' => [
        't' => 'TEXT',
        'd' => '',
        'n' => true,
    ],
    'role_id' => [
        't' => 'INT',
        'd' => 'NULL',
        'n' => true,
    ],
    'token' => [
        't' => 'TEXT',
        'd' => '',
        'n' => true,
    ],
];

$params['admin']= $this->db->filter($params['admin'], $filterArray,false);

I think there is a problem with system/db/sqlite->getColumnsMeta with your sqlite version.

getColumnsMeta runs this query to get column names

SELECT type as t, name, dflt_value as d, `notnull` as n FROM pragma_table_info('admin');

The code will be pushed to github after beta is over and bug fixes, refactoring and code cleanup is complete.

bAndie91 commented 9 months ago

it's PHP 8.2.10 (cli) (built: Sep 4 2023 08:11:43) (NTS) with php8.2-sqlite3 8.2.10-1+0~20230904.33+debian11~1.gbp2dc84c

i deleted storage/model/install/adminsql.sqlite.php and it got re-generated with $filterArray filled up.

bAndie91 commented 9 months ago

…but now it gives this on the admin panel:


Call to undefined method Vvveb\Sql\StatSQL::getOrdersCount()
/srv/web/vvveb/hmvhp/admin/controller/base.php on line 453
Code

$orderCount = $stats->getOrdersCount($this->global); // <==

        $menu             = array_insert_array_after('edit', $menu, $posts_menu);

        //products -- add to menu

        $products_menu = $this->customProducts();

        $menu          = array_insert_array_after('sales', $menu, $products_menu);

        $stats = new StatSQL();

        $orderCount = $stats->getOrdersCount($this->global);     // <==

        $orderStatsusNew = 1;//get from site config

        $newOrders = ($orderCount['orders'][$orderStatsusNew]['count'] ?? 0);

        if ($newOrders > 0) {

            $menu['sales']['badge'] =  $newOrders;

            $menu['sales']['badge-class'] =  'badge bg-primary-subtle text-body float-end';

Trace

#0 /srv/web/vvveb/hmvhp/system/core/frontcontroller.php(209): Vvveb\Controller\Base->init()
#1 /srv/web/vvveb/hmvhp/system/core/frontcontroller.php(297): Vvveb\System\Core\FrontController::call()
#2 /srv/web/vvveb/hmvhp/system/core/frontcontroller.php(362): Vvveb\System\Core\FrontController::redirect()
#3 /srv/web/vvveb/hmvhp/system/core/startup.php(365): Vvveb\System\Core\FrontController::dispatch()
#4 /srv/web/vvveb/hmvhp/index.php(144): Vvveb\System\Core\start()
#5 /srv/web/vvveb/hmvhp/admin/index.php(41): include('...')
#6 /srv/web/vvveb/hmvhp/public/admin/index.php(28): include('...')
#7 {main}
givanz commented 9 months ago

Thanks for feedback, I updated the generated model for sqlite install.

The code for getOrdersCount was not updated for sqlite, please redownload the zip and update vvveb/admin/sql/sqlite/stat.sql

bAndie91 commented 9 months ago

works. cool.