Skip to content

[sqlite] file upload error on SQLite: NOT NULL constraint failed #17

@another-brick-in-the-wall

Description

Environment

  • CMS Version: Evolution CMS 3.5.x
  • Database: SQLite
  • OS/Server Environment: Windows / OSPanel

Description

An integrity constraint violation occurs when attempting to upload an image within the manager panel on an Evolution CMS installation powered by SQLite.

The application triggers an Eloquent insertion into the dxjm_s_galleries table, but the executed INSERT query only contains timestamp fields (updated_at, created_at). Because the parent column is defined as NOT NULL and lacks a database-level default value, SQLite strictly rejects the query and throws an exception.

Steps to Reproduce

  1. Set up an Evolution CMS 3.5.x environment using an SQLite database.
  2. Navigate to the Manager panel and open any resource.
  3. Attempt to upload an image using the built-in file/gallery uploader interface.

Actual Result

The upload fails immediately with a 500 Parse Error response:

SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: dxjm_s_galleries.parent (Connection: default, Database: D:\OSPanel\domains\test1.loc\core\database\evo.sqlite, SQL: insert into "dxjm_s_galleries" ("updated_at", "created_at") values (2026-05-21 08:12:44, 2026-05-21 08:12:44))

Screenshot

Image

Expected Result

The image should upload successfully, and a corresponding row should be created in the database containing the appropriate relation IDs (such as parent or block) parsed from the request parameters.

Context Details

  • Request URI: /manager/sgallery/upload-file?cat=1&itemType=resource&block=1
  • Triggering Code: core/vendor/seiger/sgallery/src/Controllers/sGalleryController.php on line 135

Suggested Fix

The controller logic at line 135 utilizes a firstOrCreate() or create() method that fails to explicitly pass the required attributes into the instantiation array. To ensure full compatibility with SQLite's strict null constraints, either the missing required parameters (like parent) must be explicitly passed during the Eloquent creation phase, or the database migration schema should be adjusted to include a default value (e.g., ->default(0)) for the parent column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions