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

Fails when scanning broken symlinks #86

Open
2 tasks done
BrianHenryIE opened this issue Nov 26, 2023 · 2 comments
Open
2 tasks done

Fails when scanning broken symlinks #86

BrianHenryIE opened this issue Nov 26, 2023 · 2 comments

Comments

@BrianHenryIE
Copy link
Member

Bug Report

Describe the current, buggy behavior

.distignore

...
/wp-content
...

Project files:

...
wp-content/plugins/woocommerce-gateway-dummy    // broken symlink
...
Fatal error: Uncaught Inmarelibero\GitIgnoreChecker\Exception\InvalidArgumentException: Path "/Users/brianhenry/Sites/bh-wp-bitcoin-gateway/wp-content/plugins/woocommerce-gateway-dummy" does not exist. in /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/inmarelibero/gitignore-checker/src/Utils/PathUtils.php:86
Stack trace:
#0 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/inmarelibero/gitignore-checker/src/Model/RelativePath.php(64): Inmarelibero\GitIgnoreChecker\Utils\PathUtils::absolutePathIsValid('/Users/brianhen...')
#1 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/inmarelibero/gitignore-checker/src/Model/RelativePath.php(41): Inmarelibero\GitIgnoreChecker\Model\RelativePath->setPath('/wp-content/plu...')
#2 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/inmarelibero/gitignore-checker/src/GitIgnoreChecker.php(71): Inmarelibero\GitIgnoreChecker\Model\RelativePath->__construct(Object(Inmarelibero\GitIgnoreChecker\Model\Repository), '/wp-content/plu...')
#3 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/dist-archive-command/src/Dist_Archive_Command.php(444): Inmarelibero\GitIgnoreChecker\GitIgnoreChecker->isPathIgnored('/wp-content/plu...')
#4 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/dist-archive-command/src/Dist_Archive_Command.php(165): Dist_Archive_Command->get_file_list('/Users/brianhen...')
#5 [internal function]: Dist_Archive_Command->__invoke(Array, Array)
#6 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#8 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(488): call_user_func(Object(Closure), Array, Array)
#9 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(436): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#10 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(459): WP_CLI\Runner->run_command(Array, Array)
#11 /Users/brianhenry/Sites/bh-wp-bitcoin-gateway/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(136): WP_CLI\Runner->run_command_and_exit()

Describe what you would expect as the correct outcome

It should handle this gracefully – it should only be scanning the excluded directories for .distignore files that act to include a subdir of an included dir. The broken symlink shouldn't be fatal for dist-ignore-command.

Let us know what environment you are running this on

OS:	Darwin 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 arm64
Shell:	/bin/zsh
PHP binary:	/opt/homebrew/Cellar/php@8.0/8.0.30_1/bin/php
PHP version:	8.0.30
php.ini used:	/opt/homebrew/etc/php/8.0/php.ini
MySQL binary:	/opt/homebrew/bin/mysql
MySQL version:	mysql from 11.1.2-MariaDB, client 15.2 for osx10.18 (arm64) using  EditLine wrapper
SQL modes:	STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/Users/brianhenry/Sites/bh-wp-bitcoin-gateway
WP-CLI packages dir:	/Users/brianhenry/.wp-cli/packages/
WP-CLI cache dir:	/Users/brianhenry/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	/Users/brianhenry/Sites/bh-wp-bitcoin-gateway/wp-cli.yml
WP-CLI version:	2.9.0

Provide a possible solution

I was already aware that it's inefficiently scanning – when improving that it should be easy to gracefully skip over broken symlinks too.

@BrianHenryIE BrianHenryIE changed the title Fails when scanning symlinks Nov 26, 2023
@danielbachhuber
Copy link
Member

Thanks for the report, @BrianHenryIE !

The broken symlink shouldn't be fatal for dist-ignore-command.

This seems like a reasonable fix.

@thelovekesh
Copy link
Member

Is #91 a fix for this issue? If yes, should we close it? cc @danielbachhuber

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment