mayflower / PHP_CodeBrowser

Generates a browsable representation of PHP code where sections with violations found by quality assurance tools such as PHP_CodeSniffer or PHPMD are highlighted.
http://www.mayflower.de
BSD 3-Clause "New" or "Revised" License
135 stars 31 forks source link

PHP Warning: DOMDocument::loadHTML(): Validation failed: no DTD found ! #16

Closed lukearmstrong closed 10 years ago

lukearmstrong commented 12 years ago

I followed the guide at http://jenkins-php.org/ and am getting this error. It still seems to work though, as the Code Browser link in Jenkins works.

phpcb:
     [exec] PHP Warning:  DOMDocument::loadHTML(): Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !detected an error in element content in Entity, line: 2 in /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php on line 272

     [exec] PHP Stack trace:
     [exec] PHP   1. {main}() /usr/bin/phpcb:0
     [exec] PHP   2. CbCLIController::main() /usr/bin/phpcb:55
     [exec] PHP   3. CbCLIController->run() /usr/share/pear/PHP_CodeBrowser/CLIController.php:409
     [exec] PHP   4. CbViewReview->generate() /usr/share/pear/PHP_CodeBrowser/CLIController.php:326
     [exec] PHP   5. CbViewReview->_formatSourceCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:137
     [exec] PHP   6. CbViewReview->_highlightCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:165
     [exec] Warning: DOMDocument::loadHTML(): Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !detected an error in element content in Entity, line: 2 in /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php on line 272
     [exec] PHP   7. CbViewReview->_highlightPhpCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:364

     [exec] PHP   8. DOMDocument->loadHTML() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:272
     [exec] Call Stack:
     [exec]     0.0002     231096   1. {main}() /usr/bin/phpcb:0
     [exec]     0.0045     769128   2. CbCLIController::main() /usr/bin/phpcb:55
     [exec]     0.0085     936816   3. CbCLIController->run() /usr/share/pear/PHP_CodeBrowser/CLIController.php:409
     [exec]    20.8438    2973640   4. CbViewReview->generate() /usr/share/pear/PHP_CodeBrowser/CLIController.php:326
     [exec]    20.8454    3381048   5. CbViewReview->_formatSourceCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:137
     [exec]    20.8454    3381048   6. CbViewReview->_highlightCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:165
     [exec]    20.8463    3419792   7. CbViewReview->_highlightPhpCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:364
     [exec]    20.8542    3794560   8. DOMDocument->loadHTML() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:272

BUILD SUCCESSFUL
Total time: 28 seconds

I am attempting to run it on fuel/fuel using this version of PHP_CodeBrowser

Installed packages, channel pear.phpqatools.org:
================================================
Package         Version State
PHP_CodeBrowser 1.0.3   stable
xmontana commented 11 years ago

I have a symilar error in jenkins-php with Symfony2 project:

phpcb: [exec] PHP Warning: DOMDocument::loadHTML(): Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Invalid char in CDATA 0xC in Entity, line: 1 in /usr/share/php/PHP_CodeBrowser/View/ViewReview.php on line 410 [exec] PHP Stack trace: [exec] PHP 1. {main}() /usr/bin/phpcb:0 [exec] PHP 2. CbCLIController::main() /usr/bin/phpcb:56 [exec] PHP 3. CbCLIController->run() /usr/share/php/PHP_CodeBrowser/CLIController.php:409 [exec] PHP 4. CbViewReview->generate() /usr/share/php/PHP_CodeBrowser/CLIController.php:326 [exec] PHP 5. CbViewReview->_formatSourceCode() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:137 [exec] PHP 6. CbViewReview->_highlightCode() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:165 [exec] PHP 7. DOMDocument->loadHTML() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:410 [exec] PHP Warning: DOMDocument::loadHTML(): Invalid char in CDATA 0xB in Entity, line: 1 in /usr/share/php/PHP_CodeBrowser/View/ViewReview.php on line 410 [exec] PHP Stack trace: [exec] PHP 1. {main}() /usr/bin/phpcb:0 [exec] PHP 2. CbCLIController::main() /usr/bin/phpcb:56 [exec] PHP 3. CbCLIController->run() /usr/share/php/PHP_CodeBrowser/CLIController.php:409 [exec] PHP 4. CbViewReview->generate() /usr/share/php/PHP_CodeBrowser/CLIController.php:326 [exec] PHP 5. CbViewReview->_formatSourceCode() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:137 [exec] PHP 6. CbViewReview->_highlightCode() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:165 [exec] PHP 7. DOMDocument->loadHTML() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:410 [exec] PHP Warning: DOMDocument::loadHTML(): Invalid char in CDATA 0xC in Entity, line: 1 in /usr/share/php/PHP_CodeBrowser/View/ViewReview.php on line 410 [exec] PHP Stack trace: [exec] PHP 1. {main}() /usr/bin/phpcb:0 [exec] PHP 2. CbCLIController::main() /usr/bin/phpcb:56 [exec] PHP 3. CbCLIController->run() /usr/share/php/PHP_CodeBrowser/CLIController.php:409 [exec] PHP 4. CbViewReview->generate() /usr/share/php/PHP_CodeBrowser/CLIController.php:326 [exec] PHP 5. CbViewReview->_formatSourceCode() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:137 [exec] PHP 6. CbViewReview->_highlightCode() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:165 [exec] PHP 7. DOMDocument->loadHTML() /usr/share/php/PHP_CodeBrowser/View/ViewReview.php:410

ShurikAg commented 11 years ago

Any resolution on this one?

FreddieK commented 11 years ago

Also experiencing this issue...

voidus commented 11 years ago

I'll look into it in the next days.

FreddieK commented 11 years ago

Doing some dirty debugging, I printed the filename in _highlightCode before the loadHTML call, which for me displayed following:

/Users/Shared/Jenkins/Home/jobs/test/workspace/build/api/css/bootstrap.min.css PHP Warning: DOMDocument::loadHTML(): Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Invalid char in CDATA 0xC in Entity, line: 1 in /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php on line 410 [exec] PHP Stack trace: [exec] PHP 1. {main}() /Users/freddiekarlbom/pear/bin/phpcb:0 [exec] PHP 2. CbCLIController::main() /Users/freddiekarlbom/pear/bin/phpcb:56 [exec] PHP 3. CbCLIController->run() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/CLIController.php:409 [exec] PHP 4. CbViewReview->generate() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/CLIController.php:326 [exec] PHP 5. CbViewReview->_formatSourceCode() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:137 [exec] PHP 6. CbViewReview->_highlightCode() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:165 [exec] PHP 7. DOMDocument->loadHTML() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:410 [exec] PHP Warning: DOMDocument::loadHTML(): Invalid char in CDATA 0xB in Entity, line: 1 in /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php on line 410 [exec] PHP Stack trace: [exec] PHP 1. {main}() /Users/freddiekarlbom/pear/bin/phpcb:0 [exec] PHP 2. CbCLIController::main() /Users/freddiekarlbom/pear/bin/phpcb:56 [exec] PHP 3. CbCLIController->run() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/CLIController.php:409 [exec] PHP 4. CbViewReview->generate() /Users/freddiekarlbom/Users/Shared/Jenkins/Home/jobs/test/workspace/build/api/css/jquery.iviewer.css/Users/Shared/Jenkins/Home/jobs/test/workspace/bu/pear/share/pear/PHP_CodeBrowser/CLIController.php:326 [exec] PHP 5. CbViewReview->_formatSourceCode() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:137 [exec] PHP 6. CbViewReview->_highlightCode() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:165 [exec] PHP 7. DOMDocument->loadHTML() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:410 [exec] PHP Warning: DOMDocument::loadHTML(): Invalid char in CDATA 0xC in Entity, line: 1 in /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php on line 410 [exec] PHP Stack trace: [exec] PHP 1. {main}() /Users/freddiekarlbom/pear/bin/phpcb:0 [exec] PHP 2. CbCLIController::main() /Users/freddiekarlbom/pear/bin/phpcb:56 [exec] PHP 3. CbCLIController->run() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/CLIController.php:409 [exec] PHP 4. CbViewReview->generate() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/CLIController.php:326 [exec] PHP 5. CbViewReview->_formatSourceCode() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:137 [exec] PHP 6. CbViewReview->_highlightCode() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:165 [exec] PHP 7. DOMDocument->loadHTML() /Users/freddiekarlbom/pear/share/pear/PHP_CodeBrowser/View/ViewReview.php:410 [exec] ild/api/css/prettify.css/Users/Shared/Jenkins/Home/jobs/test/workspace/build/api/css/template.css

Since it seems to be part of api generation, I guess it might be a problem related to the phpDocumentor installation? I use the latest phpdocumentor2 (http://www.phpdoc.org/) installation, since I need it to work with php 5.3.

voidus commented 11 years ago

Is it possible that your files are not in latin1 or UTF-8?

voidus commented 11 years ago

I cloned fuel/fuel and tried phpcb on it, there were no errors. Do you have any idea how I could reproduce that?

Another thing worth trying: go to src/ViewReview.php and change the following lines (line numbers refer to 1.0.3) to include the 'u' parameter in the regex.

Around 401:

$sourceCode = preg_replace(
    '/^.*$/m', '<li>$0</li>',
    htmlentities($sourceCode)
);

change to

$sourceCode = preg_replace(
    '/^.*$/mu', '<li>$0</li>',
    htmlentities($sourceCode)
);

And right below, on line 405

$sourceCode = preg_replace('/ /', '&nbsp;', $sourceCode);

to

$sourceCode = preg_replace('/ /u', '&nbsp;', $sourceCode);
FreddieK commented 11 years ago

Adding the u-flag to the regex didn't change anything in the output.

Running

find . -type f -exec file --mime {} \; | grep -v "charset=utf-8\|charset=us-ascii"

lists many files with charset binary, among them image files, .css, .ttf, .zip and .mysql files.

When excluding binary charset as well, the command lists

./build/api/js/prettify/lang-apollo.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-go.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-lua.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-ml.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-scala.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-sql.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-tex.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-vb.js: text/plain; charset=unknown-8bit
./build/api/js/prettify/lang-vhdl.js: text/plain; charset=iso-8859-1
./build/api/js/prettify/lang-wiki.js: text/plain; charset=iso-8859-1

where ./build/api/js/prettify/lang-vb.js: text/plain; charset=unknown-8bit sticks out.

For me at least, it seems the problem might be related to the project structure, as the source by default was the same as the basedir, where documentation was generated (based on this tutorial for setting it up together with CI: http://blog.famakinwa.net/content/getting-codeigniter-phpunit-and-jenkins-working-together ). When configuring the phpcb --source so it doesn't read any of the files with other encoding than utf-8 and us-ascii ( --source ${basedir}/application instead of ${basedir} in the build-file) the error goes away.

voidus commented 11 years ago

Could you just exclude "lang-vb.js"? Codebrowser tries to detect the encoding, maybe it fails in a weird way here.

TheDevilOnLine commented 11 years ago

+1

phpcb:
     [exec] PHP Warning:  DOMDocument::loadHTML(): Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Validation failed: no DTD found !Invalid char in CDATA 0x1B in Entity, line: 2 in /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php on line 272
     [exec] PHP Stack trace:
     [exec] PHP   1. {main}() /usr/bin/phpcb:0
     [exec] PHP   2. CbCLIController::main() /usr/bin/phpcb:56
     [exec] PHP   3. CbCLIController->run() /usr/share/pear/PHP_CodeBrowser/CLIController.php:409
     [exec] PHP   4. CbViewReview->generate() /usr/share/pear/PHP_CodeBrowser/CLIController.php:326
     [exec] PHP   5. CbViewReview->_formatSourceCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:137
     [exec] PHP   6. CbViewReview->_highlightCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:165
     [exec] PHP   7. CbViewReview->_highlightPhpCode() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:364
     [exec] PHP   8. DOMDocument->loadHTML() /usr/share/pear/PHP_CodeBrowser/View/ViewReview.php:272
m1ket commented 11 years ago

I'm currently experiencing the same issues as highlighted above. Does anyone have a solution?

triplepoint commented 11 years ago

can verify this issue is still relevant as of dev-master#93318ce

globin commented 10 years ago

Should be fixed in #27

jcalonso commented 8 years ago

I'm getting this error on version 1.1.2 is this a regression?

calbrecht commented 8 years ago

Could you try this with the branch above, and report back please?

jcalonso commented 8 years ago

Hi again, the branch works fine and version 1.1.2 now works too, I cannot replicate the bug after downgrading to 1.1.1 and clearing vendor folder.

The steps where the following:

  1. I was using: "mayflower/php-codebrowser": "~1.1"
  2. Then I did composer update and got "1.1.2"
  3. After this my local and CI server started failing because of the error above.

After downgrading to version 1.1.1 everything worked again.

Probably was an isolated problem, let me know if you need any more info.

raponiwalter commented 8 years ago

Same issue here. Upgraded to 1.1.2 and got the error.A Downgrade resolved the problem

sherifadel-msft commented 7 years ago

Guys, i made a downgrade, and the issue still persists, any clue on what i'm missing ?