-
Notifications
You must be signed in to change notification settings - Fork 85
Optimize and align validate_object methods across handlers #2278
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aaa4f5d
Optimize and align validate_object methods across handlers
obenland c08f808
Bump @wordpress/editor from 14.31.0 to 14.32.0 (#2283)
dependabot[bot] 62a27de
Bump @wordpress/env from 10.31.0 to 10.32.0 (#2280)
dependabot[bot] 8e7c78e
Bump @wordpress/edit-post from 8.31.0 to 8.32.0 (#2282)
dependabot[bot] 7fa5d3c
Fix Prettify workflow for pull requests from forks (#2277)
obenland 140daa8
Tests: Avoid using `runInSeparateProcess` where possible (#2275)
obenland 6a1755a
Update builds (again) (#2285)
pfefferle 83d5cbf
Reorganize test directory structure (#2289)
obenland 1cd87cd
Fix: issue #2286 – typo, improved quoting explanation, add missing i1…
Jiwoon-Kim 85922f3
Use `bp_members_get_user_url` if available for author URLs (#2292)
pfefferle 5d0a1cb
Exclude build asset files from PHP GitHub Actions triggers (#2293)
pfefferle 6da01bc
Merge branch 'trunk' into optimize-validate-object-functions
pfefferle 924275e
Remove test for validate_object with WP_Error
pfefferle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,36 +85,25 @@ public static function handle_undo( $activity, $user_id ) { | |
* @return bool The validation state: true if valid, false if not. | ||
*/ | ||
public static function validate_object( $valid, $param, $request ) { | ||
$json_params = $request->get_json_params(); | ||
$activity = $request->get_json_params(); | ||
|
||
if ( empty( $json_params['type'] ) ) { | ||
if ( empty( $activity['type'] ) ) { | ||
return false; | ||
} | ||
|
||
if ( | ||
'Undo' !== $json_params['type'] || | ||
\is_wp_error( $request ) | ||
) { | ||
if ( 'Undo' !== $activity['type'] ) { | ||
return $valid; | ||
} | ||
|
||
$required_attributes = array( | ||
'actor', | ||
'object', | ||
); | ||
|
||
if ( ! empty( \array_diff( $required_attributes, \array_keys( $json_params ) ) ) ) { | ||
if ( ! isset( $activity['actor'], $activity['object'] ) ) { | ||
return false; | ||
} | ||
|
||
$required_object_attributes = array( | ||
'id', | ||
'type', | ||
'actor', | ||
'object', | ||
); | ||
if ( ! \is_array( $activity['object'] ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we first merge #2284 and then have your changes afterwards? My PR adds support for URI-Objects at least for |
||
return false; | ||
} | ||
|
||
if ( ! empty( \array_diff( $required_object_attributes, \array_keys( $json_params['object'] ) ) ) ) { | ||
if ( ! isset( $activity['object']['id'], $activity['object']['type'], $activity['object']['actor'], $activity['object']['object'] ) ) { | ||
return false; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.