Recently upgraded from alpha0 to alpha2 and now getting the following message when trying to do any view, edit or delete operations on a node containing a file field which has field which uses s3fs.

Class name must be a valid object or a string in Drupal\image\Entity\ImageStyle->buildUri()

Any clues?

Comments

kevla created an issue. See original summary.

jansete’s picture

In alpha2 image styles generation changed enterily. Maybe you have refresh cache and if you cache your php code, reload your php service.

kevla’s picture

Hmm no reloading cache doesn't seem to fix it.

jansete’s picture

Can you tell us more info? How do you work with the images or files in the project? Steps to reproduce?

kevla’s picture

Debugging this further, has the uri scheme changed from s3fs to s3?

More info to follow in a sec. Might be quite time consuming to find a give you a vanilla situation to reproduce this so I'm going to try and debug it first.

kevla’s picture

Ah I think I know what the matter is.

It's a difference between 8.x-2.0-alpha0 and 8.x-3.0-alpha3

The scheme is totally changed. I guess I am locked in version 2?

jansete’s picture

Yes kevla, you can replace all your s3fs_file register and file_managed from s3fs to s3, because in 8.x-2.x it was wrong.

Make backups before that. 8.x-2.x is not more supported.

jansete’s picture

Version: 8.x-3.0-alpha2 » 8.x-2.0-alpha0
Status: Active » Closed (outdated)
andreyks’s picture

Updating for drupal 8.5.1

andreyks’s picture

jansete’s picture

Hi andreyks the patch is for core? So it shouldn't be in this module.

chuckienorton’s picture

I am getting the same error after updating.

Re jansete's comment

you can replace all your s3fs_file register and file_managed from s3fs to s3, because in 8.x-2.x it was wrong.

- is it possible to elaborate? Are you referring to settings.php configs?

For reference - i'm updating from drupal 8.2 -> 8.5.1, and s3fs 2.x-dev (not sure which version) -> 3.x-dev (now 8.x-3.0-alpha9)

hamilti’s picture

My issue was completely unrelated to S3. Patch #9 worked for me. After a recent core update the problem occurred and is simply due to a missing image in the files folder, a fairly simple but major problem I think. The presence of the file needs to be tested first - clearly this is a core issue. How do we get that added?

UPDATE: Further testing shows that this while the above fixes the immediate frontend display problem, I cannot admin the custom block to add the image. This problem has already been identified in core Url.php and documented here: https://www.drupal.org/project/drupal/issues/2953330

chuckienorton’s picture

RE:

you can replace all your s3fs_file register and file_managed from s3fs to s3, because in 8.x-2.x it was wrong.

I found the solution to this if you're updating from a version previous to s3fs 3 - here is an sql query to replace all the s3fs references with s3. Just run this on your database.

UPDATE file_managed
SET uri = REPLACE(uri,'s3fs','s3')
WHERE uri LIKE '%s3fs%';

UPDATE s3fs_file
SET uri = REPLACE(uri,'s3fs','s3')
WHERE uri LIKE '%s3fs%'
AND dir = 0;

If this is incorrect, admins, please let me know. I'm curious as to why this wasn't handled during an update.

nashkrammer’s picture

Hi chuckienorton,

Your solution worked for me. Though after running the update query on file_managed and s3fs_file tables, issue was resolved and s3 file were fetched properly but for very few files the url appears as below
<img property="schema:image" src="/s3/files/styles/large/s3/2018-06/filename.png?itok=Yk0475fa" width="480" height="269" alt="sample" typeof="foaf:Image" class="image-style-large">

I checked the filename it does exist on s3 bucket but url itself is not formed correctly for them. Any pointer could really help. Thank You.
-Avinash

jansete’s picture

Hi @nashkrammer,

/s3/files/styles/large/s3/2018-06/filename.png is a route callback to generate image style, it belongs drupal instead bucket, the second time when image style had been generated in the bucket, the url will change to the final bucket url (yes, now is in the bucket).