PHP error 'Undefined index'

Post Reply
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Hi,

I've recently started using Bludit on two development machines, running Windows 7, PHP 5.6.16 and Apache 2.4.7. The output of phpinfo() is virtually identical between the two systems, but Bludit will only run one of them. The other throws an error:

Code: Select all

Notice: Undefined index: language-data in C:\webroot\bl-kernel\dblanguage.class.php on line 32
Please check your theme configuration
I've tried fresh installs of Bludit 1.5.2 on both systems, but the problem one won't even get to the install page. What can I do to troubleshoot this issue?

Otherwise, Bludit is great. Exactly what I was looking for, and I'm really enjoying developing with it.

Cheers,
Jon
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Hi,
seem you select a theme on your configuration and this themes doesn't exist anymore ? I mean the files of the themes.
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Hi,

I don't think it's a theme problem. Even with a fresh install of Bludit, the same setup (identical files) will work on one system, but not the other.

Cheers,
Jon
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

I see..
Could you make some changes to see some variables on your system, I think there are some problem with Windows and some function on php.

In the file /bl-kernel/boot/site.php add this on the line 23.

Code: Select all

// Add this lines
var_dump(PATH_THEMES);
var_dump($Site->theme());
var_dump(DS);
var_dump(realpath(PATH_THEMES.$Site->theme().DS.'index.php'));
exit;

// Theme HTML
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'index.php') ) {
	include(PATH_THEMES.$Site->theme().DS.'index.php');
}
else {
	$Language->p('Please check your theme configuration');
}
Thanks
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Thanks. I will try this later today and report back.
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

The output I get from the var_dump() lines is as follows:

Code: Select all

string(33) "C:\webroot\bludit.test\bl-themes\"
string(3) "log"
string(1) "\"
string(46) "C:\webroot\bludit.test\bl-themes\log\index.php"
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

I don't see any problem, this path and files exists ? C:\webroot\bludit.test\bl-themes\log\index.php ?

This output is from the Bludit installation who doens't works ?
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Yes, the files exist. It's not an issue with the Bludit install. I can move the same files between the two systems and I get the same output from the modified script.

I'm feeling the problem is related to a server misconfiguration, but I don't know how to find it.
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

I've found that, on the problem system, the call to Sanitize::pathFile() on line 17 of db-kernel/dblanguage.class.php is returning bool(false). Given that there is no else statement for the if that checks this value, the language database never gets loaded.

Edit:
Sanitize::pathFile() uses realPath(), which, on Windows, will correct the case of the path, as well as resolving symbolic links and other path components. On the problem system, the constant PATH_LANGUAGES is all lowercase, whereas the actual path has capitals in it. When this is passed to Sanitize::pathFile(), it is compared against the 'real' version of itself, and since the case doesn't match, the function returns false (to prevent directory traversal exploits).

You're right that it's a Windows-only problem – the actual cause is to do with how I've defined a symbolic link which tells Apache where to serve files from, but I'm not sure it'll be possible to check for this error without causing issues for Unix systems.

I'll just fix my symbolic link for now.
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Try disable this constant, CHECK_SYMBOLIC_LINKS, put it on FALSE.

/bl-kernel/boot/init.php
Post Reply