<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[51786] trunk/src/wp-includes/rest-api/endpoints: Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_REST_Controller::prepare_item_for_response()`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/51786">51786</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/51786","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>hellofromTonya</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-09-09 18:35:34 +0000 (Thu, 09 Sep 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_REST_Controller::prepare_item_for_response()`.
In each child and grandchild class, renames the first parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/38832">[38832]</a>, <a href="https://core.trac.wordpress.org/changeset/39011">[39011]</a>, <a href="https://core.trac.wordpress.org/changeset/39015">[39015]</a>, <a href="https://core.trac.wordpress.org/changeset/39021">[39021]</a>, <a href="https://core.trac.wordpress.org/changeset/39024">[39024]</a>, <a href="https://core.trac.wordpress.org/changeset/39025">[39025]</a>, <a href="https://core.trac.wordpress.org/changeset/39031">[39031]</a>, <a href="https://core.trac.wordpress.org/changeset/39036">[39036]</a>, <a href="https://core.trac.wordpress.org/changeset/43519">[43519]</a>, <a href="https://core.trac.wordpress.org/changeset/43735">[43735]</a>, <a href="https://core.trac.wordpress.org/changeset/43739">[43739]</a>, <a href="https://core.trac.wordpress.org/changeset/43768">[43768]</a>, <a href="https://core.trac.wordpress.org/changeset/46821">[46821]</a>, <a href="https://core.trac.wordpress.org/changeset/48173">[481
73]</a>, <a href="https://core.trac.wordpress.org/changeset/48242">[48242]</a>, <a href="https://core.trac.wordpress.org/changeset/49088">[49088]</a>, <a href="https://core.trac.wordpress.org/changeset/50995">[50995]</a>, <a href="https://core.trac.wordpress.org/changeset/51003">[51003]</a>, <a href="https://core.trac.wordpress.org/changeset/51021">[51021]</a>.
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See <a href="https://core.trac.wordpress.org/ticket/51553">#51553</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestattachmentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestautosavescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestblockdirectorycontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestblocktypescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpatterndirectorycontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpoststatusescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestposttypescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpostscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestrevisionscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestsearchcontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestsidebarscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswpresttaxonomiescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswpresttemplatescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestuserscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestwidgettypescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestattachmentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -707,12 +707,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single attachment output for response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Post $post Attachment object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Post $item Attachment object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $post, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $post = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = parent::prepare_item_for_response( $post, $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestautosavescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -396,13 +396,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares the revision for the REST response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Post $post Post revision object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Post $item Post revision object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $post, $request ) {
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $post = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->revisions_controller->prepare_item_for_response( $post, $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestblockdirectorycontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,12 +109,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Parse block metadata for a block, and prepare it for an API repsonse.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$plugin` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $plugin The plugin metadata.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $item The plugin metadata.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $plugin, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $plugin = $item;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // There might be multiple blocks in a plugin. Only the first block is mapped.
</span><span class="cx" style="display: block; padding: 0 10px"> $block_data = reset( $plugin['blocks'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestblocktypescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -236,16 +236,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a block type object for serialization.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$block_type` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Block_Type $block_type Block type data.
- * @param WP_REST_Request $request Full details about the request.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Block_Type $item Block type data.
+ * @param WP_REST_Request $request Full details about the request.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Block type data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $block_type, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $block_type = $item;
+ $fields = $this->get_fields_for_response( $request );
+ $data = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = $this->get_fields_for_response( $request );
- $data = array();
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( rest_is_field_included( 'attributes', $fields ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $data['attributes'] = $block_type->get_attributes();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1028,16 +1028,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single comment output for response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Comment $comment Comment object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Comment $item Comment object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $comment, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $comment = $item;
+ $fields = $this->get_fields_for_response( $request );
+ $data = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = $this->get_fields_for_response( $request );
- $data = array();
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( 'id', $fields, true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $data['id'] = (int) $comment->comment_ID;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpatterndirectorycontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -199,12 +199,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepare a raw pattern before it's output in an API response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$raw_pattern` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param object $raw_pattern A pattern from api.wordpress.org, before any changes.
- * @param WP_REST_Request $request Request object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param object $item Raw pattern from api.wordpress.org, before any changes.
+ * @param WP_REST_Request $request Request object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $raw_pattern, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $raw_pattern = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $prepared_pattern = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => absint( $raw_pattern->id ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => sanitize_text_field( $raw_pattern->title->rendered ),
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpoststatusescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -213,13 +213,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a post status object for serialization.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$status` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param stdClass $status Post status data.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param stdClass $item Post status data.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Full details about the request.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Post status data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $status, $request ) {
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $status = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestposttypescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,12 +168,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a post type object for serialization.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$post_type` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Post_Type $post_type Post type object.
- * @param WP_REST_Request $request Full details about the request.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Post_Type $item Post type object.
+ * @param WP_REST_Request $request Full details about the request.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $post_type, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $post_type = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomies = wp_list_pluck( $taxonomies, 'name' );
</span><span class="cx" style="display: block; padding: 0 10px"> $base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name;
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpostscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1679,12 +1679,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single post output for response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Post $post Post object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Post $item Post object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $post, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $post = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['post'] = $post;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestrevisionscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -535,12 +535,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares the revision for the REST response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Post $post Post revision object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Post $item Post revision object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $post, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $post = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['post'] = $post;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestsearchcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -186,12 +186,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.6.0 The `$id` parameter can accept a string.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$id` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $id ID of the item to prepare.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $item ID of the item to prepare.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $id, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $item_id = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $handler = $this->get_search_handler( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $handler ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_REST_Response();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -199,7 +202,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data = $handler->prepare_item( $id, $fields );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = $handler->prepare_item( $item_id, $fields );
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = $this->add_additional_fields_to_object( $data, $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,7 +210,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_ensure_response( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $links = $handler->prepare_item_links( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $links = $handler->prepare_item_links( $item_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $links['collection'] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestsidebarscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,19 +262,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single sidebar output for response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$raw_sidebar` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @global array $wp_registered_sidebars The registered sidebars.
</span><span class="cx" style="display: block; padding: 0 10px"> * @global array $wp_registered_widgets The registered widgets.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $raw_sidebar Sidebar instance.
- * @param WP_REST_Request $request Full details about the request.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $item Sidebar instance.
+ * @param WP_REST_Request $request Full details about the request.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Prepared response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $raw_sidebar, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wp_registered_sidebars, $wp_registered_widgets;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $raw_sidebar['id'];
- $sidebar = array( 'id' => $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Restores the more descriptive, specific name for use within this method.
+ $raw_sidebar = $item;
+ $id = $raw_sidebar['id'];
+ $sidebar = array( 'id' => $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $wp_registered_sidebars[ $id ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $registered_sidebar = $wp_registered_sidebars[ $id ];
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswpresttaxonomiescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,13 +200,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a taxonomy object for serialization.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$taxonomy` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Taxonomy $taxonomy Taxonomy data.
- * @param WP_REST_Request $request Full details about the request.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Taxonomy $item Taxonomy data.
+ * @param WP_REST_Request $request Full details about the request.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $taxonomy, $request ) {
- $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $taxonomy = $item;
+ $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array();
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswpresttemplatescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,13 +402,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepare a single template output for response
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$template` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Block_Template $template Template instance.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Block_Template $item Template instance.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response $data
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $template, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- $result = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ // Restores the more descriptive, specific name for use within this method.
+ $template = $item;
+ $result = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'id' => $template->id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'theme' => $template->theme,
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => array( 'raw' => $template->content ),
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,12 +204,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single theme output for response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Theme $theme Theme object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_Theme $item Theme object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $theme, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $theme = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestuserscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -963,13 +963,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single user output for response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_User $user User object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_User $item User object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param WP_REST_Request $request Request object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Response object.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $user, $request ) {
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $user = $item;
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = $this->get_fields_for_response( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestwidgettypescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php 2021-09-09 15:17:20 UTC (rev 51785)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php 2021-09-09 18:35:34 UTC (rev 51786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,14 +263,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepares a widget type object for serialization.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0 Renamed `$widget_type` to `$item` to match parent class for PHP 8 named parameter support.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $widget_type Widget type data.
- * @param WP_REST_Request $request Full details about the request.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $item Widget type data.
+ * @param WP_REST_Request $request Full details about the request.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response Widget type data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function prepare_item_for_response( $widget_type, $request ) {
- $fields = $this->get_fields_for_response( $request );
- $data = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $widget_type = $item;
+ $fields = $this->get_fields_for_response( $request );
+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'id' => $widget_type['id'],
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>