New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only prepare links if requested on index. #4784
Conversation
CC @dlh01 |
Tests fail. I'm interested in the fact that this patch seeks to prevent the links being added (which is convenient, since we already have access to the current If we can get the tests passing on this patch, I'm 👍 on at minimum not adding them when we can avoid it, regardless of whether we also pursue something more like the other patch later on. |
@kadamwhite Sorry for pushing up unit test fails. Should be fixed now. The idea of this ticket is two fold.
See b7bae69 for referennce, where we did this for other endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me. Thanks for picking it up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @spacedmonkey for the PR, Look good to me left minot nitpick
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Isn't this a breaking change? If someone used This was already a problem in 6.1 when this was added to all the other REST controllers. I'd be wary of making such a breaking change that late in the cycle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @spacedmonkey! I've left some test-related feedback in this review.
* | ||
* @throws Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | |
* @throws Exception |
This shouldn't throw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@costdev This comes from upstream method. See
wordpress-develop/tests/phpunit/includes/abstract-testcase.php
Lines 1151 to 1171 in 252a2c1
public static function text_array_to_dataprovider( $input ) { | |
$data = array(); | |
foreach ( $input as $value ) { | |
if ( ! is_string( $value ) ) { | |
throw new Exception( | |
'All values in the input array should be text strings. Fix the input data.' | |
); | |
} | |
if ( isset( $data[ $value ] ) ) { | |
throw new Exception( | |
"Attempting to add a duplicate data set for value $value to the data provider. Fix the input data." | |
); | |
} | |
$data[ $value ] = array( $value ); | |
} | |
return $data; | |
} |
@swissspidy |
Because that was the existing behavior ever since WordPress 4.7.0. It just worked. This bug fix will break this behavior, simple as that. Even if it's not documented and not intended. Don't get me wrong, I don't have a problem with making this change, as it was already changed for all the other controllers and the index controller isn't used as much. I just like to point out that now is very late to do this change. I suggest doing this early in the 6.4.0 cycle instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a code perspective, this looks good. However, I'm mindful of @swissspidy's comment about landing this early in a cycle. Pascal, we're 3 weeks from 6.4 Beta 1 - Is there still time to consider this one for commit 6.4 in your opinion?
Trac ticket: https://core.trac.wordpress.org/ticket/57902
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.