wppaste
WordPress

wp_xmlrpc_server::wp_editTerm( array $args ): true|IXR_Error

Since
3.4.0
Source
wp-includes/class-wp-xmlrpc-server.php:2179
Edits a term.

Compatibility

WordPress
since 3.4.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$argsarray
Method arguments. Note: arguments must be ordered as documented.
  • $0int

    Blog ID (unused).
  • $1string

    Username.
  • $2string

    Password.
  • $3int

    Term ID.
  • $4array

    Content struct for editing a term. The struct must contain the term 'taxonomy'. Optional accepted values include 'name', 'parent', 'description', and 'slug'.

Return value

true|IXR_Error
True on success, IXR_Error instance on failure.

Performance profile

How much work a call to wp_xmlrpc_server::wp_editTerm() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_term().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
8–120

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 201.

Plugin surface
1 hook

Third-party callbacks on 'xmlrpc_call' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksdo_action()called directly
  • querycontent queryget_term()called directly

Further down the call graph this can also reach option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 16 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_xmlrpc_server::wp_editTerm() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!->minimum_args()8->minimum_args()
->minimum_args()22->minimum_args(), ->escape(), ->login()
->minimum_args() && !taxonomy_exists()41->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), __()
->minimum_args() && taxonomy_exists() && is_wp_error()60->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), ->get_error_message()
->minimum_args() && taxonomy_exists() && !is_wp_error()62->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), __()
->minimum_args() && taxonomy_exists() && !is_wp_error()67–79->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), __()
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && !isset($content_struct) && empty($content_struct)83–95->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), wp_update_term(), is_wp_error()
->minimum_args() && taxonomy_exists() && current_user_can() && !empty($content_struct) && $taxonomy85–91->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), get_term(), is_wp_error(), ->get_error_message()
->minimum_args() && taxonomy_exists() && current_user_can() && empty($content_struct)86–98->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), wp_update_term(), is_wp_error(), ->get_error_message()
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && !empty($content_struct) && $taxonomy87–93->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), get_term(), is_wp_error(), __()
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && empty($content_struct)88–100->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), wp_update_term(), is_wp_error(), __()
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && empty($content_struct) && isset($content_struct)89–101->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), wp_update_term(), is_wp_error(), ->set_term_custom_fields()
4 further outcomes, up to 120 instructions
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && !isset($content_struct) && !empty($content_struct) && $taxonomy102–114->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), get_term(), is_wp_error(), wp_update_term(), is_wp_error()
->minimum_args() && taxonomy_exists() && current_user_can() && !empty($content_struct) && $taxonomy105–117->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), get_term(), is_wp_error(), wp_update_term(), is_wp_error(), ->get_error_message()
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && !empty($content_struct) && $taxonomy107–119->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), get_term(), is_wp_error(), wp_update_term(), is_wp_error(), __()
->minimum_args() && taxonomy_exists() && !is_wp_error() && current_user_can() && !empty($content_struct) && $taxonomy && isset($content_struct)108–120->minimum_args(), ->escape(), ->login(), do_action(), taxonomy_exists(), get_taxonomy(), get_term(), is_wp_error(), current_user_can(), get_term(), is_wp_error(), wp_update_term(), is_wp_error(), ->set_term_custom_fields()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev2018–12017
8.52018–12017
8.42018–120172 fewer instructions than PHP 8.3
8.32038–12217
8.22038–12217
8.12038–12217
7.42038–12217

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while wp_xmlrpc_server::wp_editTerm() runs, in this order:

  1. do_action( xmlrpc_call )actionline 2197 (+18 into the body)

    Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.

Uses · 13

Show all 13

Source code

	public function wp_editTerm( $args ) {		if ( ! $this->minimum_args( $args, 5 ) ) {			return $this->error;		} 		$this->escape( $args ); 		$username       = $args[1];		$password       = $args[2];		$term_id        = (int) $args[3];		$content_struct = $args[4]; 		$user = $this->login( $username, $password );		if ( ! $user ) {			return $this->error;		} 		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */		do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this ); 		if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );		} 		$taxonomy = get_taxonomy( $content_struct['taxonomy'] ); 		$taxonomy = (array) $taxonomy; 		// Hold the data of the term.		$term_data = array(); 		$term = get_term( $term_id, $content_struct['taxonomy'] ); 		if ( is_wp_error( $term ) ) {			return new IXR_Error( 500, $term->get_error_message() );		} 		if ( ! $term ) {			return new IXR_Error( 404, __( 'Invalid term ID.' ) );		} 		if ( ! current_user_can( 'edit_term', $term_id ) ) {			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this term.' ) );		} 		if ( isset( $content_struct['name'] ) ) {			$term_data['name'] = trim( $content_struct['name'] ); 			if ( empty( $term_data['name'] ) ) {				return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );			}		} 		if ( ! empty( $content_struct['parent'] ) ) {			if ( ! $taxonomy['hierarchical'] ) {				return new IXR_Error( 403, __( 'Cannot set parent term, taxonomy is not hierarchical.' ) );			} 			$parent_term_id = (int) $content_struct['parent'];			$parent_term    = get_term( $parent_term_id, $taxonomy['name'] ); 			if ( is_wp_error( $parent_term ) ) {				return new IXR_Error( 500, $parent_term->get_error_message() );			} 			if ( ! $parent_term ) {				return new IXR_Error( 403, __( 'Parent term does not exist.' ) );			} 			$term_data['parent'] = $content_struct['parent'];		} 		if ( isset( $content_struct['description'] ) ) {			$term_data['description'] = $content_struct['description'];		} 		if ( isset( $content_struct['slug'] ) ) {			$term_data['slug'] = $content_struct['slug'];		}

Changelog

Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-xmlrpc-server.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.