Skip to content

Update/sync user language choice#6053

Merged
samhotchkiss merged 7 commits intomasterfrom
update/sync-user-language-choice
Mar 13, 2017
Merged

Update/sync user language choice#6053
samhotchkiss merged 7 commits intomasterfrom
update/sync-user-language-choice

Conversation

@enejb
Copy link
Copy Markdown
Member

@enejb enejb commented Jan 7, 2017

Fixes #5535

Sync the user local if it is different from the sites or if the user sets it.

Changes proposed in this Pull Request:

Add sync event when the user local changes.
Full Sync doesn't send user local if it is the same as the sites.

Testing instructions:

  • Do the test pass?

Proposed changelog entry for your changes:


@enejb enejb added [Package] Sync [Status] Needs Review This PR is ready for review. labels Jan 7, 2017
@enejb enejb added this to the 4.5 milestone Jan 7, 2017
@enejb enejb self-assigned this Jan 7, 2017
$this->server_replica_storage->reset();
$this->sender->reset_data();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's extra whitespace here.

public function test_delete_user_locale_is_synced() {
global $wp_version;
if ( version_compare( $wp_version, 4.7, '<' ) ) {
$this->markTestSkipped( 'WP 4.7 and up supports user local' );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

local => locale.

return $user;
}

// Only set the user local if it is different from the site local
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be a bit easier to write this as:

public function add_to_user( $user ) {
	$user->allowed_mime_types = get_allowed_mime_types( $user );

	if ( ! function_exists( 'get_user_locale' ) ) {
		return $user;
	}

	// Only set the user local if it is different from the site local
	if ( get_locale() !== get_user_locale( $user->ID ) ) {
		$user->locale = get_user_locale( $user->ID );
	}
	
	return $user;
}

In case we need to add more meta in the future.

@ebinnion
Copy link
Copy Markdown
Contributor

ebinnion commented Jan 9, 2017

I left a bit of minor feedback, but overall, this LGTM. 👍

@jeherve jeherve modified the milestones: 4.5, 4.6 Jan 11, 2017

return $user;

return $user;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

miss spaced :P

@enejb enejb force-pushed the update/sync-user-language-choice branch from eab9ae9 to f4cbc0d Compare January 30, 2017 20:01
@enejb
Copy link
Copy Markdown
Member Author

enejb commented Jan 30, 2017

@ebinnion and @lezama I think this is ready to merge.

@jeherve jeherve modified the milestones: 2/17 - February, 4.7.0 - March 2017 Jan 30, 2017
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

space after if

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be cleaner if we sync a jetpack_sync_delete_user_locale?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extra space before =

@lezama lezama added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Feb 1, 2017
@enejb enejb added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Feb 2, 2017
@enejb
Copy link
Copy Markdown
Member Author

enejb commented Feb 2, 2017

@lezama Added fixes as per your suggestions.

@enejb enejb force-pushed the update/sync-user-language-choice branch from 5b91254 to 14c2331 Compare February 23, 2017 18:43
function maybe_save_user_meta( $meta_id, $user_id, $meta_key, $value ) {
if ( $meta_key === 'locale' ) {
if ( current_filter() === 'deleted_user_meta' ) {
do_action( 'jetpack_sync_user_locale_delete', $user_id );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add a docblock here?

if ( current_filter() === 'deleted_user_meta' ) {
do_action( 'jetpack_sync_user_locale_delete', $user_id );
} else {
do_action( 'jetpack_sync_user_locale', $user_id, $value );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add a docblock here?

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Feb 27, 2017
@enejb enejb force-pushed the update/sync-user-language-choice branch from be08830 to c56fa87 Compare March 2, 2017 20:58
@enejb enejb dismissed jeherve’s stale review March 8, 2017 17:45

Added documentation

@enejb enejb force-pushed the update/sync-user-language-choice branch from c56fa87 to 18f4029 Compare March 8, 2017 18:02
Copy link
Copy Markdown
Contributor

@lezama lezama left a comment

Choose a reason for hiding this comment

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

👍

@lezama lezama added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Mar 9, 2017
@samhotchkiss samhotchkiss merged commit 217e752 into master Mar 13, 2017
@samhotchkiss samhotchkiss deleted the update/sync-user-language-choice branch March 13, 2017 17:34
@samhotchkiss samhotchkiss removed the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 13, 2017
jeherve added a commit that referenced this pull request Mar 28, 2017
jeherve added a commit that referenced this pull request Mar 28, 2017
samhotchkiss pushed a commit that referenced this pull request Mar 29, 2017
* Readme: remove old release and add skeleton for 4.8.

* Changelog: add #6572

* Changelog: add #6567

* Changelog: add #6542

* Changelog: add #6527

* Changelog: add #6508

* Changelog: add #6478

* Changelog: add #6477

* Changelog: add #6249

* Update stable version and remove old version from readme.

* Changelog: add 4.7.1 to changelog.

* Readme: add new contributor.

* Sync: update docblock @SInCE version.

Related: #6053

* Changelog: add release post.

* changelog: add #6053

* Changelog: add #6413

* Changelog: add #6482

* Changelog: add #6584

* Changelog add #6603

* Changelog: add #6606

* Changelog: add #6611

* Changelog: add #6635

* Changelog: add #6639

* Changelog: add #6684

* Changelog: add #6710

* Changelog: add #6711

* Changelog: add #5461

* Testing list: update Settings UI feedback prompt.

Props @MichaelArestad

* Changelog: add #6789

* Changelog: add #6778

* Changelog: add #6777

* Changelog: add #6775

* Changelog: add #6755

* Changelog: add #6731

* Changelog: add #6721

* Changelog: add #6705

* Changelog: add #6702

* Changelog: add #6671

* Changelog: add #6637

* Changelog: add #6582

* Changelog: add #6566

* Changelog: add #6555

* Changelog: add #6529

* Changelog: add #6344

* Changelog: add #5763

* Changelog: add #5503

* Changelog: update #6637 changelog.

@see 40e115c#commitcomment-21523982

* Changelog: add #6699

* Changelog: add #6632

* Changelog: add #6769

* Changelog: add #6707

* Changelog: add #6590
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.

6 participants