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

If the post_author is a deleted user, change it to a specified user #270

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

leedxw
Copy link
Contributor

@leedxw leedxw commented Dec 12, 2024

Posts having post_author ids that refer to deleted users cause problems - even if co-authors is populated.

In the short term, don't attempt to resolve the author, and independently find posts with

a) deleted authors
b) populated co-authors

and switch them to be an archive user

leedxw and others added 2 commits December 12, 2024 17:15
Posts having post_author ids that refer to deleted users cause
problems - even if co-authors is populated.

In the short term, don't attempt to resolve the author, and
independently find posts with

a) deleted authors
b) populated co-authors

and switch them to be user 0
@RobjS
Copy link
Contributor

RobjS commented Dec 13, 2024

@leedxw Is there a known way to recreate the issue this fixes? Without this fix, I've tried authoring a post, and then removing the post author from the database entirely, but the page still renders just with an empty author. I do see a PHP warning in the logs:

PHP Warning:  Attempt to read property "user_login" on bool in /var/www/html/wp-content/plugins/co-authors-plus/template-tags.php on line 129

Is the intention of this fix to address that warning?

@leedxw
Copy link
Contributor Author

leedxw commented Dec 13, 2024

It addresses this warning, but you'll also see a perpetual spinner under "Authors" if you edit the page.

@leedxw
Copy link
Contributor Author

leedxw commented Dec 13, 2024

(I suspect there are other issues related to posts that have owners for which lookups fail.)

@leedxw
Copy link
Contributor Author

leedxw commented Dec 13, 2024

Note that we shouldn't apply this to production until we have reassigned the existing deleted-author posts to an existing author. This output is intended to explain future issues from deleted users.

@leedxw leedxw force-pushed the chore/no-coauthors-on-page branch 3 times, most recently from 3c64b91 to 10ca0ea Compare December 13, 2024 16:54
Sets the post_author to 2 if the actual post_author is not found
@leedxw leedxw force-pushed the chore/no-coauthors-on-page branch from 10ca0ea to d5733b4 Compare December 13, 2024 17:02
@leedxw leedxw requested review from snim2 and RobjS December 13, 2024 17:15
Copy link
Contributor

@RobjS RobjS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the intention, but I'm nervous about the approach. Hardcoding a user ID like this that depends on the correct database entry being in place feels risky to me.

templates/entry-meta.php Outdated Show resolved Hide resolved
lib/set-archive-author.php Outdated Show resolved Hide resolved
Copy link
Contributor

@snim2 snim2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Rob's comments

@leedxw leedxw changed the title Don't display a byline if the page has an invalid author If the post_author is a deleted user, change it to a specified user Dec 16, 2024
@leedxw leedxw force-pushed the chore/no-coauthors-on-page branch from 1d79929 to 788cabd Compare December 16, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants