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
239 stars 49 forks source link

Creating a new Option group fails #104

Open Twilight-Computer opened 3 months ago

Twilight-Computer commented 3 months ago

Creating a new Option group from web front end fails. Same data created in MySQL backend works.

error output: Internal server error! (error 500)

Field 'sort_order' doesn't have a default value INSERT INTO option

        (       `type`  )

    VALUES ( :option_data )

INSERT INTO option

        (       `type`  )

    VALUES ( 'radio' )

Array ( [0] => s [1] => radio ) s /var/www/html/twilight/system/db/mysqli.php on line 337 Code

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

            } else {

                error_log(print_r($stmt, 1));

                error_log($this->debugSql($sql, $params, $paramTypes));

            }

        } catch (\mysqli_sql_exception $e) {

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

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

        }

    } else {

        error_log(print_r($stmt, 1));

        error_log($this->debugSql($origSql, $params, $paramTypes));

    }

Trace

0 /var/www/html/twilight/storage/model/admin/optionsql.mysqli.php(324): Vvveb\System\Db\Mysqli->execute()

1 /var/www/html/twilight/admin/controller/crud.php(59): Vvveb\Sql\OptionSQL->add()

2 /var/www/html/twilight/admin/controller/product/option.php(87): Vvveb\Controller\Crud->save()

3 [internal function]: Vvveb\Controller\Product\Option->save()

4 /var/www/html/twilight/system/core/frontcontroller.php(229): call_user_func()

5 /var/www/html/twilight/system/core/frontcontroller.php(298): Vvveb\System\Core\FrontController::call()

6 /var/www/html/twilight/system/core/frontcontroller.php(364): Vvveb\System\Core\FrontController::redirect()

7 /var/www/html/twilight/system/core/startup.php(366): Vvveb\System\Core\FrontController::dispatch()

8 /var/www/html/twilight/index.php(138): Vvveb\System\Core\start()

9 /var/www/html/twilight/admin/index.php(41): include('...')

10 /var/www/html/twilight/public/vadmin-live/index.php(26): include('...')

11 {main}

givanz commented 3 months ago

Thanks for the bug report, I added the missing sort order input on the page and also added default values for sort order columns.

https://github.com/givanz/Vvveb/commit/cfc64b03b79a3ac858cac8bfaa7daf82c8242c65