IXR_Server::serve( $data = false )
- Source
wp-includes/IXR/class-IXR-server.php:38
Compatibility
- WordPress
- core
- 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
$dataoptional- Default:
false
Performance profile
How much work a call to IXR_Server::serve() 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
- Scaling
- Constant
- Instructions
- 45–83
- Plugin surface
- None
- Called by
- 1
Reads or writes the filesystem via file_get_contents().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 83.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- filesystemfilesystem access
file_get_contents()called directly - hookthird-party callbacks
apply_filters()one call below IXR_Server::serve()
What one call costs · 24 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost IXR_Server::serve() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
->parse() && !is_a() | 45 | ->parse(), ->call(), is_a(), ->getXml(), ->output() |
->parse() && is_a() | 48 | ->parse(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
!is_a() | 49 | ->parse(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
->parse() && !is_a() | 52–56 | file_get_contents(), ->parse(), ->call(), is_a(), ->getXml(), ->output() |
is_a() | 52 | ->parse(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
!->parse() && !is_a() | 53 | ->parse(), ->error(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
->parse() && is_a() | 55–59 | file_get_contents(), ->parse(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
!is_a() | 56–60 | file_get_contents(), ->parse(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
!->parse() && is_a() | 56 | ->parse(), ->error(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
is_a() | 59–63 | file_get_contents(), ->parse(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
!->parse() && !is_a() | 60–64 | file_get_contents(), ->parse(), ->error(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
!->parse() && is_a() | 63–67 | file_get_contents(), ->parse(), ->error(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
12 further outcomes, up to 83 instructions
isset($value) && !function_exists() && ->parse() && !is_a() | 66 | function_exists(), header(), exit(), file_get_contents(), ->parse(), ->call(), is_a(), ->getXml(), ->output() |
isset($value) && !function_exists() && ->parse() && is_a() | 69 | function_exists(), header(), exit(), file_get_contents(), ->parse(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
isset($value) && !function_exists() && !is_a() | 70 | function_exists(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
isset($value) && function_exists() && ->parse() && !is_a() | 72 | function_exists(), status_header(), header(), header(), exit(), file_get_contents(), ->parse(), ->call(), is_a(), ->getXml(), ->output() |
isset($value) && !function_exists() && is_a() | 73 | function_exists(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
isset($value) && !function_exists() && !->parse() && !is_a() | 74 | function_exists(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
isset($value) && function_exists() && ->parse() && is_a() | 75 | function_exists(), status_header(), header(), header(), exit(), file_get_contents(), ->parse(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
isset($value) && function_exists() && !is_a() | 76 | function_exists(), status_header(), header(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
isset($value) && !function_exists() && !->parse() && is_a() | 77 | function_exists(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
isset($value) && function_exists() && is_a() | 79 | function_exists(), status_header(), header(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
isset($value) && function_exists() && !->parse() && !is_a() | 80 | function_exists(), status_header(), header(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->error(), ->call(), is_a(), ->getXml(), ->output() |
isset($value) && function_exists() && !->parse() && is_a() | 83 | function_exists(), status_header(), header(), header(), exit(), file_get_contents(), ->parse(), ->error(), ->error(), ->call(), is_a(), ->error(), ->getXml(), ->output() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 83 | 45–83 | 7 | |
| 8.5 | 83 | 45–83 | 7 | |
| 8.4 | 83 | 45–83 | 7 | 2 more instructions than PHP 8.3 |
| 8.3 | 81 | 17–67 | 7 | |
| 8.2 | 81 | 17–67 | 7 | |
| 8.1 | 81 | 17–67 | 7 | |
| 7.4 | 81 | 17–67 | 7 |
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.
Uses · 6
- status_header()Sets HTTP status header.
- IXR_Message::__construct()PHP5 constructor.
- IXR_Server::error()
- IXR_Server::call()
- IXR_Value::__construct()PHP5 constructor.
- IXR_Server::output()
Used by · 1
- IXR_Server::__construct()PHP5 constructor.
Source code
function serve($data = false) { if (!$data) { if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') { if ( function_exists( 'status_header' ) ) { status_header( 405 ); // WP #20986 header( 'Allow: POST' ); } header('Content-Type: text/plain'); // merged from WP #9093 die('XML-RPC server accepts POST requests only.'); } $data = file_get_contents('php://input'); } $this->message = new IXR_Message($data); if (!$this->message->parse()) { $this->error(-32700, 'parse error. not well formed'); } if ($this->message->messageType != 'methodCall') { $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall'); } $result = $this->call($this->message->methodName, $this->message->params); // Is the result an error? if (is_a($result, 'IXR_Error')) { $this->error($result); } // Encode the result $r = new IXR_Value($result); $resultxml = $r->getXml(); // Create the XML $xml = <<<EOD<methodResponse> <params> <param> <value> $resultxml </value> </param> </params></methodResponse> EOD; // Send it $this->output($xml); }Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/IXR/class-IXR-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.