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

Fix/missing wp user type #988

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open

Commits on Aug 28, 2023

  1. Configuration menu
    Copy the full SHA
    33ae3b0 View commit details
    Browse the repository at this point in the history

Commits on Sep 2, 2023

  1. Configuration menu
    Copy the full SHA
    92c6725 View commit details
    Browse the repository at this point in the history
  2. fix: making the update operation dependent on $append flag.

    This might be a problematic decision. But the way I justify this change is that if you are appending co-authors, there may already be a WP_User set as the author. So we don't really have to care whether one is passed or not. Because of this, we do not need to forcibly return a `false` flag since that is confusing to the caller, especially because we actually do save the guest authors which are given in the call! Instead, if the $append flag is false, we should expect that at least one user will be a WP_User. In that case, if none is passed in, then there is a mismatch of the intended authors. Because now, the `wp_posts.post_author` column will have an old `wp_users.ID` which remains set and most likely isn't the intent of the caller.
    eddiesshop authored and GaryJones committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    b6a0598 View commit details
    Browse the repository at this point in the history
  3. fix: attempting DB update only when $new_author is not empty.

    Also, returning the actual response from the DB, to make this call even more accurate in terms of what is actually happen at the DB layer.
    eddiesshop authored and GaryJones committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    017dc74 View commit details
    Browse the repository at this point in the history
  4. fix: need to ensure pure WP_User is processed correctly as post_author.

    A pure WP_User (i.e. a WP_User that IS NOT linked to a Guest Author) needs to be handled specially.
    eddiesshop authored and GaryJones committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    a0635df View commit details
    Browse the repository at this point in the history
  5. fix: a necessary refactor of the get_coauthor_by function.

    This refactor is absolutely necessary in order for all the previous fixes to work as expected. Without this fix, what happens is that when you use `get_coauthor_by` by searching with a Guest Author, if that Guest Author has a valid link to a WP_User, it is summarily ignored. Functions like `add_coauthors` expect at least one coauthor to be a valid WP_User so that the `wp_posts.post_author` column can be appropriately updated. The only case where this function is returning an expected value is when you search by the WP_User first. When it arrives at `$guest_author = $this->guest_authors->get_guest_author_by( $key, $value, $force );`, `$guest_author === false`. It is then forced to move to the switch statement to find a user via their WP_User data.
    
    With this refactor, `get_coauthor_by` will now check if the `linked_account` attribute is set. If so, it will attempt to find the corresponding user for the Guest Account. It still gives priority to returning a Guest Author. When a Guest Author is not found, it will search for a WP_User. If found, it will also search to see if a linked Guest Author account exists. If it does, it will return that Guest Author object instead, without losing the fact that this account also has a WP_User associated with it.
    eddiesshop authored and GaryJones committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    da28669 View commit details
    Browse the repository at this point in the history
  6. fix: returning a plain WP_User if guest authors is not enabled.

    I forgot to run tests on my previous commit. This satisfies the test Test_CoAuthors_Plus::test_get_coauthor_by_when_guest_authors_not_enabled which is expecting a WP_User when the plugin is not enabled.
    eddiesshop authored and GaryJones committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    b71ea29 View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2023

  1. Configuration menu
    Copy the full SHA
    fbf2087 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    756d9fc View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2023

  1. Configuration menu
    Copy the full SHA
    0d55c46 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e64921e View commit details
    Browse the repository at this point in the history
  3. fix: making the update operation dependent on $append flag.

    This might be a problematic decision. But the way I justify this change is that if you are appending co-authors, there may already be a WP_User set as the author. So we don't really have to care whether one is passed or not. Because of this, we do not need to forcibly return a `false` flag since that is confusing to the caller, especially because we actually do save the guest authors which are given in the call! Instead, if the $append flag is false, we should expect that at least one user will be a WP_User. In that case, if none is passed in, then there is a mismatch of the intended authors. Because now, the `wp_posts.post_author` column will have an old `wp_users.ID` which remains set and most likely isn't the intent of the caller.
    eddiesshop committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    c0344db View commit details
    Browse the repository at this point in the history
  4. fix: attempting DB update only when $new_author is not empty.

    Also, returning the actual response from the DB, to make this call even more accurate in terms of what is actually happen at the DB layer.
    eddiesshop committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    7ece2ab View commit details
    Browse the repository at this point in the history
  5. fix: need to ensure pure WP_User is processed correctly as post_author.

    A pure WP_User (i.e. a WP_User that IS NOT linked to a Guest Author) needs to be handled specially.
    eddiesshop committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    741c053 View commit details
    Browse the repository at this point in the history
  6. fix: a necessary refactor of the get_coauthor_by function.

    This refactor is absolutely necessary in order for all the previous fixes to work as expected. Without this fix, what happens is that when you use `get_coauthor_by` by searching with a Guest Author, any link to a WP_User the Guest Author may have is summarily ignored. Functions like `add_coauthors` expect at least one coauthor to be a valid WP_User so that the `wp_posts.post_author` column can be appropriately updated. The only case where this function is currently returning an expected value is when you search by a WP_User account/field first. When it arrives at `$guest_author = $this->guest_authors->get_guest_author_by( $key, $value, $force );`, `$guest_author === false`. It is then forced to move to the switch statement to find a user via their WP_User data.
    
    With this refactor, `get_coauthor_by` will now check if the `linked_account` attribute is set. If so, it will then attempt to find the corresponding WP_User for the Guest Author. Crucially, it still gives priority to returning a Guest Author. When a Guest Author is not found, it will then attempt to search for a WP_User. If found, it will also search to see if a linked Guest Author account exists. If it does, it will return that Guest Author object instead, without losing the fact that this account also has a WP_User associated with it.
    eddiesshop committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    e9e76af View commit details
    Browse the repository at this point in the history
  7. fix: renaming user_login's for new authors introduced for new tests.

    These user_login's were causing other tests to fail because you cannot create another user with the same user_login.
    eddiesshop committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    e7c7792 View commit details
    Browse the repository at this point in the history
  8. fix: removing use of assertObjectHasProperty

    Older version of PHPUnit do not have this function available. Updating to workaround: `assertTrue( property_exists( $obj, 'prop' ) )`
    eddiesshop committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    b6b959b View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    41006b3 View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2023

  1. Configuration menu
    Copy the full SHA
    1a2d06f View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2023

  1. Configuration menu
    Copy the full SHA
    7e4bd8e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aacd37b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fc05f9d View commit details
    Browse the repository at this point in the history
  4. fix: removing use of newly introduced is_wp_user property.

    Relying instead on wp_user property which has already been used before.
    eddiesshop committed Oct 17, 2023
    Configuration menu
    Copy the full SHA
    a0b808a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e3a120a View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2023

  1. Configuration menu
    Copy the full SHA
    6afab35 View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2024

  1. Configuration menu
    Copy the full SHA
    719c15c View commit details
    Browse the repository at this point in the history

Commits on May 1, 2024

  1. Configuration menu
    Copy the full SHA
    3c27322 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2024

  1. Configuration menu
    Copy the full SHA
    175d8fe View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    de55e39 View commit details
    Browse the repository at this point in the history

Commits on Jul 3, 2024

  1. Configuration menu
    Copy the full SHA
    8dd6d67 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    db9a6d7 View commit details
    Browse the repository at this point in the history

Commits on Jul 4, 2024

  1. add: new test solely for CoAuthorPlus::get_coauthor_by().

    By fully testing CoAuthorPlus::get_coauthor_by(), we can remove some repetitive assertions that don't directly relate to what's being tested.
    eddiesshop committed Jul 4, 2024
    Configuration menu
    Copy the full SHA
    bbfc79a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    312d519 View commit details
    Browse the repository at this point in the history