We have a otherwise perfectly working site with "slasharguments" disabled. But I can not get mini-sites to work without enabling it. But if we enable "slasharguments", it breaks images, videos and other files.
What is the solution to this dilemma?
Here are details:
Moodle version 2.5 (latest I guess). OS is FreeBSD. (I don't have more details at hand, since I am not the Moodle admin nor the sysadmin. But can request anything.) If I upload a mini-site as it is, i.e. with "slasharguments" disabled, I get the "main" HTML displayed in the popup, but not the subpages, nor images. The "main" HTML has the URL https://example.com/pluginfile.php?file=%2F8406%2Fmod_resource%2Fcontent%2F3%2Ftemplate%2Ftemplate.html whereas the subpages have the format https://example.com/templatech1.html#x3-20001, i.e. no "pluginfile.php" part.
The behaviour is identical on a 2.7 site on the same system software.
The same exercise works perfectly on a Linux, Debian 7, as explained in the post "PDF and HTML from the same LaTeX source, a minimal example" https://moodle.org/mod/forum/discuss.php?d=276119 with slasharguments enabled.
Any tipps, advice, ... to the system administrators there?
Re: Connection between "slasharguments" and mini-sites?
I have requested the admins to keep "slasharguments" enabled. Going through the resources I realised that most of them, embedded pictures, file resources, ... work. The only thing I have found which does not work are files inside Folder resources. The error says, "Sorry, the requested file could not be found" and is linked to http://docs.moodle.org/27/en/error/moodle/filenotfound. The broken link is like
https://example.com/pluginfile.php/8413/mod_folder/content/0/Subfolder%20under%20Test/examples.pdf?forcedownload=1.
Could be a clue to something?
Re: Connection between "slasharguments" and mini-sites?
In the mean time developer level debugging is active. When it breaks in the subfolder case in the previous post, the message is:
===
Debug info:
Error code: filenotfound
Stack trace:
line 463 of /lib/setuplib.php: moodle_exception thrown
line 1957 of /lib/filelib.php: call to print_error()
line 4592 of /lib/filelib.php: call to send_file_not_found()
line 37 of /pluginfile.php: call to file_pluginfile()
===
Are we getting closer?
Re: Connection between "slasharguments" and mini-sites?
Hi Visvanath,
slasharguments is the key to preserve relative paths in linked resources: that's the reason why IMS and SCORM need it to work as expected and the same applies here.
That being said, have you already try with the Moodle Health Center available in http://hostname/path/to/moodle/admin/tool/health to check for issues in that instance?
You can start debugging the issue with hacking the pluginfile.php file by adding one line to see what the web stack returns to Moodle i.e. adding one line below the retrieving of the so called PATH_INFO data:
...
$relativepath = get_file_argument();
die($relativepath);
...
This hack will immediately return with the supposed relative path e.g. putting https://example.com/pluginfile.php/8413/mod_folder/content/0/examples.pdf?forcedownload=1 in your browser you should read /8413/mod_folder/content/0/examples.pdf, if everything is fine.
BYW, it seems not a plain 2.5 since the line 4592 is far from the length of the file in the latest 2.5 as well as in the first (.0) one.
HTH,
Matteo
Re: Connection between "slasharguments" and mini-sites?
That sounds promising! I sent an update to the admins involved. As I said earlier, I am doing it without sysadmin nor Moodle admin privileges!
BTW, we are continuing in the 2.7 version I mentioned at the beginning. This one is a test upgrade of the production server which is 2.5. (see the OP).
Will report the results tomorrow.
Re: Connection between "slasharguments" and mini-sites?
Could you also provide the exact version of the 2.7 test instance?
Just to have the opportunity to get more info about why it stops there.
Re: Connection between "slasharguments" and mini-sites?
_________________________________________
Moodle version: $githash = ‘29507f2’;
config.php:
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost =
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 1,
'dbport' => '',
'dbsocket' => '',
);
$CFG->wwwroot =
$CFG->dataroot =
$CFG->admin =
$CFG->directorypermissions = 0777;
$CFG->xsendfile = 'X-Sendfile'; // Apache {@see https://tn123.org/mod_xsendfile/}
$CFG->svgicons = true;
$CFG->directorypermissions = 0777;
@error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
@ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
$CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
$CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS!
$CFG->dblogerror = true;
$CFG->showcrondebugging = true;
___________________________________
PHP 5.5.13 running PHP-FPM for fastcgi
Apache/2.4.9 (FreeBSD) with mod_proxy_fastcgi for PHP,
vhost config for moodle:
ServerName
VirtualDocumentRoot /usr/local/www/%0
SetEnvIf ^Host$ ^(.*)$ HOST=$1
ProxyPassInterpolateEnv On
ProxyPassMatch ^/(.*)/$ fcgi://127.0.0.1:9000/usr/local/www/${HOST}/$1/index.php interpolate
SSLOptions +StdEnvVars
ProxyPass fcgi://127.0.0.1:9000/usr/local/www/${HOST} interpolate
Proxypassreverse fcgi://127.0.0.1:9000/usr/local/www/${HOST} interpolate
___________________________________
Re: Connection between "slasharguments" and mini-sites?
I have Moodle administrator access now. The slasharguments are activate and I am trying to solve the broken files in "Folder in Folder".
Anything in particular, e.g. in PHP info, I should look for?
Re: Connection between "slasharguments" and mini-sites?
It is the same thing with a file directly under the Folder resource. The link to the file 'examples with spaces in name.pdf' https://example.com/pluginfile.php/8413/mod_folder/content/0/examples%20with%20spaces%20in%20name.pdf?forcedownload=1 breaks.
I could solve _my_ problem by avoiding the space character. Is it only in this server or is there a major bug in 2.7.3?
Re: Connection between "slasharguments" and mini-sites?
Just had an idea (Oh, Boy! Here we go ....) ...
The file names actually come from the DB once a file is uploaded.
One can find all file names with spaces via:
select * from `mdl_files` where `filename` like "% %"
If one edited all those records replacing the space in filename with '_' then things should still be found, shouldn't they? Moodle uses contenthash and pathhash. Unless the spaces are in pathhash.
Any docs on pathhash?
'spirit of sharing', Ken
Re: Connection between "slasharguments" and mini-sites?
I will wait with "repairs" until I know the cause. As it is now, with slasharguments ON file and folder resources with blanks in their naimes fail. If I put it to OFF the mini-sites fail. It still could be the uncommon system software on FreeBSD. I can not remember having this on LAMP.
Re: Connection between "slasharguments" and mini-sites?
Oh, there's still issues cross platform that relates to this me thinks ... differences in Windows/MacOSX/Linux in what's legal for file names. A Windows PC person can name a file using '/' in the filename and stupid linux will accept it. Windows person doesn't realize a '/', while being a legal character in their OS, is a 'no-no' in Linux ... upon which their Moodle might be hosted.
What Moodle uploads should do is insert "_" to replace 'spaces' (those ugly %20's) in the file names. Of course, if one uploads a zip and the zip contains a bunch of those files then what.
Anyway .... it all marches on ... imperfections and all.
'spirit of sharing', Ken
Re: Connection between "slasharguments" and mini-sites?
Hi Ken,
here are some relative issues in the Tracker:
Regarding with your question about hashes:
- contenthash: https://github.com/moodle/moodle/blob/10ccdfb8cdbacf1c7313a623f9e82ecd36ba6cee/lib/filestorage/file_storage.php#L1634
- pathnamehash: https://github.com/moodle/moodle/blob/10ccdfb8cdbacf1c7313a623f9e82ecd36ba6cee/lib/filestorage/file_storage.php#L109
Changing the file name should be done with PHP scripting to be consistent with the Files API or, since the renaming is limited to this issue, by using a standard SHA-1 implementation regardless adopting the PHP and Files API way of doing.
HTH,
Matteo
Re: Connection between "slasharguments" and mini-sites?
You may be relieved to know that I am neither going to repair space characters in file names nor forbid special charaters in file names. This was my very last attempt: https://moodle.org/mod/forum/discuss.php?d=190958#p831105.
The cause lies deep in FastCGI, but out of bounds for me. (See my [CLOSED} post.)
Re: Connection between "slasharguments" and mini-sites?
Hi Visvanath,
looking at the configuration I'm seeing nice bits for performances : PHP FPM and X-Sendfile.
You could start disabling the X-Sendfile support to see if the "whitespaces" issue is not correctly managed under this configuration.
Have you tried my hack? You'll get what Moodle extracts as slash arguments - the so called PATH_INFO - and you can see if the issue is in the way Moodle extracts the slash arguments or in the way that web stack provide data to the Moodle instance. What you'll read is what it will be used to search for the file in the Moodle Pool.
Here we have sensitive parts to be separately investigated:
- the X-Sendfile;
- the PHP FPM;
Each of them IMHO must be reviewed starting with their configuration in the stack first and then with the Moodle support for them.
In the configurations picture you've wisely provided, I'd expect to read something like below:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/moodle/$1
to be sure that only PHP pages with optional slash arguments will be processed correctly by the PHP FPM stack. Now, I'm only reading how Virtual Hosting is supported.
HTH,
Matteo
Re: Connection between "slasharguments" and mini-sites? [CLOSED]
Thanks for the great hints! I've forwarded them to the system administrator of this particular machine. He is of the openion that this is not a problem of the environment, FreeBSD jails, per se, but a result of FastCGI. There are a couple of comments in this respect even on https://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm. "Without disabling the 'slash arguments', you may notice that the admin setup page is missing the images and css styling. However, if you turn off slash arguments, then other things won't work, so really someone ought to work out what is wrong here and fix it."
I'm not in a position nor inclined to follow up this matter any further. I adviced the sysadmin to disable slasharguments. I will find an alternative to the missing mini-sites capability.
So AFAIC the thread is closed. Thanks a lot for taking so much trouble on this issue. It is good to know that for non-trivial cases like this one the community can count on the developers!
Re: Connection between "slasharguments" and mini-sites? [CLOSED]
Hi Visvanath,
even if it is closed on your side, MDL-51554 could be relevant for your future envs , when based on mod_proxy_fcgi.
HTH,
Matteo