-
Notifications
You must be signed in to change notification settings - Fork 206
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
Add wp-cli command to delete guest authors, with option to reassign their posts. #588
base: develop
Are you sure you want to change the base?
Conversation
Script was stopping after no co-authors was find. Now script will display an error message and continue to the next post.
This reverts commit f759744.
This reverts commit 6e7da2b.
Script was stopping after no co-authors was find. Now script will display an error message and continue to the next post.
Resolves Automattic#417 * Removed duplicate left join for optimization
…bled() should do the trick now
This reverts commit 525f211.
This reverts commit 5ac7d9a.
Reduce amount of sleep
…r-posts Fixed WP CLI create-terms-for-posts if no co-authors found
Terminology updated throughout
…uthor Replace hardcoded 'author' with $this->$coauthor_taxonomy
Fixes warning: `Warning: sprintf(): Too few arguments in /path/wp-content/plugins/co-authors-plus/php/class-coauthors-guest-authors.php on line 487` Warning surfaces when deleting a guest author that is mapped to a WP user
Move parenthesis to fix esc_html and sprintf
Perfect |
Looking at #550, it seems like it could be its own independent PR. Am I reading it right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions :)
This commit adds additional information on success and failure, telling the end user not only the ID of the guest author that was deleted, but also (if applicable) the login their posts were assigned to.
Nod, it might be useful for the comment to explain the intent behind this
since I wouldn't say it's a common pattern :)
…On 14 August 2018 at 18:40, Stephen Smith ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In php/class-wp-cli.php
<#588 (comment)>
:
> + );
+
+ $assoc_args = wp_parse_args( $assoc_args, $defaults );
+
+ $dry_run = $assoc_args['dry-run'];
+
+ // Safety first.
+ $filename_status = validate_file( $args[0] );
+
+ if ( 0 !== $filename_status ) {
+ WP_CLI::error( __( 'The provided file cannot be accessed. Please use either relative or absolute pathnames, and avoid using directory traversal such as ../ and other methods.', 'co-authors-plus' ) );
+ }
+
+ $filename = $args[0];
+
+ // Add custom error handling on fopen error.
Ah. The custom error handling is there to avoid an ugly PHP warning and
stack trace from being thrown to the console if the CSV file can't be
opened, doesn't exist, or some other error.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#588 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARpqYPBy7Pw6eRbB4T6uFU6dxWvrJgzks5uQ1HagaJpZM4V9Lsf>
.
|
This commit utilizes the CAP API during dry runs to pull out information about the guest authors about to be deleted, to make sure they're the right ones.
This commit utilizes the CAP API to pull out information about the guest authors about to be deleted, to make sure they're the right ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good - I've left some comment.
One overall question - how can we check this code is going to work as expected in production?
Checks I've performed so far:
And I'm always open to more opportunities 👍 |
Allow for remapping to user named "false". The CAP delete function takes, as its second parameter, either a string containing the login of the user you wish to reassign the deleted guest author's posts to, or a boolean false stating that you do wish to reassign. But what if you want to reassign to a user named false? Before that was not possible. Now, the code specifically looks for if the instance has a user named false, and if so, allows it to be reassigned to. If not, it assumes the boolean was intended.
Hooray for @philipjohn pulling the gremlin out of Travis, builds pass now, as they should 👍 |
Which unit tests did you look at when trying to assess whether this code works as intended?
That's a good idea! What kind of faulty data did you use here? |
I examined the
I used:
As well as:
|
@rebeccahum I appreciate this is an old PR but is there a reason this PR never got merged? Happy to help get this over the line if possible. |
@chrissy-dev I think this just slipped the radar. First step would be to resolve any merge conflicts and test if the current PR still works please! |
Overlaps with #696. |
Currently, there is no way to delete guest authors from the command line. This command fills that need.
It is activated using
delete-guest-authors
, and passing in the path to a CSV file containing a list of two columns: the ID to delete, and the login to assign the posts to (or "false" to not reassign).The command runs dry by default, showing the end user the guest authors it would have attempted to delete, and the user login it would have attempted to transfer the posts to.
Passing --no-dry-run, and confirming that you really do want to delete guest authors, actively modifies the database.