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

Symlink in ignored directory causing out of memory error #57

Closed
2 tasks done
BrianHenryIE opened this issue May 27, 2022 · 1 comment · Fixed by #61
Closed
2 tasks done

Symlink in ignored directory causing out of memory error #57

BrianHenryIE opened this issue May 27, 2022 · 1 comment · Fixed by #61

Comments

@BrianHenryIE
Copy link
Member

Bug Report

Describe the current, buggy behavior

I have a project structure with a recursive symlink:

project-dir/my-plugin.php
project-dir/wp-content/plugins/my-plugin/

where wp-content/plugins/my-plugin/ is a symlink to project-dir/.

Previously I was using dist-archive on the src directory and now I'm trying to use it on the entire project directory, with appropriate an .distignore in the project root. PhpStorm project screenshot

My .distignore file contains wp-content in it.

Still, running wp dist-archive . out.zip causes a PHP Fatal error:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 121634848 bytes) in /path/to/project-dir/vendor/wp-cli/wp-cli/php/WP_CLI/Process.php on line 75

When I delete the symlink, I am able to use dist-archive without issue.

Describe what you would expect as the correct outcome

I expect the wp-content folder to have no bearing on the operation because it is listed in the .distignore file.

Let us know what environment you are running this on

MacOS M1, Monterey (12.3.1), PHP 8.0 via Homebrew, Zsh shell.

OS:     Darwin 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64
Shell:  /bin/zsh
PHP binary:     /opt/homebrew/bin/php
PHP version:    8.0.19
php.ini used:   /opt/homebrew/etc/php/8.0/php.ini
MySQL binary:   /opt/homebrew/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.7.3-MariaDB, for osx10.17 (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:        /Users/brianhenry/Sites/bh-wc-disable-free-gifts-per-product/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      /Users/brianhenry/Sites/bh-wc-disable-free-gifts-per-product/vendor
WP_CLI phar path:       
WP-CLI packages dir:    /Users/brianhenry/.wp-cli/packages/
WP-CLI global config:   
WP-CLI project config:  /Users/brianhenry/Sites/bh-wc-disable-free-gifts-per-product/wp-cli.yml
WP-CLI version: 2.6.0

Provide a possible solution

Using the zip flag:

-y   store symbolic links as the link instead of the referenced file

Change:

$cmd = "zip -r '{$archive_file}' {$archive_base} {$excludes}";

to:

$cmd = "zip -y -r '{$archive_file}' {$archive_base} {$excludes}";

This works.

But I presume it would prevent the dist-ignore command from working with plugins that use symlinks internally to the plugin (i.e. not just dev tools and environment) during development.

Alternatively, I could copy all files to system temp before archiving them.

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