@@ -50,6 +50,38 @@ public function test_invalid_taxonomy() {
5050 $ this ->assertSame ( __ ( 'Invalid taxonomy. ' ), $ result ->message );
5151 }
5252
53+ /**
54+ * Ensures a non-array content struct is rejected rather than causing a fatal error.
55+ *
56+ * When the content struct (the fifth argument) is passed as a string instead of a
57+ * struct, the method must return an error instead of attempting to access a string
58+ * offset, which triggers "Cannot access offset of type string on string" on PHP 8+.
59+ *
60+ * @ticket 65682
61+ */
62+ public function test_invalid_content_struct_should_return_error () {
63+ $ this ->make_user_by_role ( 'editor ' );
64+
65+ $ result = $ this ->myxmlrpcserver ->wp_editTerm ( array ( 1 , 'editor ' , 'editor ' , self ::$ parent_term , 'not-a-struct ' ) );
66+ $ this ->assertIXRError ( $ result );
67+ $ this ->assertSame ( 403 , $ result ->code );
68+ $ this ->assertSame ( __ ( 'Invalid taxonomy. ' ), $ result ->message );
69+ }
70+
71+ /**
72+ * Ensures a missing content struct is rejected with an insufficient arguments error.
73+ *
74+ * @ticket 65682
75+ */
76+ public function test_missing_content_struct_should_return_error () {
77+ $ this ->make_user_by_role ( 'editor ' );
78+
79+ $ result = $ this ->myxmlrpcserver ->wp_editTerm ( array ( 1 , 'editor ' , 'editor ' , self ::$ parent_term ) );
80+ $ this ->assertIXRError ( $ result );
81+ $ this ->assertSame ( 400 , $ result ->code );
82+ $ this ->assertSame ( __ ( 'Insufficient arguments passed to this XML-RPC method. ' ), $ result ->message );
83+ }
84+
5385 public function test_incapable_user () {
5486 $ this ->make_user_by_role ( 'subscriber ' );
5587
0 commit comments