Skip to content

Instantly share code, notes, and snippets.

@janit
Last active May 20, 2020 07:34
Show Gist options
  • Save janit/dad0368b89809df551cc1db025ba1698 to your computer and use it in GitHub Desktop.
Save janit/dad0368b89809df551cc1db025ba1698 to your computer and use it in GitHub Desktop.
eZ Platform v3.0.0 used ezplatform-kernel 1.0.0 package which had an issue with
storing images in the wrong directory: https://jira.ez.no/browse/EZP-31546
The issue was fixed in ezplatform-kernel 1.0.1 (shipped in eZ Platform v3.0.1),
but misplaced files and corrupt database entries for image binaries remain in
the wrong location. This will make your installation not work consistently.
This is a set of commands that can be used to remedy the issue and bring your
file structure and database up-to-date if you have been running version 3.0.0
so that data has accumulated in the wrong way. It is not very elegant, but works.
Be sure to read and understand what you are doing and prepare to have plenty of
diskspace since this is not fruga. You could make it more frugal by moving
files instead of copying, but I just want to be extra conservative here.
!!! BEFORE ATTEMPTING MAKE SURE NO USERS ARE ACTIVELY USING THE SYSTEM !!!
NOTE: This is not an official solution and you run it at YOUR OWN RISK, but
if you choose to attempt to run this, then before trying to attempt
be sure to TAKE BACKUPS of your files and database. Godspeed.
Official support is available for eZ Platform EE customers learn more at
https://www.ibexa.co/services/support-maintenance
-------8<--------------------8<--------------------8<--------------------8<-------
Shell commands to fix files
# Create temp dir and copy wrongly placed images there
cd public/var/site/storage
mkdir temp_images
cp -r 0 temp_images/
cp -r 1 temp_images/
cp -r 2 temp_images/
cp -r 3 temp_images/
cp -r 4 temp_images/
cp -r 5 temp_images/
cp -r 6 temp_images/
cp -r 7 temp_images/
cp -r 8 temp_images/
cp -r 9 temp_images/
# disk usage of individuals
du -d0 temp_images/
du -d0 images/
# sync two dirs
rsync -a temp_images/ images/
# disk usage of synced dir - sanity check that the sum ~matches with the separate file directories
du -d0 images/
# remove old images
rm -rf 0
rm -rf 1
rm -rf 2
rm -rf 3
rm -rf 4
rm -rf 5
rm -rf 6
rm -rf 7
rm -rf 8
rm -rf 9
rm -rf temp_images
# move other images (svg) and attachments
mv ./var/site/storage/application/* ./var/site/storage/original/application/
mv ./var/site/storage/image/* ./var/site/storage/original/image/
mv ./var/site/storage/video/* ./var/site/storage/original/video/
-------8<--------------------8<--------------------8<--------------------8<-------
SQL update statements
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/0', 'var/site/storage/images/0') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/1', 'var/site/storage/images/1') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/2', 'var/site/storage/images/2') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/3', 'var/site/storage/images/3') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/4', 'var/site/storage/images/4') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/5', 'var/site/storage/images/5') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/6', 'var/site/storage/images/6') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/7', 'var/site/storage/images/7') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/8', 'var/site/storage/images/8') WHERE data_type_string = 'ezimage';
UPDATE ezcontentobject_attribute SET data_text = REPLACE(data_text,'var/site/storage/9', 'var/site/storage/images/9') WHERE data_type_string = 'ezimage';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment