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

Undefined variable notice when update_post_meta() #7

Open
metodiew opened this issue Apr 16, 2016 · 1 comment
Open

Undefined variable notice when update_post_meta() #7

metodiew opened this issue Apr 16, 2016 · 1 comment

Comments

@metodiew
Copy link

We are using this plugin for one of our client projects and I found an notice for undefined variable when update the post meta. I can't reproduce it right now while I'm testing it, but I'm 100% sure I saw this note in debug.log a few weeks ago.

I've asked about a GitHub repository here https://wordpress.org/support/topic/do-you-have-a-github-repository and I'll send a PR. Take a look and see if it's worth adding this check or not :)

metodiew added a commit to metodiew/wp-bitly that referenced this issue Apr 16, 2016
@metodiew
Copy link
Author

That's quite strange. Either my IDE (Eclipse) is playing with me or GitHub can't track the change.

It looks like the file spacing is a bit odd, at least here on my local installation, but here is the code:
before:

if (is_array($response)) {

        $shortlink = $response['data']['url'];

        update_post_meta($post_id, '_wpbitly', $shortlink);

    }

after:

if (is_array($response)) {
        if ( ! empty( $response['data']['url'] ) ) {
            $shortlink = $response['data']['url'];
            update_post_meta($post_id, '_wpbitly', $shortlink);
        }
    }

Sorry for the multiple comments :)

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

No branches or pull requests

1 participant