phpdox icon indicating copy to clipboard operation
phpdox copied to clipboard

Filename too long

Open aroly opened this issue 6 years ago • 1 comments

Hi there,

I'm trying to generate doc for a PHP framework, and I'm facing the following issue:

Oups... phpDox encountered a problem and has terminated!

It most likely means you've found a bug, so please file a report for this
and paste the following details and the stacktrace (if given) along:

PHP Version: 7.0.33-0ubuntu0.16.04.1 (Linux)
PHPDox Version: 0.8.2-dev
Exception: TheSeer\phpDox\Collector\ProjectException (Code: 4)
Location: /usr/share/php/TheSeer/phpDox/collector/project/Project.php (Line 256)

An error occured while saving the collected data: DOMDocument::save(/home/XXX/OCI-P/broadworks-connector/vendor/cwm/broadworks-connector/build/phpdox/xml/classes/CWM_BroadWorksConnector_Ocip_Models_SystemVoiceMessagingGroupGetVoicePortalMenusResponse18sp1ChangeCurrentIntroductionOrMessageOrReplyMenuKeys.xml): failed to open stream: File name too long

#0 /usr/share/php/TheSeer/phpDox/CLI.php(161): TheSeer\phpDox\Application->runCollector()
#1 /usr/bin/phpdox(50): TheSeer\phpDox\CLI->run()


ErrorException: E_WARNING 
Location: /usr/share/php/TheSeer/fDOMDocument/fDOMDocument.php (Line 238)

DOMDocument::save(/home/XXX/OCI-P/broadworks-connector/vendor/cwm/broadworks-connector/build/phpdox/xml/classes/CWM_BroadWorksConnector_Ocip_Models_SystemVoiceMessagingGroupGetVoicePortalMenusResponse18sp1ChangeCurrentIntroductionOrMessageOrReplyMenuKeys.xml): failed to open stream: File name too long

#0 /usr/share/php/TheSeer/fDOMDocument/fDOMDocument.php(238): DOMDocument->save()
#1 /usr/share/php/TheSeer/phpDox/collector/project/Project.php(308): TheSeer\fDOM\fDOMDocument->save()
#2 /usr/share/php/TheSeer/phpDox/collector/project/Project.php(243): TheSeer\phpDox\Collector\Project->saveUnit()
#3 /usr/share/php/TheSeer/phpDox/Application.php(141): TheSeer\phpDox\Collector\Project->save()
#4 /usr/share/php/TheSeer/phpDox/CLI.php(161): TheSeer\phpDox\Application->runCollector()
#5 /usr/bin/phpdox(50): TheSeer\phpDox\CLI->run()

The filename generated is indeed too long for my Linux system, the max size is 255. I know that such long names are unusual, but you may want to have a look.

By the way, is there a way to somehow limit the filename length ? Or to trim a part, or anything ? I'd like to be able to generate this doc...

Regards,

A

aroly avatar Feb 21 '19 08:02 aroly

It never occurred to me that the approach the current implementation takes - as in takeing the FQCN and basically mapping it 1:1 to a filename - might run over 255 chars. But of course that could easily happen and thus needs fixing.

The following solutions come to mind:

  • Merely cutting of after x chars This not really an option, given that that would eventually lead to collisions, which in turn would be leading to duplicates and I'd be overwriting files.

  • Simply counting Also not nice since the code would need to keep track of used numbers and the name cannot be (easily) recreated.

  • Cut of after say 240 chars and append a short SHA-hash The assumption here is that using a shortened hash would be unique enough given we're talking about class names. The content of the class cannot be used for this as that would lead to changing hashes and thus changing filenames for the same class.

Unless somebody comes up with a better solution, I'll consider using the SHA-Approach.

theseer avatar Feb 25 '19 16:02 theseer