LycheeOrg / Lychee

A great looking and easy-to-use photo-management-system you can run on your server, to manage and share photos.
https://lycheeorg.github.io/
MIT License
3.42k stars 303 forks source link

upgrade to 4.5.3, cannot uploads image #1465

Closed cnkmmk closed 2 years ago

cnkmmk commented 2 years ago

I upgrade Lychee to 4.5.3. can not uploads image.


log

2022-08-18 05:27:08 UTC -- error -- App\Http\Middleware\AcceptContentType::handle -- 41 -- Content type unacceptable. Content type "json" required 2022-08-18 05:26:39 UTC -- error -- Illuminate\Foundation\Http\FormRequest::failedValidation -- 138 -- The given data was invalid. 2022-08-18 05:26:39 UTC -- error -- App\Http\Requests\BaseApiRequest::validateResolved -- 84 -- The given data was invalid.; caused by 2022-08-18 05:25:20 UTC -- error -- Illuminate\Foundation\Http\FormRequest::failedValidation -- 138 -- The given data was invalid. 2022-08-18 05:25:20 UTC -- error -- App\Http\Requests\BaseApiRequest::validateResolved -- 84 -- The given data was invalid.; caused by


php artisan lychee:diagnostics

In Builder.php line 2678:

Undefined property: stdClass::$owner_id


nagmat84 commented 2 years ago

This looks like something in your installation has been mixed up rather than a bug in Lychee. Please

  1. run git status inside your installation directory to ensure that the working dir is clear and spurious outdated files are left
  2. clean all the various Laravel caches via the corresponding artisan clear commands, like ./artisan config:clear (./artisan list should give you a list of all commands and then watch out for 'clean or clear)
  3. confirm that your browser is loading the correct web frontend from public/. We have seen this kind of error once or twice from users who moved the frontend to some other location, configured the webserver to serve the frontend from that alternative location and then forgot to update that copy of the frontend when the updated the backend.
cnkmmk commented 2 years ago

I unzip version 4.5.3 files in new directory, copy all upload files and database file. run 'php artisan migrate'. I can view Lychee in browser.


I run 'php artisan optimize:clear' the same error.

nagmat84 commented 2 years ago

BTW, please use the template to report errors. In particular, the output of the diagnostic and the information about your system is missing.

kamil4 commented 2 years ago

Just to confirm, php artisan migrate worked fine, and viewing existing photos works fine as well?

I was going to suggest that you check the versions of your PHP engine and the database engine, but if the migration worked, then you are probably fine on that front...

nagmat84 commented 2 years ago

I still believe the issue is an out-of-sync error between a newer version of the backend and an older version of the frontend. The error basically tells us that the frontend sends a non-JSON request when the backend expects one.

In the past versions (i.e. before my refactorings) many requests related to "read access" (i.e. viewing photos, browsing albums, etc.) were already properly formatted JSON requests. Much of the refactoring went into requests related to uploading photos and error reporting. If the version of the frontend was too old for the backend, this could also explain why simple browsing just seems to work fine, while uploading does not.

Anyway, without having a proper diagnostic output, this is like tapping around in the dark.

kamil4 commented 2 years ago

FYI, the compiled front end files reside in public/dist/. So, @cnkmmk, please verify that, e.g., public/dist/main.js in your installation is 966932 bytes long...

cnkmmk commented 2 years ago

thank you. @kamil4 图片

cnkmmk commented 2 years ago

My system infomation

Browser and system

  1. OS: Debian 11.0.4 IP: 192.168.4.45
  2. HTTP service: caddy 2.5.3
  3. Caddyfile:
    {
    order webdav before file_server
    auto_https off
    }
    (global) {
    php_fastcgi unix//run/php/php8.1-fpm.sock
    file_server
    log {
        output file /var/log/caddy/caddy.log
        format filter {
            wrap json {
                time_format wall
            }
            fields {
                request>headers>Accept delete
                request>headers>Accept-Language delete
                request>headers>Connection delete
                request>headers>Cookie delete
                request>headers>Accept-Encoding delete
                request>headers>Upgrade-Insecure-Requests delete
                request>headers>X-Xsrf-Token delete
                request>headers>Sec-Fetch-Dest delete
                request>headers>Sec-Fetch-Site delete
                request>headers>Sec-Fetch-Mode delete
                request>headers>Sec-Fetch-User delete
                request>headers>X-Requested-With delete
                request>headers>Content-Length delete
                request>headers>Te delete
                request>headers>Content-Type delete
                request>proto delete
                request>method delete
                request>remote_port delete
                request>tls delete
                user_id delete
                duration delete
                resp_headers delete
            } 
        }
    }
    }
    :2280 {
    root * /opt/www/
    redir /webdav /webdav/
    handle /webdav/* {
        basicauth /webdav/* {
            mercuryhg JDJhJDEwJEphdUZRUjNUYmY4QTNqMDNjV1I0NXU1TU1rNVkwUEZ4YU1PMTh2aFVuNXJCalltQ2VHcDI2
        }
        webdav /webdav/* {
            root /opt/webdav/
            prefix /webdav/
        }
    }
    import global
    tls "/opt/lets/fullchain.cer" "/opt/lets/*.*****.win.key"
    }
    :2281 {
    root * /opt/Lychee/public/
    import global
    tls "/opt/lets/fullchain.cer" "/opt/lets/*.*****.win.key"
    }
    :2282 {
    root * /opt/baikal/html/
    import global
    tls "/opt/lets/fullchain.cer" "/opt/lets/*.*****.win.key"
    }
    :2283 {
    root * /opt/xiaoshuo/
    import global
    @te {
        not remote_ip 192.168.4.244 192.168.4.23
    }
    handle @te {
        respond "Access denied" 403
    }
    }
  4. PHP 8.1
  5. browser: firefox 103.0.2
cnkmmk commented 2 years ago

install packets

apt install -y libpcre2-dev php8.1-cgi php8.1-fpm php8.1-curl php8.1-gd php8.1-xml php8.1-mbstring php8.1-zip php8.1-mysql php8.1-sqlite3 php8.1-bcmath php8.1-gd php8.1-imagick
cnkmmk commented 2 years ago

upgrade step:

  1. download Lychee.zip from https://github.com/LycheeOrg/Lychee/releases/download/v4.5.3/Lychee.zip
  2. unzip Lychee.zip
  3. mv Lychee /opt/
  4. mv .env.example .env
  5. php artisan key:generate
  6. php artisan migrate
  7. check /etc/php/8.1/fpm/php.ini
    max_execution_time = 200
    post_max_size = 100M
    upload_max_size = 100M
    upload_max_filesize = 100M
    memory_limit = 256M
  8. restore old version files: database.sqlite , public/uploads/*
  9. chown www-data: /opt/Lychee -R
  10. chmod 2775 public/uploads public/sym -R
  11. php artisan migrate
  12. visit url in browser
d7415 commented 2 years ago

wrap json { time_format wall } fields { request>headers>Accept delete request>headers>Accept-Language delete request>headers>Connection delete request>headers>Cookie delete request>headers>Accept-Encoding delete request>headers>Upgrade-Insecure-Requests delete request>headers>X-Xsrf-Token delete request>headers>Sec-Fetch-Dest delete request>headers>Sec-Fetch-Site delete request>headers>Sec-Fetch-Mode delete request>headers>Sec-Fetch-User delete request>headers>X-Requested-With delete request>headers>Content-Length delete request>headers>Te delete request>headers>Content-Type delete request>proto delete request>method delete request>remote_port delete request>tls delete user_id delete duration delete resp_headers delete }

I don't have time to look properly right now, but these look suspect to me...

nagmat84 commented 2 years ago

If I interpret this Nginx config correctly, this only affects the content of the log. So it should not be the reason.

But you are running PHP FPM. Please try to restart the FPM daemon, i.e. depending on your system it is something like systemctl restart php-fpm-8.0.

FPM caches pre-compiled PHP code and depending on your FPM settings it may or may not invalidate the cache upon changing the original PHP files.

d7415 commented 2 years ago

If I interpret this Nginx config

Caddy, not nginx, but yes it looks like you're right about it referring to the logs.

cnkmmk commented 2 years ago

Sorry, everyone, I make a mistake. I can not change the php.ini. when changed, I can upload.