Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Starnut

Hi everyone,

I uploaded the Weltmeister editor to my server in order to allow my clients to build levels themselves. Strangely, it throws the following exception:

Uncaught TypeError: Object false has no method 'match' select-file-dropdown.js:67
wm.SelectFileDropdown.ig.Class.extend.showFiles select-file-dropdown.js:67
...

As I understand this, the editor fails to read the list of levels from the directory. The file structure is the exact same as offline (under MAMP, where it works just fine) so I have absolutely no clue why it fails to find the files. I even set all file permissions to 777 to make sure that's not an issue.

Anyone has encountered this problem or has an idea what may be at the root of this problem? Is it something about my php config I have to change?

Thanks,

Michel

1 decade ago by Starnut

So, I managed to figure it out myself:

I tracked down the problem to the file lib/weltmeister/api/browse.php where the call to glob() does not return an empty array, but one that contains the boolean false, which later breaks the JavaScript regexp call in showFiles():

$dirs = (array)glob( $dir.'*', GLOB_ONLYDIR );
$files = (array)glob( $dir.$find, GLOB_BRACE );

According to a comment in the php manual page for glob(), this function returns [false] instead of an empty array when no matching files were found, if "you have open_basedir set in php.ini to limit which files php can execute". There.

Since I'm on a shared server and have no access to changing open_basedir in php.ini, I came up with this workaround by replacing the lines in browse.php

foreach( $files as $i => $f ) {
	$files[$i] = substr( $f, $fileRootLength );
}
foreach( $dirs as $i => $d ) {
	$dirs[$i] = substr( $d, $fileRootLength );
}

with

foreach( $files as $i => $f ) {
	if ($f) {
		$files[$i] = substr( $f, $fileRootLength );
	} else {
		unset($files[$i]);
	}
}
foreach( $dirs as $i => $d ) {
	if ($d) {
		$dirs[$i] = substr( $d, $fileRootLength );
	} else {
		unset($dirs[$i]);
	}
}

I also check the directories since the same issue may occur here as well.

Hope this helps anyone else running into this issue.

Cheers,
Michel

1 decade ago by Starnut

Oh and BTW: It seems this issue relates to this PHP bug, which seems to've been fixed in late 2011:

https://bugs.php.net/bug.php?id=47358
Page 1 of 1
« first « previous next › last »