Skip to content
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

Fix Plugin Conflict with Give plugin (previously created 500 server error when viewing site admin) #1725

Merged
merged 2 commits into from Dec 11, 2018

Conversation

KZeni
Copy link
Contributor

@KZeni KZeni commented Dec 11, 2018

Fixes #1720.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@KZeni
Copy link
Contributor Author

KZeni commented Dec 11, 2018

@googlebot I've signed it!

@googlebot
Copy link

CLAs look good, thanks!

@@ -1894,7 +1894,10 @@ public static function print_url_as_title( $post ) {
*
* @return string Title.
*/
public static function filter_the_title_in_post_list_table( $title, $post ) {
public static function filter_the_title_in_post_list_table( $title, $post = '' ) {
if($post == ''){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KZeni I found that this function is a callback for the_title hook. In that can we need to update the following thing:

  1. The second parameter for the_title filter in int type, so set default value to 0: https://core.trac.wordpress.org/browser/tags/5.0/src/wp-includes/post-template.php#L158
  2. According to point 1, you can also update $post param value type to int instead of WP_Post in function description comment block.
  3. Use trinary condition $post = empty( $post ) ? get_post() : $post

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found we can simply further. Since $post is only used by get_post_type(), and since this function takes null|int|WP_Post as its type, then we just have to provide an empty default value for $post.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the PR and identifying the problem in the first place.

Please try my alternative patch included here. It will also fix the build error reported by Travis: https://travis-ci.org/ampproject/amp-wp/jobs/466619023#L186

public static function filter_the_title_in_post_list_table( $title, $post = '' ) {
if($post == ''){
$post = get_post();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest the following change instead:

- public static function filter_the_title_in_post_list_table( $title, $post ) {
+ public static function filter_the_title_in_post_list_table( $title, $post = null ) {

@westonruter
Copy link
Member

See also #1723.

@westonruter westonruter changed the base branch from develop to 1.0 December 11, 2018 19:58
@westonruter
Copy link
Member

I'm rebasing this PR against the 1.0 branch so we can merge it straight into the release branch.

@westonruter
Copy link
Member

@KZeni could you please double check that the PR fixes the problem as it stands at the moment?

@westonruter westonruter merged commit a85581f into ampproject:1.0 Dec 11, 2018
@KZeni
Copy link
Contributor Author

KZeni commented Dec 11, 2018

@westonruter I can confirm that the PR as it stands (

- public static function filter_the_title_in_post_list_table( $title, $post ) {
+ public static function filter_the_title_in_post_list_table( $title, $post = null ) {

) is working on my end with both AMP and Give enabled on the site & viewing the site admin.

@westonruter westonruter mentioned this pull request Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants