PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.7.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/rest/class-comments-controller.php +3 -15 9.3.07.7.0 View file →
@@ -9,10 +9,8 @@
9 9
10 10 use Activitypub\Comment;
11 11 use Activitypub\Webfinger;
12 12
13 -use function Activitypub\is_post_publicly_queryable;
14 -
15 13 /**
16 14 * Comments_Controller class.
17 15 *
18 16 * @author Matthias Pfefferle
@@ -31,9 +29,9 @@
31 29 * The base of this controller's route.
32 30 *
33 31 * @var string
34 32 */
35 - protected $rest_base = 'comments/(?P<comment_id>[\d]+)';
33 + protected $rest_base = 'comments/(?P<comment_id>[-]?\d+)';
36 34
37 35 /**
38 36 * Register routes.
39 37 */
@@ -45,9 +43,8 @@
45 43 'args' => array(
46 44 'comment_id' => array(
47 45 'description' => 'The ID of the comment.',
48 46 'type' => 'integer',
49 - 'minimum' => 1,
50 47 'required' => true,
51 48 'validate_callback' => array( $this, 'validate_comment' ),
52 49 ),
53 50 ),
@@ -81,20 +78,11 @@
81 78 if ( ! $comment ) {
82 79 return new \WP_Error( 'activitypub_comment_not_found', \__( 'Comment not found', 'activitypub' ), array( 'status' => 404 ) );
83 80 }
84 81
85 - /*
86 - * A comment inherits the visibility of its parent post. Check this
87 - * BEFORE the local-only guard below, so that any comment on a non-
88 - * publicly-queryable parent returns the same "not found" shape — we
89 - * never want an outsider to distinguish "comment exists but is local"
90 - * from "comment missing" when the parent post is private.
91 - */
92 - if ( ! is_post_publicly_queryable( $comment->comment_post_ID ) ) {
93 - return new \WP_Error( 'activitypub_comment_not_found', \__( 'Comment not found', 'activitypub' ), array( 'status' => 404 ) );
94 - }
82 + $is_local = Comment::is_local( $comment );
95 83
96 - if ( Comment::is_local( $comment ) ) {
84 + if ( $is_local ) {
97 85 return new \WP_Error( 'activitypub_local_only_comment', \__( 'Comment is local only', 'activitypub' ), array( 'status' => 403 ) );
98 86 }
99 87
100 88 return true;