Powered by MediaWiki
Personal tools

Debugging

From B2evolution

Jump to: navigation, search

Contents

[edit] Enable Debuglog

To have a Debuglog with a load of information on the bottom of each page, set

$debug = 1;

in /conf/_advanced.php.

[edit] Blank pages

Blank pages or sudden script abortion often mean that there's a fatal error during the PHP script execution and the website/server is configured to not display them.

A cause for this might be a parse error or the exhaustion of the memory limit).

You can try to look into the server's error log or add the following code to /conf/_basic_config.php (/conf/_config.php before b2evo 1.8):

ini_set( 'error_reporting', E_ALL ); /* report all errors */
ini_set( 'display_errors', 'on' ); /* display them on the page */

Add this after the opening "<?php" tag at the beginning of the page.

Note that this won't help, if you have a parse error in the config file you're editing itself, because PHP cannot execute the statements that change the reporting..

[edit] phpinfo

Often additional information may be useful/required.

Therefor you can setup a simple file in your web root directory like so:

<?php
phpinfo();
?>

Save this as p.php and give the URL to that file to the developer that asks for it or mention it in your bug report.

E.g., you can search on the resulting page for "safe_mode" to see if your installation is setup like so.

[edit] Permissions

If you have file permission problems, try the following script. Upload it into your "blogs" directory, where "media" is and call it from a browser. It will display a recursive list of the subdirectories in "media" and display info about the permissions that apply to each directory (including and especially user/group permissions).

Code: Display permissions and owner/group of directories recursively
<?php

$dir = dirname(__FILE__).'/media/';
#$dir = '';

echo 'Current script owner (irrelevant): '.get_current_user();
echo "<br />\n";

$processUser = posix_getpwuid(posix_geteuid());
echo 'Process user:'.$processUser['name'];
echo "<br />\n";

echo '<h1>Dirs:</h1>';
?>

<p>
Effective perms are <strong>highlighted/bold</strong>.
<br />
<span style="color:green">Green</span> user and groupnames can write.<br />
<span style="color:brown">Brown</span> user and groupnames can read.<br />
<span style="color:red">Red</span> user and groupnames cannot read/write.<br />
</p>


<?php

echo '<ul>';
print_dir_owners($dir);
echo '</ul>';

function print_dir_owners($dir)
{
	$uid = fileowner( $dir );
	$gid = filegroup( $dir );

	if( function_exists('posix_getpwuid') )
	{
		$user = posix_getpwuid($uid);
		$user = $user['name'];
		$group = posix_getpwuid($gid);
		$group = $group['name'];
	}
	else
	{
		$user = '#'.$uid;
		$group = '#'.$gid;
	}

	$perms = substr( sprintf('%o', fileperms($dir)), -3 );

	echo '<li>'.$dir.":<br />\n";

	for( $i = 0; $i < strlen($perms); $i++ )
	{
		$highlight = false;
		switch($i)
		{
			case 0:
				if( $uid == posix_geteuid() )
					$highlight = true;
				break;
			case 1:
				if( $gid == posix_geteuid() )
					$highlight = true;
				break;
			case 2:
				$highlight = true;
				break;
		}
		if( $highlight )
			echo '<strong>'.$perms{$i}.'</strong>';
		else
			echo $perms{$i};
	}
	echo ' / ';

	echo '<span style="color:';
	if( $perms{0} < 4 )
		echo 'red';
	elseif($perms{0} < 6)
		echo 'brown';
	else
		echo 'green';
	echo '">'.$user.'</span>';

	echo '/<span style="color:';
	if( $perms{1} < 4 )
		echo 'red';
	elseif($perms{1} < 6)
		echo 'brown';
	else
		echo 'green';
	echo '">'.$group.'</span>';

	if( ($dh = dir($dir)) !== false )
	{
		echo '<ul>';
		while( $entry = $dh->read() )
		{
			if( $entry == '.' || $entry == '..' )
				continue;

			if( is_dir($dir.$entry) )
			{
				print_dir_owners($dir.$entry.'/');
			}
		}
		echo '</ul>';
	}

	echo '</li>';
}


?>