EPSA crop saves its data in table epsacrop_files. File ID (fid) is key and 'coords' is data.
So far, so good.
But the EPSA crop data gets saved in an array at array element key = file ID.
In other words, if your image file ID is 1894, then, the actual EPSA crop data gets preceded by 1893 times 'null, '.
Imagine what a waste of database space that would be if you have thousands of files...
$coord = $coords[$fid][$preset];
in epsacrop_crop_image() proves this construction.
The solution probably lies within epsacrop.js which calls 'crop/ajax/put/' ...
But all the other module files will need to be adjusted accordingly.
Comment | File | Size | Author |
---|---|---|---|
#5 | epsacrop.js-object-storage.1823940-5.patch | 925 bytes | jsst |
#4 | 1823940-epsacrop-js-object-storage-4.patch | 3.47 KB | jsst |
#1 | 1823940-epsacrop-js-object-storage.patch | 4.32 KB | davidwhthomas |
Comments
Comment #1
davidwhthomas CreditAttribution: davidwhthomas commentedI noticed the same issue occurring sporadically, large null padded js arrays being created, and stored in db.
It's related to how the "presets" variable is treated in javascript - as an array or as an object.
e.g
var presets[1234] = {}
creates an array with 1234 empty elements.
Generally, as per the code it should be treated as an object.
I've attached a small patch that ensures the variable is initialized as an object in cases where it might be treated as an array, if empty.
Attached.
Thanks for the neat module.
Comment #2
yvmarques CreditAttribution: yvmarques commentedComment #4
jsst CreditAttribution: jsst commentedThis patch removes the bogus 'null' values from the preset object before saving it back to the database. Fixes from #2 are also included.
Comment #5
jsst CreditAttribution: jsst commentedBoth #1 and #4 did not fix the issue completely.
Attached patch fixes this in the ajax handling, not client-side. Previous patches should not be applied. I ended up creating an update task that converts all arrays in epsacrop_files.coords to objects (that saved gigabytes of useless 'null, null, null'!).
Comment #6
Toraih CreditAttribution: Toraih commentedIf you have thousands of cropped images like us, you probably want to cleanup the epsacrop-table from null-values.
or adding this to a cron job running weekly or monthly is a fine way to keep your table clean automatically...
Comment #7
PieterDCIt would be cool if that functionality went in an update function so it automatically gets executed when upgrading.
Comment #8
itamair CreditAttribution: itamair commentedWe are experiencing huge drupal db dimension, caused by Epsa Crop table.
Does the #5 patch solve the matter properly? As it claims ...
Why is not yet been pushed in the stable version of this module?
Any update on this would be really appreciated ... thanks
Comment #9
itamair CreditAttribution: itamair commentedComment #10
yvmarques CreditAttribution: yvmarques commented