Fatal error when uploading attachments
Fatal error when uploading attachments – Incorrect integer value: '' for column id_item
Description
When trying to upload an attachment in TeamPass, a PHP fatal error occurs.
The upload fails and the following error appears in the Apache logs:
PHP Fatal error: Uncaught MeekroDBException: Incorrect integer value: '' for column `teampass`.`teampass_files`.`id_item` at row 1
in /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php:934
Stack trace:
#4 /var/www/html/sources/upload.attachments.php(415): DB::__callStatic()
Steps to Reproduce
- Go to Items → Upload attachment.
- Select a file and upload it.
- The upload fails and a PHP fatal error is logged.
Expected Behavior
The file should upload successfully and be attached to the selected item.
Actual Behavior
A fatal error occurs because an empty string ('') is being inserted into the id_item column (which expects an integer).
Environment
- TeamPass version: 3.1.5.1
- PHP version: 8.3.13
- Database: MariaDB
@B3XAL I cannot reproduce. I tried to:
- upload a file from an existing item ✅
- upload a file while creating a new item ✅
- review the code and expected variable is always defined.
COuld describe each steps you are going through? Thanks
Please check your php settings - you have a Maximum file size upload setting which is reported on your main Teampass page. Couldn't reproduce too on my side, it is working fine.
I started with a functional teampass, performing a preliminary test to verify it.
I updated to version 3.1.5.1 with PHP 8.3. It failed.
I updated to PHP 8.4 and the same error persists.
I don't know what it could be.
Base
TeamPass: 3.1.3.1
Operating System: Ubuntu 24.04.1
PHP version: 8.3.13
Memory limit: 128M
Memory usage: 539.63 KB
Maximum execution time: 60
Maximum file upload size: 2M
File upload tested
- Destination: personal folder
- File size: 75KB
- Extension: .txt
Result: OK
Non-related issues: Session needs to be restarted each time a file is uploaded.
After update
TeamPass: 3.1.5.1
Operating System: Ubuntu 24.04.1
PHP version: 8.3.13
Memory limit: 512M
Memory usage: 534.80 KB
Maximum execution time: 300
Maximum file upload size: 200M
File upload tested
- Destination: personal folder
- File size: 75KB
- Extension: .txt
Result: An unknown error occurred. - Upload stopped., File: poc.txt
LOG
172.17.0.1 - - [14/Nov/2025:08:08:06 +0000] "POST /sources/main.queries.php HTTP/1.1" 200 41
[Fri Nov 14 08:08:06.937953 2025] [php:error] [pid 280] [client 172.17.0.1:36568] PHP Fatal error: Uncaught MeekroDBException: Incorrect integer value: '' for column `teampass`.`teampass_files`.`id_item` at row 1 in /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php:934\nStack trace:\n#0 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(890): MeekroDB->queryHelper()\n#1 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(549): MeekroDB->query()\n#2 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(554): MeekroDB->insertOrReplace()\n#3 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(116): MeekroDB->insert()\n#4 /var/www/html/sources/upload.attachments.php(415): DB::__callStatic()\n#5 {main}\n thrown in /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php on line 934, referer: http://127.0.0.1/index.php?page=items
172.17.0.1 - - [14/Nov/2025:08:08:06 +0000] "POST /sources/upload.attachments.php HTTP/1.1" 500 -
Updated to PHP 8.4
TeamPass: 3.1.5.1
Operating System: Ubuntu 24.04.1
PHP version: 8.4.14
Memory limit: 512M
Memory usage: 667.69 KB
Maximum execution time: 300
Maximum file upload size: 200M
Checks performed:
- /etc/php/8.4/apache2/php.ini
- /var/www/html/includes/.externals/tp.config.php
- Directory permissions
File upload tested
- Destination: personal folder
- File size: 75KB
- Extension: .txt
Result: An unknown error occurred. - Upload stopped., File: poc.txt
LOG
172.17.0.1 - - [14/Nov/2025:08:22:11 +0000] "POST /sources/main.queries.php HTTP/1.1" 200 41
[Fri Nov 14 08:22:11.604428 2025] [php:error] [pid 14] [client 172.17.0.1:33280] PHP Fatal error: Uncaught MeekroDBException: Incorrect integer value: '' for column `teampass`.`teampass_files`.`id_item` at row 1 in /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php:934\nStack trace:\n#0 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(890): MeekroDB->queryHelper()\n#1 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(549): MeekroDB->query()\n#2 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(554): MeekroDB->insertOrReplace()\n#3 /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php(116): MeekroDB->insert()\n#4 /var/www/html/sources/upload.attachments.php(415): DB::__callStatic()\n#5 {main}\n thrown in /var/www/html/vendor/sergeytsalkov/meekrodb/db.class.php on line 934, referer: http://127.0.0.1/index.php?page=items
172.17.0.1 - - [14/Nov/2025:08:22:11 +0000] "POST /sources/upload.attachments.php HTTP/1.1" 500 -
With php 8.4 you have to consider fpm settings. I worked on that and share some tricks on https://github.com/nilsteampassnet/TeamPass/issues/4878 adjusting those setting fixed an issue I had and also gave Teampass better performance. Maybe you should put an eye on that
Thanks for the advice.
I tried it, but I'm still getting the same error.
It also gives me the error in both php 8.3 and php 8.4. I don't think that's the problem.
Good morning, update:
I have tried the new release 3.1.5.13 and identified the point of failure.
When creating a new object, I get the previous error, as it apparently cannot find the ID of the object to assign the file to upload. So I decided to first create the item and then attach it, and to my surprise, it works.
There is then a period of time during which I can create objects with attachments until the error reappears, and I have to recreate it and then edit it again to attach it.
This behavior is a little strange.