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

[Fatal] Author override can cause infinite loop on post list screen #1064

Closed
1 task done
peterwilsoncc opened this issue May 30, 2023 · 1 comment · Fixed by #1065
Closed
1 task done

[Fatal] Author override can cause infinite loop on post list screen #1064

peterwilsoncc opened this issue May 30, 2023 · 1 comment · Fixed by #1065
Assignees
Labels
type:bug Something isn't working.
Milestone

Comments

@peterwilsoncc
Copy link
Collaborator

peterwilsoncc commented May 30, 2023

Describe the bug

The post list can go in an infinite loop if the author replacement option is set.

A git bisect suggests it's following the merge of #1035 but it's possibly an interaction with a subsequently merged PR as the failure is intermittent.

Steps to Reproduce

  1. Create multiple sites running Distributor on develop branch
  2. Connect them
  3. Create a few posts on the first site
  4. Pull a few posts to the second site
  5. Visit the posts listing in the dashboard
  6. An infinite loop occurs.

Screenshots, screen recording, code snippet

Screen Shot 2023-05-30 at 2 15 29 pm

Environment information

No response

WordPress information

Site info
### wp-core ###

version: 6.2.3-alpha-55842
site_language: en_US
user_language: en_US
timezone: +00:00
permalink: /%year%/%monthnum%/%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: open
environment_type: local
user_count: 5
dotorg_communication: true

### wp-paths-sizes ###

wordpress_path: /vagrant/wp-build
wordpress_size: loading...
uploads_path: /vagrant/content/uploads
uploads_size: loading...
themes_path: /vagrant/content/themes
themes_size: loading...
plugins_path: /vagrant/content/plugins
plugins_size: loading...
database_size: loading...
total_size: loading...

### wp-dropins (1) ###

db.php: true

### wp-active-theme ###

name: Twenty Twenty-Three (twentytwentythree)
version: 1.1
author: the WordPress team
author_website: https://wordpress.org
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, responsive-embeds, editor-styles, html5, automatic-feed-links, block-templates, widgets-block-editor
theme_path: /vagrant/wp-build/wp-content/themes/twentytwentythree

### wp-themes-inactive (12) ###

Twenty Eleven: version: 4.3, author: the WordPress team
Twenty Fifteen: version: 3.4, author: the WordPress team
Twenty Fourteen: version: 3.6, author: the WordPress team
Twenty Nineteen: version: 2.5, author: the WordPress team
Twenty Seventeen: version: 3.2, author: the WordPress team
Twenty Sixteen: version: 2.9, author: the WordPress team
Twenty Ten: version: 3.8, author: the WordPress team
Twenty Thirteen: version: 3.8, author: the WordPress team
Twenty Twelve: version: 3.9, author: the WordPress team
Twenty Twenty: version: 2.2, author: the WordPress team
Twenty Twenty-One: version: 1.8, author: the WordPress team
Twenty Twenty-Two: version: 1.4, author: the WordPress team

### wp-mu-plugins (6) ###

nope-post-abstraction-dumps.php: author: (undefined), version: (undefined)
nope-push-nope-pull.php: author: (undefined), version: (undefined)
query-monitor-file-mappings.php: author: (undefined), version: (undefined)
show-stable-dist.php: author: (undefined), version: (undefined)
snippet-auto-unlink.php: author: (undefined), version: (undefined)
unsafe-app-passwords.php: author: (undefined), version: (undefined)

### wp-plugins-active (3) ###

Distributor: version: 1.9.1, author: 10up Inc.
Query Monitor: version: 3.12.3, author: John Blackbourn
User Switching: version: 1.7.0, author: John Blackbourn & contributors

### wp-plugins-inactive (6) ###

Classic Editor: version: 1.6.3, author: WordPress Contributors
Distributor: version: 1.9.1, author: 10up Inc.
Distributor - Edit Remote Post Meta: version: 0.2.1, author: 10up
Newspack Image Credits: version: 1.0.1, author: Automattic, INN Labs, Project Argo
Test block: author: (undefined), version: (undefined)
Yoast SEO: version: 20.7, author: Team Yoast (latest version: 20.8)

### wp-media ###

image_editor: WP_Image_Editor_GD
imagick_module_version: Not available
imagemagick_version: Not available
imagick_version: Not available
file_uploads: File uploads is turned off
post_max_size: 1024M
upload_max_filesize: 1024M
max_effective_size: 1 GB
max_file_uploads: 20
gd_version: 2.3.3
gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM
ghostscript_version: not available

### wp-server ###

server_architecture: Linux 5.15.0-30-generic x86_64
httpd_software: nginx/1.18.0
php_version: 7.4.33 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 900
memory_limit: 128M
admin_memory_limit: 256M
max_input_time: 900
upload_max_filesize: 1024M
php_post_max_size: 1024M
curl_version: 7.81.0 OpenSSL/3.0.2
suhosin: false
imagick_availability: false
pretty_permalinks: true

### wp-database ###

extension: mysqli
server_version: 8.0.30-0ubuntu0.22.04.1
client_version: mysqlnd 7.4.33
max_allowed_packet: 16777216
max_connections: 151

### wp-constants ###

WP_HOME: http://xu-distributor.local
WP_SITEURL: http://xu-distributor.local/wp
WP_CONTENT_DIR: /vagrant/content
WP_PLUGIN_DIR: /vagrant/content/plugins
WP_MEMORY_LIMIT: 40M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: true
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: true
SCRIPT_DEBUG: true
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: local
DB_CHARSET: utf8
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable

### distributor ###

0: 1.9.1
1: No
2: N/A
3: 
	Override Author Byline: Yes
	Media Handling: Featured image only
4: N/A
5: 
	XU Single 2: 
- URL: http://vagrant.local/wp-json/
- Version: 1.9.1
- Status: valid
- Auth method: Username / Password
- Username: admin
- Roles Allowed to Push: administrator, editor
- Additional data: {"errors":[], "can_post":["post", "page", "attachment", "nav_menu_item", "wp_block", "wp_template", "wp_template_part", "wp_navigation"], "can_get":["post", "page", "attachment", "nav_menu_item", "wp_block", "wp_template", "wp_template_part", "wp_navigation"], "endpoint_suggestion":false, "is_authenticated":"yes"}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@peterwilsoncc peterwilsoncc added the type:bug Something isn't working. label May 30, 2023
@ravinderk ravinderk moved this from 🆕 New to 📋 Backlog in Distributor 2.0.0 May 30, 2023
@jeffpaul jeffpaul added this to the 2.0.0 milestone May 30, 2023
@peterwilsoncc
Copy link
Collaborator Author

This is an edge case caused by a post without an author specified or an author with the display name set to ''.

The DistributorPost::get_author_name() method is used by the author replacement hook and doesn't allow for the use case of an empty author display name. When running on the replacment hook, it triggers an infinite loop.

protected function get_author_name( $author_name = '' ) {
$settings = Utils\get_settings();
if (
empty( $settings['override_author_byline'] )
|| $this->is_source
|| $this->original_deleted
|| ! $this->is_linked
|| ! $this->connection_id
|| ! $this->original_post_url
) {
if ( empty( $author_name ) ) {
return get_the_author_meta( 'display_name', $this->post->post_author );
}
return $author_name;
}
$this->populate_source_site();
return $this->source_site['name'];
}

We're not seeing it in the E2E tests as the author display name is specified, I'm seeing it locally because I'm generating posts with wp post generate which produces posts without an author specified.

An empty display name is an edge case but probably something we should account for.

@jeffpaul jeffpaul moved this from 📋 Backlog to 👀 In review in Distributor 2.0.0 May 31, 2023
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Distributor 2.0.0 Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants