I was unable to reproduce this issue on piwigo.com, however it happens consistently on my local machine, so I went to debug the code and found the issue. It starts with pwg_image_infos() returning null values for width and height when the uploaded file is a video clip.
Second, single_insert() converts null values to empty strings. This causes the insert to fail because the database expects integer values or nulls.
I believe the following change in single_insert() is in order:
That way the path can be specified with or without the trailing slash. This also gives you the opportunity to log a message if the executable is not there. Currently exec() fails silently if the path is incorrect, and there is no way to determine what caused the failure (or even know that ffmpeg didn't run).
I was unable to reproduce this issue on piwigo.com, however it happens consistently on my local machine, so I went to debug the code and found the issue. It starts with pwg_image_infos() returning null values for width and height when the uploaded file is a video clip.
Second, single_insert() converts null values to empty strings. This causes the insert to fail because the database expects integer values or nulls.
I believe the following change in single_insert() is in order:
```
if ($value === '')
{
$query .= 'NULL';
}
```
replace with
```
if ($value === '' || is_null($value))
{
$query .= 'NULL';
}
```
That way null values will remain NULLs.
And finally, a couple of words about using ffmpeg. You are constructing the full path as
```
$ffmpeg = $conf['ffmpeg_dir'].'ffmpeg';
```
which will cause if the configuration parameter doesn't contain a trailing slash.
I would like to suggest a more flexible approach:
```
$exe = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')? 'ffmpeg.exe' : 'ffmpeg';
$ffmpeg = realpath(join('/', array($conf['ffmpeg_dir'], $exe)));
if (!$ffmpeg) {
return null;
}
```
That way the path can be specified with or without the trailing slash. This also gives you the opportunity to log a message if the executable is not there. Currently exec() fails silently if the path is incorrect, and there is no way to determine what caused the failure (or even know that ffmpeg didn't run).
<!-- github-comment-id:215848417 -->
@vvinogradsky can you elaborate a bit on your fix ? I have the same problem, but changing the test in single_insert() does not change anything. I don't really know how to debug and I don't want to clobber my db with invalid data when testing :)
@vvinogradsky can you elaborate a bit on your fix ? I have the same problem, but changing the test in `single_insert()` does not change anything. I don't really know how to debug and I don't want to clobber my db with invalid data when testing :)
<!-- github-comment-id:216460890 -->
I've updated to piwigo 2.8.1 and still have the same error. Even applying the little fix above (in include/dblayer/functions_mysql.inc.php) does not change anything.
I've updated to piwigo 2.8.1 and still have the same error. Even applying the little fix above (in include/dblayer/functions_mysql.inc.php) does not change anything.
<!-- github-comment-id:217088005 -->
Ok, I've found why the fix was not working: I must be using mysqli, not mysql, so the file to edit is include/dblayer/functions_mysql.inc.php.
Ok, I've found why the fix was not working: I must be using mysqli, not mysql, so the file to edit is include/dblayer/functions_mysql.inc.php.
<!-- github-comment-id:217230494 -->
Huge +1 for getting this fix into Piwigo, and video upload support into @vvinogradsky 's lightroom publisher plugin.
Huge +1 for getting this fix into Piwigo, and video upload support into @vvinogradsky 's lightroom publisher plugin.
<!-- github-comment-id:230589222 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Uploading a video clip to Piwigo 2.8.0 results in the following error:
I was unable to reproduce this issue on piwigo.com, however it happens consistently on my local machine, so I went to debug the code and found the issue. It starts with pwg_image_infos() returning null values for width and height when the uploaded file is a video clip.
Second, single_insert() converts null values to empty strings. This causes the insert to fail because the database expects integer values or nulls.
I believe the following change in single_insert() is in order:
replace with
That way null values will remain NULLs.
And finally, a couple of words about using ffmpeg. You are constructing the full path as
which will cause if the configuration parameter doesn't contain a trailing slash.
I would like to suggest a more flexible approach:
That way the path can be specified with or without the trailing slash. This also gives you the opportunity to log a message if the executable is not there. Currently exec() fails silently if the path is incorrect, and there is no way to determine what caused the failure (or even know that ffmpeg didn't run).
@vvinogradsky can you elaborate a bit on your fix ? I have the same problem, but changing the test in
single_insert()does not change anything. I don't really know how to debug and I don't want to clobber my db with invalid data when testing :)I've updated to piwigo 2.8.1 and still have the same error. Even applying the little fix above (in include/dblayer/functions_mysql.inc.php) does not change anything.
Ok, I've found why the fix was not working: I must be using mysqli, not mysql, so the file to edit is include/dblayer/functions_mysql.inc.php.
Awesome! I am glad you found the solution. Too bad there is no official fix for this.
I've made a PR for quicker merge in piwigo :)
Huge +1 for getting this fix into Piwigo, and video upload support into @vvinogradsky 's lightroom publisher plugin.