openbenches.org
openbenches.org copied to clipboard
A new bench could be saved without some of the images and without warning.
Steps to recreate:
- Click "Add new Bench" button.
- Select image A which is a photo of an inscription.
- Select image B which is a photo of the bench.
- Click "Share Bench" button.
- Click "Add new Bench" button.
- Select image C which is a photo of an inscription.
- Select image B for whatever reason. Accidents happen.
- Click "Share Bench" button.
Expected (? Desired?) results: The bench does not get submitted. Some sort of message appears informing that image B has already been submitted and the user has a chance to correct the issue.
Actual results: The bench is successfully submitted without any indication of there being a problem. Image B doesn't show up on the bench page. User probably wonders why there's only one photo on their submission instead of two.
I haven't experienced this issue, I suspected it's existence whilst reading the code and then confirmed it using a local instance of the OpenBenches code.
The save_image() function returns some text if asked to save a duplicate image, but in add.php that text isn't assigned to a variable for three of the calls to save_image()
https://github.com/edent/openbenches/blob/8ea9be3cc73a5b503f181226cfffb7cf2b0c8ed3/www/add.php#L54
https://github.com/edent/openbenches/blob/8ea9be3cc73a5b503f181226cfffb7cf2b0c8ed3/www/add.php#L67
https://github.com/edent/openbenches/blob/8ea9be3cc73a5b503f181226cfffb7cf2b0c8ed3/www/add.php#L74
By contrast, in edit.php the output of save_image() is always assigned and an error message built up and displayed
https://github.com/edent/openbenches/blob/8ea9be3cc73a5b503f181226cfffb7cf2b0c8ed3/www/edit.php#L56
https://github.com/edent/openbenches/blob/8ea9be3cc73a5b503f181226cfffb7cf2b0c8ed3/www/edit.php#L95
Possibly the fix is do what edit.php does in add.php. :man_shrugging:
Yes, I think that's a good idea.
The new version of the code will allow the same photo to be uploaded to multiple benches. The reduces the number of errors users see, and makes the logic a lot easier. If they notice they've made a mistake they can delete the bench and start again.
I occasionally run a check to see an image has been attached to multiple benches. It only happens rarely.