Skip to content

Conversation

@soren121
Copy link
Contributor

Directories can also match the glob search pattern if their names end in ".php", which will cause a read error later since the ContentRetriever implementers are expecting files. This behavior can be reproduced by installing the Composer package "mtdowling/jmespath.php".

As far as I know, the only way to fix this is to do an additional check to ensure the URI is not of a directory.

This resolves #306.

Directories can also match the glob search pattern if their names end in ".php", which will cause a read error later since the ContentRetriever implementers are expecting files. As far as I know, the only way to fix this is to do an additional check to ensure the URI is not of a directory.

This resolves #306.
@soren121 soren121 changed the title Exclude directories from file system search Exclude directory paths from file system search Jun 11, 2017
@codecov
Copy link

codecov bot commented Jun 11, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@fe7e9d5). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master     #401   +/-   ##
=========================================
  Coverage          ?   84.24%           
  Complexity        ?      699           
=========================================
  Files             ?       54           
  Lines             ?     1568           
  Branches          ?        0           
=========================================
  Hits              ?     1321           
  Misses            ?      247           
  Partials          ?        0
Impacted Files Coverage Δ Complexity Δ
src/FilesFinder/FileSystemFilesFinder.php 100% <100%> (ø) 3 <0> (?)

Upon further inspection, it seems that the workspace should never contain a directory, so it should be safe.
Copy link
Owner

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting as a fix, but an additional stat on every file is not the best. Maybe the implementation should be changed to not rely on globs anymore...

@felixfbecker felixfbecker merged commit 8d1732e into felixfbecker:master Jun 11, 2017
@soren121
Copy link
Contributor Author

I agree. For what it's worth, I tested on a codebase of ~3500 PHP files and the performance (in seconds) was the same as it was without the is_dir check.

@staabm
Copy link
Contributor

staabm commented Jun 12, 2017

Maybe it should utilize the symfony finder which is also capable of using native commands to speedup the process

@felixfbecker
Copy link
Owner

What does it provide over RecursiveDirectoryIterator for our use case?

@staabm
Copy link
Contributor

staabm commented Jun 12, 2017

we need to benchmark whether the "native finders" are faster/more effiecient or not.

or was your question related to features the sfFinder can provide?

@staabm
Copy link
Contributor

staabm commented Jun 12, 2017

maybe a non-glob (php native) finder would be enough though

@felixfbecker
Copy link
Owner

What are "native finders"? RecursiveDirectoryIterator is native too

@staabm
Copy link
Contributor

staabm commented Jun 12, 2017

symfony uses system/exec to use the OS capabilities

@felixfbecker
Copy link
Owner

I couldn't find that in Symfony's codebase, could you give a code pointer?

@staabm
Copy link
Contributor

staabm commented Jun 12, 2017

hmm it seems this feature was deprecated and removed later on
symfony/symfony#15805

lialan pushed a commit to lambdalab/php-language-server that referenced this pull request Oct 7, 2017
* Exclude directories from file system search

Directories can also match the glob search pattern if their names end in ".php", which will cause a read error later since the ContentRetriever implementers are expecting files. As far as I know, the only way to fix this is to do an additional check to ensure the URI is not of a directory.

This resolves felixfbecker#306.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal error when parsing directories whose names end in ".php"

4 participants