Upgraded site doesn't rotate images
Bug #1760970 reported by
Kristina Hoeppner
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
High
|
Robert Lyon | ||
18.04 |
Fix Released
|
High
|
Robert Lyon | ||
18.10 |
Fix Released
|
High
|
Robert Lyon |
Bug Description
When you upgrade from 17.10 to 18.04RC2 / master, images that had been uploaded prior to the upgrade cannot be rotated.
Robert tracked it down to the database in the table "artefact_
orientation character varying(10) DEFAULT '0'::character varying,
and
CONSTRAINT artefileimag_ori_ck CHECK (orientation::text = ANY (ARRAY[
when on a fresh install it says "bigint" instead of "character varying".
To post a comment you must log in.
Turns out the problem has nothing to do with the postgres install vs upgrade db settings as there is already code to handle that.
The problem comes from this chain of events:
1) Install an older site (I practised with an old 16.10 site) and add some files including images via Content -> Files then check database table: file_image;
SELECT * FROM artefact_
You should see the width/height values for the files
2) Upgrade to master and log in so you are on dashboard page then check database table: file_image;
SELECT * FROM artefact_
You should see new column added with orientation 0 for the files + the width/height
3) Go to the Content -> Files page then check database table: file_image;
SELECT * FROM artefact_
You should see all image files that exist in the home folder now have their width/height/ orientation removed
The problem stems from the fact the files on upgrade are missing their artefact_file_files contenthash value and there is a bit of code in the ArtefactTypeFile class that checks to see if the value exists and if not generates it and commits the artefact.
And the problem comes in when we create a new ArtefactTypeImage instance we call the parent ArtefactTypeFile and commit it before we have full constructed the ArtefactTypeImage and so data is lost.
Because the parent Artefact class has a destructor we shouldn't need to explicitly call the commit() during construction of ArtefactTypeFile on line 1115 of artefact/ file/lib. php because the it will be committed on destruction as long as we set the $this->dirty = true;