Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hard coded absolute path for symbolic links in html/public/cache/ js and css files? #1220

Closed
poVoq opened this issue Jul 20, 2023 · 9 comments
Assignees
Milestone

Comments

@poVoq
Copy link

poVoq commented Jul 20, 2023

It seems like Movim creates symbolic links for the .js and .css files in the /html/public/cache folder and at least in the Docker images these appear to result in a hard coded absolute path at /var/www/html/app/...

While this works inside the docker container, this breaks when trying to serve these files from an external Nginx where these files are at a different absolute path.

It appears that the official docker compose script gets around this by including an additional Nginx that forces these files inside to the same /var/www/html/app/... location, but otherwise this additional Nginx seems completely redundant.

I think the proper solution would be to make these symbolic links relative, something like ../../apps/...

@poVoq
Copy link
Author

poVoq commented Jul 21, 2023

Removing the symlinks results in the following error being displayed in the browser:

Warning
: symlink(): Permission denied in
/var/www/html/src/Movim/Widget/Base.php
on line
246

But apparently these cache files get rebuilt on a restart of the daemon / container.

I suspect that the issue is with DOCUMENT_ROOT being used to determine the absolute paths for these symlinks and as this is done inside the container the /var/www/html/app/... path is used.

See: https://yagudaev.com/posts/resolving-php-relative-path-problem/

@poVoq
Copy link
Author

poVoq commented Jul 21, 2023

The likely culprit is this:

define('WIDGETS_PATH', DOCUMENT_ROOT . '/app/widgets/');

As WIDGETS_PATH is used to construct the symlink path at the location mentioned above.

@poVoq
Copy link
Author

poVoq commented Jul 21, 2023

Replacing the above line in Bootstrap.php with a relative path seems to work at first glance:

define('WIDGETS_PATH', '../../app/widgets/');

But I am probably overlooking something.

Edit: Yeah that breaks it pretty horribly after logging in.

@poVoq
Copy link
Author

poVoq commented Jul 21, 2023

Changing this line:

https://github.com/movim/movim/blob/4e0c6f2f042d580b627fc39505cdd0bc2f1a6d13/src/Movim/Widget/Base.php#L241C13-L241C13

to

$local = '../../app/widgets/' . get_class($this) . '/' . $filename;

Seems to work and not have an immediate negative effect.

@edhelas edhelas self-assigned this Jul 21, 2023
@edhelas edhelas added this to the 0.22.3 milestone Jul 21, 2023
@poVoq

This comment was marked as off-topic.

@edhelas
Copy link
Member

edhelas commented Jul 22, 2023

I made the change, still don't get why you need it in Docker, but anyway

@poVoq
Copy link
Author

poVoq commented Jul 22, 2023

Thanks!

This is a peculiarity with the php docker setup. From the inside of the container these files are at /var/www/html and for the daemon and the php-fpm process they appear like that, but the actual serving of the static files is not done in the same container, but rather by the host Nginx (or a separate Nginx container), which usually has a totally different file structure and thus these static files are very likely not at /var/www/html/.

I think this theoretically greatly simplifies the Docker setup and I'll open an issue on the movim_docker repo for it.

@edhelas
Copy link
Member

edhelas commented Jul 22, 2023

Please do

@edhelas
Copy link
Member

edhelas commented Jul 22, 2023

Everything seems to work fine except that these strange things in the admin settings appear:

image

Might be unrelated though.

See a6fac66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants