Skip to content
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

Filename too long #351

Open
aroly opened this issue Feb 21, 2019 · 1 comment · May be fixed by #374
Open

Filename too long #351

aroly opened this issue Feb 21, 2019 · 1 comment · May be fixed by #374
Assignees
Labels

Comments

@aroly
Copy link

aroly commented Feb 21, 2019

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

@theseer theseer added the Bug label Feb 22, 2019
@theseer
Copy link
Owner

theseer commented Feb 25, 2019

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 theseer self-assigned this Feb 25, 2019
MacFJA added a commit to MacFJA/phpdox that referenced this issue Oct 6, 2019
Replace the '\' to '_' class FQN transformation by SHA1 to prevent issue with filename being too long.

Close theseer#351
@MacFJA MacFJA linked a pull request Oct 6, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants