w3c / i18n-checker

W3C's i18n checker
https://validator.w3.org/i18n-checker/
Other
36 stars 17 forks source link

“PHP Fatal error: Uncaught Error: Call to undefined function ‘mb_internal_encoding()’” #48

Closed tripu closed 8 years ago

tripu commented 8 years ago

NB: I'm running PHP7, not PHP5 as stated in the docs. If that's the cause of the problem, apologies beforehand! (but I don't see how that could be; mb-internal-encoding exists in both versions).

When visiting http://localhost/i18n-checker/tests/ on my browser as explained in the docs, the Apache logs show this, and the page doesn't render:

PHP Warning:  fopen(../logs/i18n.log): failed to open stream: Permission denied in i18n-checker/lib/log4php/appenders/LoggerAppenderFile.php on line 77
PHP Fatal error:  Uncaught Error: Call to undefined function mb_internal_encoding() in i18n-checker/src/class.N11n.php:257\nStack trace:\n#0 i18n-checker/src/class.Checker.php(9): require_once()\n#1 i18n-checker/tests/index.php(10): require_once()\n#2 {main}\n  thrown in i18n-checker/src/class.N11n.php on line 257

Line 257 of src/class.N11n.php calls function mb-internal-encoding. The only definition I can find is in lib/phpQuery.php.

Possibly related? https://www.boonex.com/n/Fatal_error_Call_to_undefined_function_mb_internal_encoding_

r12a commented 8 years ago

Does your PHP initialisation load the mbstring extension?

tripu commented 8 years ago

Thanks. I installed the package php-mbstring, restarted Apache, and now the page shows this:

Is your page world ready?

Successfully parsed 190 tests from local test files. Character encoding HTML HTML5 XHTML(H) XHTML(X) XHTML11 1 rep_charset_no_in_doc

But these resources can't be found:

And there is still an error:

PHP Warning:  fopen(../logs/i18n.log): failed to open stream: Permission denied in i18n-checker/lib/log4php/appenders/LoggerAppenderFile.php on line 77
PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in i18n-checker/src/class.Net.php:151\nStack trace:\n#0 i18n-checker/src/class.Net.php(57): Net::fetchDocument('http://localhos...')\n#1 i18n-checker/src/class.Test.php(209): Net::getDocumentByUri('http://localhos...')\n#2 i18n-checker/tests/index.php(118): Test::startCheck('http://localhos...', false)\n#3 {main}\n  thrown in i18n-checker/src/class.Net.php on line 151

curl_init exists in PHP 5 and 7.

:confused:

r12a commented 8 years ago

But these resources can't be found:

http://localhost/i18n-checker/tests/style/base_ucn.css
http://localhost/i18n-checker/tests/scripts/mootools-1.3.2.js
http://localhost/i18n-checker/tests/images/w3c.png

That should now be fixed by https://github.com/w3c/i18n-checker/commit/e9ba65f0e0778fb8e5bbcf02576f3aadbf8d7bc7 As it's only for development use, i never reallly worried about styling etc for that page. I must admit that it looks pretty now though.

r12a commented 8 years ago

And there is still an error:

PHP Warning: fopen(../logs/i18n.log): failed to open stream: Permission denied in i18n-checker/lib/log4php/appenders/LoggerAppenderFile.php on line 77 PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in i18n-checker/src/class.Net.php:151\nStack trace:\n#0 i18n-checker/src/class.Net.php(57): Net::fetchDocument('http://localhos...')\n#1 i18n-checker/src/class.Test.php(209): Net::getDocumentByUri('http://localhos...')\n#2 i18n-checker/tests/index.php(118): Test::startCheck('http://localhos...', false)\n#3 {main}\n thrown in i18n-checker/src/class.Net.php on line 151

curl_init exists in PHP 5 and 7.

Do you have that extension enabled in your php.info file?

r12a commented 8 years ago

I added to the installation notes on the wiki:

You will also need the mbstring and curl extensions enabled.

tripu commented 8 years ago

Logo, CSS and JS are loading fine now, thanks.

I installed php-curl and the error now is:

PHP Warning:  fopen(../logs/i18n.log): failed to open stream: Permission denied in i18n-checker/lib/log4php/appenders/LoggerAppenderFile.php on line 77
PHP Notice:  Uninitialized string offset: 0 in i18n-checker/src/class.Checker.php on line 114
PHP Notice:  Uninitialized string offset: 0 in i18n-checker/src/class.Checker.php on line 118
PHP Notice:  Uninitialized string offset: 0 in i18n-checker/src/class.Checker.php on line 121
PHP Fatal error:  Uncaught Error: Class 'DOMDocument' not found in i18n-checker/lib/html5lib/TreeBuilder.php:150\nStack trace:\n#0 i18n-checker/lib/html5lib/Tokenizer.php(89): HTML5_TreeBuilder->__construct()\n#1 i18n-checker/lib/html5lib/Parser.php(20): HTML5_Tokenizer->__construct('', NULL)\n#2 i18n-checker/src/class.Parser.HTML5Lib.php(30): HTML5_Parser::parse('')\n#3 i18n-checker/src/class.Parser.php(104): ParserHTML5Lib->__construct(NULL, NULL)\n#4 i18n-checker/src/class.Checker.php(49): Parser::getParser(NULL, NULL)\n#5 i18n-checker/src/class.Test.php(215): Checker->checkDocument(NULL)\n#6 i18n-checker/tests/index.php(118): Test::startCheck('http://localhos...', false)\n#7 {main}\n  thrown in i18n-checker/lib/html5lib/TreeBuilder.php on line 150

And the table on the page looks broken and has just one cell (the one containing rep_charset_no_in_doc).

Any idea? (Now this might have to do with me running PHP 7 instead of 5.)

tripu commented 8 years ago

PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found […]

Fixed by installing php-xml too and restarting Apache.