WordPress.org

Plugin Directory

seo-title-tag

Opened 6 years ago

Last modified 6 years ago

#1415 new defect

[Plugin SEO Ultimate] Bug when post has only one tag

Reported by: bear_beavis Owned by: JohnLamansky
Priority: high Severity: critical
Plugin: seo-title-tag Keywords: seo-ultimate
Cc:

Description

Hi,

We are using version 6.9.7 of plugin SEO Ultimate, and it seems there is as bug when a post has only one tag :

We got this error :

Object of class WP_Error could not be converted to string wp-content/plugins/seo-ultimate/modules/titles/titles.php on line 273

After debugging and looking at the code (line 246 to 273)

$variables = array(
                          '{blog}' => get_bloginfo('name')
                        , '{tagline}' => get_bloginfo('description')
                        , '{post}' => $post_title
                        , '{page}' => $post_title
                        , '{page_parent}' => $parent_title
                        , '{category}' => $cat_title
                        , '{categories}' => $cat_titles
                        , '{category_description}' => $cat_desc
                        , '{tag}' => $tag_title
                        , '{tag_description}' => $tag_desc
                        , '{tags}' => su_lang_implode(get_the_tags($post_id), 'name', true)
                        , '{daynum}' => $daynum
                        , '{day}' => $day
                        , '{monthnum}' => $monthnum
                        , '{month}' => $month
                        , '{year}' => $year
                        , '{author}' => $author['name']
                        , '{author_name}' => $author['name']
                        , '{author_username}' => $author['username']
                        , '{author_firstname}' => $author['firstname']
                        , '{author_lastname}' => $author['lastname']
                        , '{author_nickname}' => $author['nickname']
                        , '{query}' => su_esc_attr(get_search_query())
                        , '{ucquery}' => su_esc_attr(ucwords(get_search_query()))
                        , '{url_words}' => $this->get_url_words($_SERVER['REQUEST_URI'])
                );
                $title = str_replace(array_keys($variables), array_values($variables), htmlspecialchars($format));

When a post has only one tag, get_the_tags does not return an array but a tag object. In this case su_lang_implode also returns an object causing str_replace to trigger an error.

We found a work-around replacing the line :

, '{tags}' => su_lang_implode(get_the_tags($post_id), 'name', true)

with

, '{tags}' => su_lang_implode( (array) get_the_tags($post_id), 'name', true)

Can you take a look at this issue ?

Thanks.

Change History (1)

comment:1 @bear_beavis6 years ago

  • Summary changed from [Plugin SEO Ultimate] Bug when post as only one tag to [Plugin SEO Ultimate] Bug when post has only one tag
Note: See TracTickets for help on using tickets.