Comment 1 for bug 1760970

Revision history for this message
Robert Lyon (robertl-9) wrote :

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:
 SELECT * FROM artefact_file_image;

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:
 SELECT * FROM artefact_file_image;

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:
 SELECT * FROM artefact_file_image;

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;