Closed DaneViking closed 3 years ago
Most likely a migration not applied.
Most likely a migration not applied.
I've ran the php artisan migrate
but it says Nothing to migrate
hummmm.
[2021-01-31 22:22:56] production.ERROR: Call to a member function name() on null {"exception":"[object] (Error(code: 0): Call to a member function name() on null at /app/lychee/app/Models/Extensions/AlbumCast.php:59)
[stacktrace]
#0 /app/lychee/app/Actions/Albums/Prepare.php(32): App\\Models\\Album->toReturnArray()
This error means that you have a user_id
without its attached user (thus you get null
). This should not be happening. :thinking:
Since version 4.2 you should have a user with id 0 in your users
table, this corresponds to your admin user.
That seems right, which I guess also explains why I don't have any problems with the normal users.
Is there any way to fix this manually?
That user should have been created by the database update, this is why it is very surprising.
Anyway purely via the Database:
mysql -u <username> -p <database>[ENTER]
<password>[ENTER]
INSERT INTO users (username, password) values ('','');
# this will create a new user
select * from users;
# we look for this new user, mostly the id. The user will have no username, no password.
# below the id is 5. We need to change this id to 0
# +----+----------+----------+--------+------+----------------+------------+------------+
# | id | username | password | upload | lock | remember_token | created_at | updated_at |
# +----+----------+----------+--------+------+----------------+------------+------------+
# | 5 | | | 0 | 0 | NULL | NULL | NULL |
# +----+----------+----------+--------+------+----------------+------------+------------+
UPDATE users SET id = 0 where id = 5;
# now that this is done, just to make sure, we also clean the username password from the config table.
UPDATE configs SET value = '' where key = 'username';
UPDATE configs SET value = '' where key = 'password';
Accessing Lychee should ask you to enter a new admin username and password.
Other possibility
php artisan lychee:reset_admin
This too should work fine hopefully, once again this will ask you to enter a new admin username and password.
@ildyria Thanks! (Y)
I'm trying it right now. However, on line
UPDATE users SET id = 0 where id = 5;
it gives an error :
ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'
O.O this means that you do have a user with id 0
.
I am preparing a new diagnostic script to help.
Okay.
I have this output from MariaDB
yeah you can pretty much delete user with id 12 then. Weird.
I'm going to merge this: https://github.com/LycheeOrg/Lychee/pull/901 It should gives us some more insight (if you can do git pull and artisan migrate).
Sorry that you have to go through this, you have a bug which should definitively not happen.
Edit: merged, you should be able to do git pull
or if you cannot, download this file:
https://raw.githubusercontent.com/LycheeOrg/Lychee/master/app/Actions/Diagnostics/Checks/MissingUserCheck.php and place it in <pathToLychee>/app/Actions/Diagnostics/Checks/
You should then be able to do php artisan lychee:diagnostics
How do I delete the user we jsut created?
I'm sorry I don't know anything about mysql or php!
No worries.
DELETE FROM users where id = 12;
Well..
Progress.. Kind of! It's a steep learning curve when you're not used to the linux terminal and working inside a docker container!
Anyway.
New Diagnostics:
Diagnostics
Warning: Dropbox import not working. dropbox_key is empty. Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details. Error: A user is missing! Please create a user with id: "3"
Lychee Version (release): 4.2.1 DB Version: 4.2.1
composer install: --no-dev APP_ENV: production APP_DEBUG: true
System: Linux PHP Version: 7.4 Max uploaded file size: 5000M Max post size: 2000M MySQL Version: 10.4.17-MariaDB-1:10.4.17+maria~bionic-log
Imagick: 1 Imagick Active: 1 Imagick Version: 1802 GD Version: bundled (2.1.0 compatible)
version: 040201
check_for_updates: 0
sorting_Photos_col: title
sorting_Photos_order: ASC
sorting_Albums_col: title
sorting_Albums_order: ASC
imagick: 1
skip_duplicates: 0
small_max_width: 0
small_max_height: 360
medium_max_width: 1920
medium_max_height: 1080
lang: en
layout: 1
image_overlay: 1
image_overlay_type: desc
default_license: none
compression_quality: 90
full_photo: 1
delete_imported: 0
Mod_Frame: 1
Mod_Frame_refresh: 30
thumb_2x: 1
small_2x: 1
medium_2x: 1
landing_page_enable: 0
landing_owner: John Smith
landing_title: John Smith
landing_subtitle: Cats, Dogs & Humans Photography
landing_facebook: https://www.facebook.com/JohnSmith
landing_flickr: https://www.flickr.com/JohnSmith
landing_twitter: https://www.twitter.com/JohnSmith
landing_instagram: https://instagram.com/JohnSmith
landing_youtube: https://www.youtube.com/JohnSmith
landing_background: dist/cat.jpg
site_title: Lychee v4
site_copyright_enable: 1
site_copyright_begin: 2019
site_copyright_end: 2019
additional_footer_text:
display_social_in_gallery: 0
public_search: 0
SL_enable: 0
SL_for_admin: 0
public_recent: 0
recent_age: 1
public_starred: 0
downloadable: 0
photos_wraparound: 1
map_display: 0
zip64: 1
map_display_public: 0
map_provider: Wikimedia
force_32bit_ids: 0
map_include_subalbums: 0
update_check_every_days: 3
has_exiftool: 1
share_button_visible: 0
import_via_symlink: 0
has_ffmpeg: 1
location_decoding: 0
location_decoding_timeout: 30
location_show: 1
location_show_public: 0
rss_enable: 0
rss_recent_days: 7
rss_max_items: 100
prefer_available_xmp_metadata: 0
editor_enabled: 1
lossless_optimization: 0
swipe_tolerance_x: 150
swipe_tolerance_y: 250
local_takestamp_video_formats: .avi|.mov
log_max_num_line: 1000
unlock_password_photos_with_url_param: 0
nsfw_visible: 1
nsfw_blur: 0
nsfw_warning: 0
nsfw_warning_admin: 0
Error: A user is missing! Please create a user with id: "3"
I guess we have our answer. :)
INSERT INTO users (username, password) values ('wonder-woman','');
# this will create a new user
select * from users;
# we look for this new user, mostly the id. The user will have no username, no password.
# below the id is 5. We need to change this id to 0
# +----+--------------+----------+--------+------+----------------+------------+------------+
# | id | username | password | upload | lock | remember_token | created_at | updated_at |
# +----+--------------+----------+--------+------+----------------+------------+------------+
# | 13 | wonder-woman | | 0 | 0 | NULL | NULL | NULL |
# +----+--------------+----------+--------+------+----------------+------------+------------+
UPDATE users SET id = 3 where id = 13;
Progress.. Kind of! It's a steep learning curve when you're not used to the linux terminal and working inside a docker container!
Congrats on that one. :fearful:
Well.
I was finally able to log in again.
Can I delete the user 3 now?
If you delete the albums that user 3 own, yes.
Otherwise you can transfer ownership to admin manually
UPDATE albums SET owner_id = 0 where owner_id = 3;
UPDATE photos SET owner_id = 0 where owner_id = 3;
or directly via the GUI by creating an album A that is owned by admin and then moving the album owned by user 3 to that album A. This will trigger a ownership change to the owner of A.
Once there is no album owned by 3, then you can delete it. Otherwise you will be facing the same bug again.
Well, that's strange.
I just did the
UPDATE albums SET owner_id = 0 where owner_id = 3; UPDATE photos SET owner_id = 0 where owner_id = 3;
and i got moved some albums arround to user 0 that in the DB-list should be owned by ID 1.
Is it possible to select which albums should be owned by certain users?
By the way, thank you for lighting this bug up. :)
and i got moved some albums around to user 0 that in the DB-list should be owned by ID 1.
Dafuck. O.o
Is it possible to select which albums should be owned by certain users?
This will show you all the albums owned by user 6.
SELECT id, title FROM albums WHERE owner_id = 6;
# +------------+-----------+
# | id | title |
# +------------+-----------+
# | 1470501689 | Polynesie |
# +------------+-----------+
Okay.
So, "Wonder-woman" is dead and gone! (Y)
user id = 1 --> doesn't have any albums any more.
user id = 0 --> now owns every album on the server.
Is there a way to change the ownership of the album to a different user ID?
This should do the trick
UPDATE albums SET owner_id = <desired owner_id> WHERE id = <album_id>;
I'm still surprised that the albums from user 1 got changed to user 0 especially given that it worked fine on my end:
UPDATE albums SET owner_id = 0 WHERE owner_id = 15;
# Query OK, 1 row affected (0.006 sec)
# Rows matched: 1 Changed: 1 Warnings: 0
Without the brackets <> it worked fine.
Now I think every album is back to the right user.
I haven't really started using the software yet, so my own files was just for testing purpose. However, my aunt have used it quite a bit, so to tell her to upload and rename every file again would not have been fun!
I can imagine. :)
Can we close this issue now?
Yep!
Can we close this issue now?
@ildyria I was trying to figure out why this happend, and IIRC I actually created a user with the same name as the admin user, but with a different password. The issue might have started when I deleted that user. Then something must have happend with the database.
I think that's why it happend, but I'm not sure. Perhaps something to investigate in the future! :)
Detailed description of the problem [REQUIRED]
Using Lychee as a docker in Unraid, my admin account is unaccessable. When I try to log in comes with this error:
It only does this and only the admin account. Three other user accounts works without issues.
Steps to reproduce the issue
When I try to log in, the login box appears. When I enter the credentials for the admin user, it gives "Server error or API not found". And the screen is just black.
Output of the diagnostics [REQUIRED]
Output of the laravel.log
Browser and system
Tested in Explorer, Edge, Chrome, Chrome for Android.