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

Revert composer.json on memory limit error. #64

Merged
merged 6 commits into from
Jan 12, 2018

Conversation

gitlost
Copy link
Contributor

@gitlost gitlost commented Jan 5, 2018

Closes #27.

Deals with PHP memory allocation failure on install/uninstall corrupting the WP-CLI packages composer.json by registering a shutdown function to revert to backup.

Adds 2 new helper functions get_composer_json_path_backup_decoded(), which reads and validates composer.json, and register_revert_shutdown_function().

Modifies the get_composer_json_path() and create_default_composer_json() functions to return the absolute path of the composer.json file to simplify use, and adds some error checking and uses Utils.

Also unrelatedly puts try/catch processing into get_composer() to simplify use, and removes redundant call in uninstall(), and calls once outside loop in show_packages().

Adds phpunit tests for the new get_composer_json_path_backup_decoded() function and the modified get_composer_json_path() and create_default_composer_json() functions.

Needs wp-cli/wp-cli#4597 and a scaffold package-tests refresh before merging to use {INVOKE_WP_CLI_WITH_PHP_ARGS-}.

@gitlost gitlost requested a review from a team January 8, 2018 15:43
@schlessera schlessera merged commit 3fa1d65 into master Jan 12, 2018
@schlessera schlessera deleted the issue-27-invalid-composer.json branch January 12, 2018 17:56
schlessera added a commit that referenced this pull request Jan 5, 2022
Revert composer.json on memory limit error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants