Skip to main content


On my server, the server where is profile it hosted, the profile picture does not load anymore.

It shows a fault:

Internal Server Error

Invalid photo with id 888.

#0 [internal function]: Friendica\Module\Photo::rawContent()
#1 /srv/http/src/App/Module.php(289): call_user_func()
#2 /srv/http/src/App.php(557): Friendica\App\Module->run()
#3 /srv/http/index.php(40): Friendica\App->runFrontend()
#4 {main}

Link to profile photo should be this, according to html source:
https://friendica.utzer.de/photo/52959870015ac78226075e6200304821-4.jpg?ts=1523017271?rev=2018-04-06+14%3A21%3A11

Any idea what is wrong?

!Friendica Support #Friendica @utzer

Where are the photos stored? Database or file system?
Please execute this query and report the result:
select `backend-class`, `backend-ref` from photo where id = 888;
@Michael Vogel
MariaDB [friendica]> select `backend-class`, `backend-ref` from photo where id = 888;
+---------------+-------------+
| backend-class | backend-ref |
+---------------+-------------+
|               | 670476      |
+---------------+-------------+
1 row in set (0.001 sec)

Please check if the "data" field contains a value there. If not then you have got a problem. The backend-class should only be empty when you still store your pictures in the database.

Please check if you have got a field in the storage table with the id "670476". Also check if in the storage folder there is some file that contains this id. I don't know the exact format of the stored pictures, so I can't give you a hint for the exact filename.

select id from storage where id=670476;

@Michael Vogel
Results of select id from storage where id=670476;:

MariaDB [friendica]> select id from storage where id=670476;
+--------+
| id     |
+--------+
| 670476 |
+--------+
1 row in set (0.001 sec)
This entry was edited (3 years ago)
Interesting. We possibly can repair this, but I need some time.

@Michael Vogel

Please check if you have got a field in the storage table with the id "670476". Also check if in the storage folder there is some file that contains this id. I don't know the exact format of the stored pictures, so I can't give you a hint for the exact filename.


For find ./ -type f -name "*670476*" I get many results. Should the name start with it?

I never saw this problem anywhere. Can you remind me at the weekend when I haven't reacted until then?

@Michael Vogel it will be a pleasure, meaning it is the least I can do.

By the way it is still moving some million of files it seems.

When I run find ./ -type f -name "*"|grep -v "\.html"|wc -l, which counts lines of the output of find, which is equal to the number of files, I get 20.261.436 and wonder how it is possible that there is 20 million files.

Please try:
update photo inner join storage on storage.id = photo.`backend-ref` set `backend-class` = 'Database' where photo.data = '' and `backend-class` = '' and `backend-ref` != '';
@Michael Vogel just to be sure, this should also work if not all photos are moved to database yet? I am not sure about that state of the move, but will also check in a few minutes.
@Michael Vogel alright, just doing an backup and then will run that code.
Interesting. Sadly I don't know that photo class part very well. For some reason your system doesn't write the backend-class".
The systen is doing so anyway over time. That's the "UpdateContact" class.
No, there is no setting for this. Every contact with a post on the system is checked once a month or once a week if not failed. And if update_active_contacts isn't set, then also every other known contact is checked every 6 month or 1 month if not failed.

Your case is really special and we yet haven't found the reason for this problem. So some manual updating won't fix the issue but would just disguise it.

Would be great if @Fabio could step in, since he wrote that class 😀

Ah, like i remember what I wrote ... 😀
I have full trust in you 😁
It's quite difficult to debug this from remote. Looks like the system is adding (or updating) rows in "photo" table without backend-class set. Looking at the code, the only place where that is writtend in db is in \Friendica\Model\Photo::store(), and looks like it's correct. But maybe there is some corner case which isn't obvious...
We should find a repeatable way to make the system write a wrong row in db to try to understand why it write a wrong row in db.
Are you running bin/console storage move?
To which backend are you moving to?

mmh..
what $ bin/console config storage name says?

can you try to change in src/Core/StorageManager.php in line 314:
'backend-class' => $destination to 'backend-class' => $destination::getName() ?

@Fabio I stoped the move process, then changed line 314 as you suggested, now
1. The move seems to be finished, it only moved a couple of thousand (4923) files and says it finished.
2. Mysql query of @Michael Vogel now finds 0 affected rows.
3. There is still over 20 million non .html files in the filesystem storage location it seems.

looks like a fix.
the files in filesystem storage dir should have been deleted while moving, but as long they have been copied in database, you could delete them, maybe....

Anyway, I'll do some tests and eventually send a pull request...

Which version of php are you using?

@Fabio most of the files are 0B, over all size is only 90 MB, but that includes the html files again.

php 7.4.16

This entry was edited (3 years ago)
we can do a query looking for rows in storage table not referenced in photo and attach tables, and we could get data and try to show it as images, but then someone should look at the images and find to which row in photo belong, by hand.
Because we have file metadata (filename, mimetype, ect) in photo table with a link to storage table where there is the actual data, but we have no means to automatically get back from storage to photo.

@Fabio hmm I think by hand is no an option, I should not look at users photos, maybe there is private photos there.
Also I am not sure how many files it would be, so it could be just a few or really alot.

Do you know why the move works in some case (social.yl.ms) and not in others (friendica.utzer.de) and I think @Michael Vogel also wrote he was moving storage (but maybe from database to filesystem.

Whatever happened there, there had been exactly one bug report so far. I really would like to know the origin of the problem.
@Fabio for me it would be important to ensure that this bug does not hit other people before it is fixed. I did not open an issue about the problem, because I am not sure if this can actually happen for other peoples installation.

I just tried on a new install, "rc" branch, without the patch on a ubuntu Bionic with php 7.4.7:
Upload a photo using "Legacy" backend;
Set Filesystem backend;
Move to Filesystem : no problems.
Set Database backend;
Move to Database: no problems.

While the patch imho is still good (I would add ::getName() also on line 308, same file, at the end of the log (otherwise the log shows Save data to new backend. {"newBackend":{}} instead of Save data to new backend. {"newBackend":"Database"} which is what should say, imho ) looks like it should have worked anyway...

@Fabio The other PR was already merged, do you want to do another PR?
@Fabio I clicked the refetch thing in the profile, but still the photo was shown. Strange.