Skip to content

Modernised phpinfo HTML somewhat #156

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */
}

if (!sapi_module.phpinfo_as_text && flag & PHP_CREDITS_FULLPAGE) {
PUTS("</div></body></html>\n");
PUTS("</div>\n");
}
}
/* }}} */
Expand Down
7 changes: 4 additions & 3 deletions ext/standard/css.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ PHPAPI void php_info_print_css(TSRMLS_D) /* {{{ */
PUTS("pre {margin: 0px; font-family: monospace;}\n");
PUTS("a:link {color: #000099; text-decoration: none; background-color: #ffffff;}\n");
PUTS("a:hover {text-decoration: underline;}\n");
PUTS("table {border-collapse: collapse;}\n");
PUTS(".box {overflow: hidden;}\n");
PUTS("table, .box {border-collapse: collapse; width: 600px; border: none;}\n");
PUTS(".center {text-align: center;}\n");
PUTS(".center table { margin-left: auto; margin-right: auto; text-align: left;}\n");
PUTS(".center table, .box { margin-left: auto; margin-right: auto; text-align: left;}\n");
PUTS(".center th { text-align: center !important; }\n");
PUTS("td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}\n");
PUTS("td, th, .box { border: 1px solid #000000; font-size: 75%; vertical-align: baseline; padding: 3px;}\n");
PUTS("h1 {font-size: 150%;}\n");
PUTS("h2 {font-size: 125%;}\n");
PUTS(".p {text-align: left;}\n");
Expand Down
24 changes: 10 additions & 14 deletions ext/standard/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {
{
if (zend_module->info_func || zend_module->version) {
if (!sapi_module.phpinfo_as_text) {
php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
php_info_printf("<h2><a id=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
} else {
php_info_print_table_start();
php_info_print_table_header(1, zend_module->name);
Expand Down Expand Up @@ -624,14 +624,11 @@ PHPAPI char *php_get_uname(char mode)
*/
PHPAPI void php_print_info_htmlhead(TSRMLS_D)
{
php_info_print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
php_info_print("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
php_info_print("<head>\n");
php_info_print("<!doctype html>\n<meta charset=utf-8>");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • DOCTYPE is usually uppercase for bc, but html5 does not care either way.
  • Missing <html lang="en"> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just use <!doctype> because it looks nicer imo. I don't think it matters.

Also I don't think lang=en matters. If you mean the html tag, that can be omitted and is perfectly valid html (and for simple header pages like this, cleaner imo)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should drop html tag. Maybe it's allowed by the standard, but many tools would assume it's there, why make their lives harder?

php_info_print_style(TSRMLS_C);
php_info_print("<title>phpinfo()</title>");
php_info_print("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
php_info_print("</head>\n");
php_info_print("<body><div class=\"center\">\n");
php_info_print("<div class=\"center\">\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why body tag is dropped?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For file size optimization and scannability purposes, consider omitting optional tags.

http://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml?showone=Optional_tags#Optional_tags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I do this with all my HTML, it's much simpler, and doesn't really do that much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bojieli Neither reason is applicable here. What is applicable is writing tools that can easily read this information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really supposed to be machine-readable, that's the text format's job.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TazeTSchnitzel Maybe I'm the only one who thinks dropping the body tag is a terrible idea. I've voiced my opinion and that's all I can do. I do agree that the text-format is designed to be human readable, but that doesn't mean we should rape our HTML.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morrisonlevi rape? It's perfectly valid in HTML5. We aren't dealing with XHTML, here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear: I am all for updating the output, but I see absolutely no reason to approve this pull request. HTML5 give absolutely no benefit over what we already have. HTML5 is not even finalized.

My previous comment was a little harsh. I meant it that way because I feel strongly about this, but I would like to say I do not intend for it to be argumentative. I merely want to express my opinion without it being misunderstood.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does more than use HTML5. It uses tables less, removes some inline styling, etc, But you're right in that it adds almost nothing, so I'll close it.

}
/* }}} */

Expand Down Expand Up @@ -676,7 +673,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
the_time = time(NULL);
ta = php_localtime_r(&the_time, &tmbuf);

php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
php_info_print("<a href=\"http://www.php.net/\"><img src=\"");
if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) {
php_info_print(PHP_EGG_LOGO_DATA_URI "\" alt=\"PHP logo\" /></a>");
} else {
Expand Down Expand Up @@ -783,7 +780,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
/* Zend Engine */
php_info_print_box_start(0);
if (!sapi_module.phpinfo_as_text) {
php_info_print("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
php_info_print("<a href=\"http://www.zend.com/\"><img src=\"");
php_info_print(ZEND_LOGO_DATA_URI "\" alt=\"Zend logo\" /></a>\n");
}
php_info_print("This program makes use of the Zend Scripting Language Engine:");
Expand Down Expand Up @@ -919,15 +916,15 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
}

if (!sapi_module.phpinfo_as_text) {
php_info_print("</div></body></html>");
php_info_print("</div>");
}
}
/* }}} */

PHPAPI void php_info_print_table_start(void) /* {{{ */
{
if (!sapi_module.phpinfo_as_text) {
php_info_print("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
php_info_print("<table>\n");
} else {
php_info_print("\n");
}
Expand All @@ -945,14 +942,13 @@ PHPAPI void php_info_print_table_end(void) /* {{{ */

PHPAPI void php_info_print_box_start(int flag) /* {{{ */
{
php_info_print_table_start();
if (flag) {
if (!sapi_module.phpinfo_as_text) {
php_info_print("<tr class=\"h\"><td>\n");
php_info_print("<div class=\"h box\">\n");
}
} else {
if (!sapi_module.phpinfo_as_text) {
php_info_print("<tr class=\"v\"><td>\n");
php_info_print("<div class=\"v box\">\n");
} else {
php_info_print("\n");
}
Expand All @@ -963,7 +959,7 @@ PHPAPI void php_info_print_box_start(int flag) /* {{{ */
PHPAPI void php_info_print_box_end(void) /* {{{ */
{
if (!sapi_module.phpinfo_as_text) {
php_info_print("</td></tr>\n");
php_info_print("</div>\n");
}
php_info_print_table_end();
}
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/general_functions/phpcredits2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var_dump(phpcredits(CREDITS_GROUP));

?>
--EXPECTF--
<!DOCTYPE %a>%s</html>
<!doctype html>%a
bool(true)

Warning: phpcredits() expects parameter 1 to be long, array given in %sphpcredits2.php on line 4
Expand Down
1 change: 0 additions & 1 deletion ext/standard/tests/general_functions/phpinfo.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ DTrace Support => %s
Registered PHP Streams => %s
Registered Stream Socket Transports => %s
Registered Stream Filters => %s

%a
_______________________________________________________________________

Expand Down
12 changes: 6 additions & 6 deletions ext/standard/tests/general_functions/phpinfo2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ var_dump(phpinfo(INFO_LICENSE));

?>
--EXPECTF--
<!DOCTYPE %s>
%a</html>bool(true)
<!doctype html>
%abool(true)
--

Warning: phpinfo() expects parameter 1 to be long, array given in %sphpinfo2.php on line 5
NULL
--
<!DOCTYPE %s>
%a</html>bool(true)
<!doctype html>
%abool(true)
--
<!DOCTYPE %s>
%a</html>bool(true)
<!doctype html>
%abool(true)
103 changes: 103 additions & 0 deletions ext/standard/tests/streams/bug40459.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
--TEST--
bug 40459 - Test whether the constructor of the user-space stream wrapper is called when stream functions are called
--FILE--
<?php
// Test whether the constructor of the user-space stream wrapper is called when stream functions are called
class testwrapper {
private $constructorCalled = false;
function __construct() {
$this->constructorCalled = true;
}

function stream_open($path, $mode, $options, &$opened_path)
{
echo $this->constructorCalled ? 'yes' : 'no';
return true;
}

function url_stat($url, $flags)
{
echo $this->constructorCalled ? 'yes' : 'no';
return array();
}

function unlink($url)
{
echo $this->constructorCalled ? 'yes' : 'no';
}

function rename($from, $to)
{
echo $this->constructorCalled ? 'yes' : 'no';
}

function mkdir($dir, $mode, $options)
{
echo $this->constructorCalled ? 'yes' : 'no';
}

function rmdir($dir, $options)
{
echo $this->constructorCalled ? 'yes' : 'no';
}

function dir_opendir($url, $options)
{
echo $this->constructorCalled ? 'yes' : 'no';
return TRUE;
}
function stream_metadata()
{
echo $this->constructorCalled ? 'yes' : 'no';
return TRUE;
}
}

stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL);

echo 'stream_open: ';
fopen('test://test', 'r');
echo "\n";

echo 'url_stat: ';
stat('test://test');
echo "\n";

echo 'dir_opendir: ';
opendir('test://test');
echo "\n";

echo 'rmdir: ';
rmdir('test://test');
echo "\n";

echo 'mkdir: ';
mkdir('test://test');
echo "\n";

echo 'rename: ';
rename('test://test', 'test://test2');
echo "\n";

echo 'unlink: ';
unlink('test://test');
echo "\n";

echo 'touch: ';
touch('test://test', time());
echo "\n";



?>
==DONE==
--EXPECT--
stream_open: yes
url_stat: yes
dir_opendir: yes
rmdir: yes
mkdir: yes
rename: yes
unlink: yes
touch: yes
==DONE==
Loading