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

URL Trim Failing for Select Tags #195

Closed
jrg94 opened this issue Apr 16, 2018 · 6 comments

Comments

@jrg94
Copy link

commented Apr 16, 2018

I recently decided to simplify my site a bit by converting two categories to tags. Now, the breadcrumb throws the following error for those tags:

Warning: trim() expects parameter 1 to be string, 
object given in class.bcn_breadcrumb.php on line 121

Of course, I dug into the code a bit. Apparently, the warning occurs because the plugin is attempting to trim the URL. Here are the offending URLs:

However, all other tags seem to be fine:

I've purged all my caches and whatnot, so I'm not sure what's going on. Any ideas? Thanks!

@jrg94

This comment has been minimized.

Copy link
Author

commented Apr 16, 2018

I did a bit more digging on this. It appears the set_url input, URL, is an error and not a string: Empty Term. Used the following snippet to check the error:

if ( is_wp_error( $url ) ) {
    echo $url->get_error_message();
}

I'll be using this as a workaround for right now. Hopefully, someone can help me dig into this issue a bit.

@mtekk

This comment has been minimized.

Copy link
Owner

commented Apr 17, 2018

The most likely cause of this that I can think of is $wp_query->get_queried_object() returns an empty string or null on those term archives. This isn't something that should be happening (and Breadcrumb NavXT can't really do its job if wp_query is borked). I'd dig into why $wp_query->get_queried_object() is returning null.

@jrg94

This comment has been minimized.

Copy link
Author

commented Apr 17, 2018

Sounds good! I'll take a look.

Btw, here's what those two tags looked like before I added the hacky workaround:

Removed the image due to some private info in the error.

It seems like there's some extra term in the hierarchy that doesn't actually exist.

@mtekk

This comment has been minimized.

Copy link
Owner

commented Apr 17, 2018

Thanks for that update, I think I need to retract my previous statement. What may be the issue here is that there is still a term parent set for those terms. If you are feeling adventurous, try adding var_dump($term->parent) to just above line 553 in class.bcn_breadcrumb_trail.php, it would be interesting to see what that is in this case.

@jrg94

This comment has been minimized.

Copy link
Author

commented Apr 17, 2018

You would be right! The two categories I converted were actually subcategories before they became tags.

I ran that snippet above, and it returned: int(322)

All the other tags report int(0). It seems there's still a linkage there.

@jrg94

This comment has been minimized.

Copy link
Author

commented Apr 17, 2018

Not sure the quickest way to fix this issue, but I ended up just deleting the tags and adding them again. Seemed to do the trick. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.