Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating existing User Photos from Craft 2 to 3 does not match URL schema; existing photos not found. #5373

Open
pixleight opened this issue Dec 23, 2019 · 16 comments
Assignees

Comments

@pixleight
Copy link

@pixleight pixleight commented Dec 23, 2019

Description

User photos in Craft 2 are uploaded in individual directories of the format /craft/storage/{username}/original/{filename.ext} (as well as transforms like ...{username}/60/{filename.ext})

After migrating to Craft 3, assets are still being associated with users, but the URL path does not match the file path in the userphotos directory. Example:

Original photo uploaded in Craft 2 for john.doe@domain.com and moved to Craft 3 is stored at /public/uploads/userphotos/john.doe@domain.com/original/photo.jpg. A function like currentUser.photo().url() outputs http://domain.tld/uploads/photo.jpg.

Also tried updating user photo location in User Settings. See screenshot-01. Output URL of existing user photos does not change, but new userphoto uploads in Craft 3 get stored in /public/uploads/userphotos/email@domain.com/photo.jpg and echoed URL matches.

Steps to reproduce

  1. Moved user photos directory from /craft/storage/userphotos to /storage/userphotos as outlined in step 4 of https://docs.craftcms.com/v3/upgrade.html#performing-the-upgrade and at https://docs.craftcms.com/v3/changes-in-craft-3.html#user-photos
  2. Installed Craft 3 & ran database update
  3. Moved user photos directory to a publicly-accessible location; in my case /public/uploads/userphotos.
  4. Updated User Photos volume paths from @storage/userphotos to match new directory. See
    screenshot-02

Additional info

  • Craft version: Craft Pro 3.3.8 (migrating from 2.7.10)
  • PHP version: 7.2.21
  • Database driver & version: MySQL 5.7.26
  • Plugins & versions: (also tested without plugins)
    • Delete Account 1.0.2
    • Element API 2.6.0
    • Environment Label 3.1.5
    • Express Forms 1.0.4
    • Guest Entries 2.2.4
    • Mailchimp Subscribe 3.0.0
    • Navigation 1.1.13
    • Neo 2.5.3
    • Position Fieldtype 1.0.14
    • reCAPTCHA 1.3.0
    • Redactor 2.4.0
    • Retour 3.1.26
    • Section Field 1.1.0
    • SEOmatic 3.2.28
    • Sprout Reports 1.2.8
    • Template Comments 1.1.2
    • Typogrify 1.1.18
    • Video Embedder 1.1.4
@pixleight pixleight changed the title Migrating existing User Photos from Craft 2 to 3 does not match URL schema; exisisting photos not found. Migrating existing User Photos from Craft 2 to 3 does not match URL schema; existing photos not found. Dec 23, 2019
@brandonkelly

This comment has been minimized.

Copy link
Member

@brandonkelly brandonkelly commented Dec 24, 2019

After updating to Craft 3 (step 2 in your list), does your users table (or craft_users) have values for the photoId column, for users that had photos in Craft 2?

@pixleight

This comment has been minimized.

Copy link
Author

@pixleight pixleight commented Dec 28, 2019

@brandonkelly Yes it does, and they point to the right assets.

@brandonkelly

This comment has been minimized.

Copy link
Member

@brandonkelly brandonkelly commented Dec 30, 2019

Can you double-check that the correct Volume is selected in the User Photo Location setting in Settings → Users → Settings? And also go into that volume’s settings and make sure you’ve definitely got the userphotos segment in the Base URL setting?

@pixleight

This comment has been minimized.

Copy link
Author

@pixleight pixleight commented Jan 2, 2020

Yes, User Photo Location is set to the User Photos volume. I've tried it both with and without {username} or {email} set as the subfolder path.

The userPhotos volume base URL and path are @baseUrl/uploads/userphotos and @basePath/uploads/userphotos, respectively.

@andris-sevcenko

This comment has been minimized.

Copy link
Member

@andris-sevcenko andris-sevcenko commented Jan 8, 2020

@pixleight Any chance this is on a site where it's possible to get CP and FTP access? If so, can you get in touch via email (support@craftcms.com) and reference this issue, please?

@andris-sevcenko

This comment has been minimized.

Copy link
Member

@andris-sevcenko andris-sevcenko commented Jan 8, 2020

@pixleight or, a pre-update DB backup would also suffice. I could probably mock a few photos and observe the issue myself after upgrading, then.

@atdotslashdot

This comment has been minimized.

Copy link

@atdotslashdot atdotslashdot commented Jan 23, 2020

the docs say "Craft will automatically create a new asset volume called “User Photos” at storage/userphotos/ (where Craft previously stored all user photos, but without the / subfolders)."
This isn't true, the username is still present in the storage (e.g. storage/userphotos/John.Doe/original/johndoe.jpg)

If i move this folder into web space and set
User photos file system path to
@webroot/userphotos

and set
User Photo Location to
{username}/original

a new upload will match the same structure but a re-index of User Photos produces lots of
errors for the existing users that were in craftcms2

Missing files
The following files could not be found. Should they be deleted from the index?
User Photos/johndoe.jpg

I can see that
User Photos/johndoe.jpg
doesn't exist (it's actually User Photos/John.Doe/original/johndoe.jpg) but I don't want to delete them from the index and have to reupload a couple of hundred user pictures

is there any solution to this?

@atdotslashdot

This comment has been minimized.

Copy link

@atdotslashdot atdotslashdot commented Jan 23, 2020

If it helps, on further investigation, the folder id for all existing users in the assets table all point toward the userphotos folder (not the individual {username}/original subfolder)

@atdotslashdot

This comment has been minimized.

Copy link

@atdotslashdot atdotslashdot commented Jan 23, 2020

....so it looks like _moveUserphotos in m160804_110002_userphotos_to_assets.php
failed or didn't get run
no errors were reported on the web page when the update happened .
I'm still looking for a solution how to untangle this :-)

@andris-sevcenko

This comment has been minimized.

Copy link
Member

@andris-sevcenko andris-sevcenko commented Jan 24, 2020

@atdotslashdot when you look at the migrations table, do you see the m160804_110002_userphotos_to_assets migration there?

@atdotslashdot

This comment has been minimized.

Copy link

@atdotslashdot atdotslashdot commented Jan 24, 2020

@andris-sevcenko

yes it's in the there, if its useful the apply time, date created and date updated fields are all exactly the same time

@andris-sevcenko

This comment has been minimized.

Copy link
Member

@andris-sevcenko andris-sevcenko commented Jan 24, 2020

@atdotslashdot Okay. I'm working on reproducing this locally.

@atdotslashdot

This comment has been minimized.

Copy link

@atdotslashdot atdotslashdot commented Jan 24, 2020

Thanks

@andris-sevcenko

This comment has been minimized.

Copy link
Member

@andris-sevcenko andris-sevcenko commented Jan 24, 2020

@atdotslashdot unfortunately, I'm unable to reproduce this when migrating a site locally from Craft 2.7.4 to the latest.

Is it possible for you to zip up your site and pre-update DB and send them over to support@craftcms.com referencing this ticket? Otherwise, it's really hard to figure out what's going wrong without being able to trigger it.

@atdotslashdot

This comment has been minimized.

Copy link

@atdotslashdot atdotslashdot commented Jan 24, 2020

@andris-sevcenko
Sadly not, but I'm working on a migration route here so will have to go through the migration steps again once I've sorted out the new templates. Instead of upgrading via the web page would I be better off running craft migrate/all to see if any errors are reported next time I try? I would prefer to migrate entirely via the command line if it's possible.
Thanks for your help.

@andris-sevcenko

This comment has been minimized.

Copy link
Member

@andris-sevcenko andris-sevcenko commented Jan 24, 2020

Instead of upgrading via the web page would I be better off running craft migrate/all to see if any errors are reported next time I try? I would prefer to migrate entirely via the command line if it's possible.

That is preferable, yeah. Let me know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.