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

Incorrect toTagsArray return value on empty string #9

Open
ashkarpetin opened this issue Jun 5, 2012 · 2 comments
Open

Incorrect toTagsArray return value on empty string #9

ashkarpetin opened this issue Jun 5, 2012 · 2 comments
Labels

Comments

@ashkarpetin
Copy link

Not sure if it is a bug. If we pass an empty string to toTagsArray function the result is Array ( [0] => ) and incorrect SQL code is generated: ...AND tag0.name = ''...

@samdark
Copy link
Member

samdark commented Jun 5, 2012

It is a bug.

@ashkarpetin
Copy link
Author

Well, I can suggest quick solution:

protected function toTagsArray($tags) {
    if(!is_array($tags)){
        $tags = explode(',', trim(strip_tags($tags), ' ,'));
    }

    array_walk($tags, array($this, 'trim'));
    return array_filter($tags, 'strlen');
}

it also fixes the case like: toTagsArray(array('',''))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants