Skip to content

Commit 878cb1c

Browse files
committed
phpinfo HTML Output: Make module title names clickable and link to the URL fragment
Each section of `phpinfo` is titled with an `<h2><a name="module_NAME">NAME</a></h2>` tag. While the `name=module_NAME` attribute allows linking to that section using a URL fragment (e.g `info.php#module_NAME`), it lacks discoverability because the `<a>` tag does not contain an `href` attribute. This is also highlighted in accessibility scans (in Firefox for instance). This adds a link to the `<a>` tag that links to the URL fragment, fixing the accessibility remark and improving the discoverability of the clickable section titles. Also contains minor CSS changes to account for the dark theme CSS.
1 parent 296f764 commit 878cb1c

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

ext/phar/tests/phpinfo_004.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ phpinfo(INFO_MODULES);
2525
===DONE===
2626
--EXPECTF--
2727
%a
28-
<h2><a name="module_phar">Phar</a></h2>
28+
<h2><a name="module_phar" href="#module_phar">Phar</a></h2>
2929
<table>
3030
<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
3131
<tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
@@ -47,7 +47,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar full
4747
<tr><td class="e">phar.require_hash</td><td class="v">Off</td><td class="v">Off</td></tr>
4848
</table>
4949
%a
50-
<h2><a name="module_phar">Phar</a></h2>
50+
<h2><a name="module_phar" href="#module_phar">Phar</a></h2>
5151
<table>
5252
<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
5353
<tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>

ext/standard/css.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ PHPAPI ZEND_COLD void php_info_print_css(void) /* {{{ */
3131
PUTS("th {position: sticky; top: 0; background: inherit;}\n");
3232
PUTS("h1 {font-size: 150%;}\n");
3333
PUTS("h2 {font-size: 125%;}\n");
34+
PUTS("h2 a:link, h2 a:visited{color: inherit; background: inherit;}\n");
3435
PUTS(".p {text-align: left;}\n");
3536
PUTS(".e {background-color: #ccf; width: 300px; font-weight: bold;}\n");
3637
PUTS(".h {background-color: #99c; font-weight: bold;}\n");

ext/standard/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ PHPAPI ZEND_COLD void php_info_print_module(zend_module_entry *zend_module) /* {
137137
zend_string *url_name = php_url_encode(zend_module->name, strlen(zend_module->name));
138138

139139
zend_str_tolower(ZSTR_VAL(url_name), ZSTR_LEN(url_name));
140-
php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", ZSTR_VAL(url_name), zend_module->name);
140+
php_info_printf("<h2><a name=\"module_%s\" href=\"#module_%s\">%s</a></h2>\n", ZSTR_VAL(url_name), ZSTR_VAL(url_name), zend_module->name);
141141

142142
efree(url_name);
143143
} else {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
phpinfo() with clickable anchor tags
3+
--DESCRIPTION--
4+
This tests for the HTML anchor tags presence in phpinfo() outputs.
5+
The --POST-- section is used to force using CGI SAPI instead of the
6+
default CLI SAPI.
7+
--POST--
8+
a=b
9+
--FILE--
10+
<?php
11+
phpinfo();
12+
?>
13+
--EXPECTF--
14+
%a
15+
<h2><a name="module_core" href="#module_core">Core</a></h2>
16+
%a

0 commit comments

Comments
 (0)