I have an image entry in my database that has the following characteristics:
ID = 80079
File = 8362e904.jpg
When you try to access the page for the image, you get the following Mysql error:
[mysql error 1367] Illegal double '8362e904' value found during parsing
SELECT id, file, level
FROM piwigo_images
WHERE id = 8362e904 in piwigo/include/dblayer/functions_mysqli.inc.php on line 847
As you can see, the software identifies "8362e904" as the ID and not the file name. It determines that the variable is actually a number, therefore it must be the numerical ID. Can an additional check be added to correctly determine if it is an integer before assuming it is a valid mediumint?
This is an error that occasionally pops up.
I have an image entry in my database that has the following characteristics:
ID = 80079
File = 8362e904.jpg
When you try to access the page for the image, you get the following Mysql error:
```
[mysql error 1367] Illegal double '8362e904' value found during parsing
SELECT id, file, level
FROM piwigo_images
WHERE id = 8362e904 in piwigo/include/dblayer/functions_mysqli.inc.php on line 847
```
As you can see, the software identifies "8362e904" as the ID and not the file name. It determines that the variable is actually a number, therefore it must be the numerical ID. Can an additional check be added to correctly determine if it is an integer before assuming it is a valid ```mediumint```?
<!-- github-sync-id:1493436732 -->
As expected the variable 8362e904 is picked up as a number, but it is not picked up as an integer.
Therefore the fix for this should be to replace the above referenced code with:
if (is_int($page['image_id']))
{
$query .= 'id = '.$page['image_id'];
}
It appears in [picture.php](https://github.com/Piwigo/Piwigo/blob/be63364aa663643a5886d120d754c306dbfa945f/picture.php#L29) the following code is what checks if a variable is a number or not:
```
if ($page['image_id']>0)
{
$query .= 'id = '.$page['image_id'];
}
```
I have run the following PHP tests in multiple versions, with the same result in all:
````
echo ('8362e904' > 0) ? 'numeric' : 'not numeric';
echo is_numeric('8362e904') ? 'numeric' : 'not numeric';
echo is_numeric(8362e904) ? 'numeric' : 'not numeric';
echo is_int('8362e904') ? 'integer' : 'not integer';
echo is_int(8362e904) ? 'integer' : 'not integer';
````
The result is:
````
numeric
numeric
numeric
not integer
not integer
````
As expected the variable ```8362e904``` is picked up as a number, but it is not picked up as an integer.
Therefore the fix for this should be to replace the above referenced code with:
```
if (is_int($page['image_id']))
{
$query .= 'id = '.$page['image_id'];
}
```
<!-- github-comment-id:1347797700 -->
You probably still want the check if greater than zero.
I also have seen a ton more places in the code where the greater than zero check is used to determine if the variable is an integer. They should all be changed.
I realize this probably should be:
````
if (is_int($page['image_id']) && $page['image_id']>0)
{
$query .= 'id = '.$page['image_id'];
}
````
You probably still want the check if greater than zero.
I also have seen a ton more places in the code where the greater than zero check is used to determine if the variable is an integer. They should all be changed.
<!-- github-comment-id:1356382575 -->
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.
This is an error that occasionally pops up.
I have an image entry in my database that has the following characteristics:
ID = 80079
File = 8362e904.jpg
When you try to access the page for the image, you get the following Mysql error:
As you can see, the software identifies "8362e904" as the ID and not the file name. It determines that the variable is actually a number, therefore it must be the numerical ID. Can an additional check be added to correctly determine if it is an integer before assuming it is a valid
mediumint?It appears in picture.php the following code is what checks if a variable is a number or not:
I have run the following PHP tests in multiple versions, with the same result in all:
The result is:
As expected the variable
8362e904is picked up as a number, but it is not picked up as an integer.Therefore the fix for this should be to replace the above referenced code with:
I realize this probably should be:
You probably still want the check if greater than zero.
I also have seen a ton more places in the code where the greater than zero check is used to determine if the variable is an integer. They should all be changed.