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

Assets are loaded using the full system path, rather than relative web path #287

Closed
joachimtingvold opened this issue Apr 5, 2020 · 3 comments

Comments

@joachimtingvold
Copy link

Hi,

Just upgraded from 6.0.0-beta-something to latest RC. Also tested with fresh install, both produced the result below.

subfolder variable is set to the full path of the files on the underlying system, and not relative to the web-root, causing assets to have wrong URL;

<!DOCTYPE html>
<html xml:lang="en-US" lang="en-US"  dir="ltr">

    <head data-headertemplate="header.twig">
        		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet/less" href="/srv/vhosts/some.domain.foo/assets/themes/global.less" type="text/css" id="cssmain" />
		<script src="/srv/vhosts/some.domain.foo/assets/js/polyfills.js" type="text/javascript"></script>
		<script src="/srv/vhosts/some.domain.foo/assets/js/less.min.js" type="text/javascript"></script>
		<link rel="stylesheet" href="/srv/vhosts/some.domain.foo/assets/themes/default/global.css" type="text/css" id="csstheme" />
		<link rel="stylesheet" href="/srv/vhosts/some.domain.foo/assets/vendor/jquery/jquery-ui.min.css" type="text/css" />
		<link rel="shortcut icon" href="/srv/vhosts/some.domain.foo/assets/images/themes/default/Favicon.ico" type="image/vnd.microsoft.icon" />
		<link rel="icon" href="/srv/vhosts/some.domain.foo/assets/images/themes/default/Introduction.png" type="image/png" />

		<script src="/srv/vhosts/some.domain.foo/assets/vendor/jquery/jquery-3.4.1.min.js"></script>
		<script src="/srv/vhosts/some.domain.foo/assets/vendor/jquery/jquery-ui.min.js"></script>

phpPgAdmin6 is served on domain some.domain.foo directly in it's root, so all of the above should start with ./ or /, rather than /srv/vhosts/some.domain.foo/.

@joachimtingvold joachimtingvold changed the title Assets are loaded using the full path, rather than relative path Assets are loaded using the full system path, rather than relative web path Apr 5, 2020
@joachimtingvold
Copy link
Author

First hunch is that it's something wrong with the logic in src/classes/ContainerUtils.php. The variables set is as follows;

<script>
window.stateObj = {
	dir: 'ltr',
	in_test: '0',
	reload: '',
	method: 'GET',
	subfolder:'/srv/vhosts/some.domain.foo',
	path:"/srv/vhosts/some.domain.foo//",
	query_string:"",
	strconfdropcred:"",
};
</script>

The relevant parts of the Apache vhost-config;

<VirtualHost *:443>
    […]
	DocumentRoot /srv/vhosts/some.domain.foo/

	<Directory "/srv/vhosts/some.domain.foo/">
		DirectoryIndex index.php
		AllowOverride All

		Options +FollowSymLinks
		SSLRequireSSL
		Require all granted
	</Directory>
</VirtualHost>

@ffflabs
Copy link
Collaborator

ffflabs commented Apr 28, 2020

Damn, I'm sorry, I have neglected this project in last month of so. I haven't ever tried on Apache and I guess the vhost config as reccomended by Slim Framework may have changed.

@ffflabs
Copy link
Collaborator

ffflabs commented May 25, 2020

Ok I believe I have figured this out. The problem is (as it has been since it begun) the attempt to figure out the subfolder.

I was currently relying on $_SERVER['DOCUMENT_ROOT'] so the subfolder would be defined as

 str_replace(<DOC ROOT>, '', <PROJECT_ROOT>)

Which means, if the document root for phppga vhost was /var/www/phppga and the project root was at /var/www/phppga/project it sould mean the subfolder is project

however this is too brittle. Some webservers won't populate the DOCUMENT_ROOT, and in other scenarios any kind of symlinking rules (think capistrano deploys) will break the above.

This behavior was introduced by #28 and all this time I tried to infer the subdirectory. I won't anymore. From now on if you want to run in a subfolder that must be configured explicitly:

@ffflabs ffflabs closed this as completed May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants