getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.31k stars 168 forks source link

Can't rename slugs or move folders inside docker container #1873

Closed florianporada closed 5 years ago

florianporada commented 5 years ago

Describe the bug When i'm trying to rename folders or the URL of the page I get the following error:

code: 2
exception: "Whoops\Exception\ErrorException"
file: "kirby/src/Toolkit/Dir.php"
line: 274
message: "rename(): The first argument to copy() function cannot be a directory"
route: "pages/([a-zA-Z0-9\.\-_%= \+\@\(\)]+)/slug"
status: "error"

This only happens if the content folder is copied into the image during the build. COPY --from=builder /usr/src/app/content /var/www/html/content <-- in this case a multi stage build. If the content directory is mounted via volume this error will disappear.

The docker image I am using is based on php:7.2-apache I tried things like giving the DocumentRoot and /tmp 777 rights but the error is still there. e.g.

RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 777 /var/www/html
RUN chmod -R 777 /tmp

Not sure if it's a docker related problem or kirby related only. Maybe one of you have an solution for this.

To Reproduce Steps to reproduce the behavior:

  1. Create a docker image with the starterkit (no volumes, not mountpoints)
  2. Try to alter the URL or the order of the pages
  3. See error

Kirby Version 3.1.4

Console output

code: 2
exception: "Whoops\Exception\ErrorException"
file: "kirby/src/Toolkit/Dir.php"
line: 274
message: "rename(): The first argument to copy() function cannot be a directory"
route: "pages/([a-zA-Z0-9\.\-_%= \+\@\(\)]+)/slug"
status: "error"

Desktop:

florianporada commented 5 years ago

For anyone who is interested. I solved the problem by altering the move function in /src/Toolkit/Dir.php (https://github.com/getkirby/kirby/blob/644fd2b8f7c132562ebbe939ffaf4e0ca768c72c/src/Toolkit/Dir.php#L283)

to

return empty(shell_exec('mv ' . $old . ' ' . $new));

Will do some testing. Closing this issue for now.