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

Bug: method monthNo() from class MDBbase should check if empty result #259

Open
jcvignoli opened this issue Aug 20, 2021 · 13 comments
Open

Comments

@jcvignoli
Copy link

jcvignoli commented Aug 20, 2021

Description

method monthNo() in MDBbase doesn't check if it gets an empty result before sending data to Person class.
This results in a undefined index php notice if empty:
int(8) string(22) "Undefined index: 2009," string(124) "Imdb/MdbBase.php" int(171) array(1) { ["mon"]=> string(5) "2009," }

Movies / TV-Shows / Person

Jorge Rivero, nm0729473, when using interviews() method

Comment

method monthNo() hides its failures behind a "@", this is a bad practice.

Proposal for fixing

I'm not an experienced developper at all and I lack of basic php knowldege, but I'd like to suggest a fix anyway:

    protected function monthNo($mon)
    {
	$return = '';
	if ( ! empty ($this->months[$mon]) ) {
	        $return = $this->months[$mon];
        }
        return $return;
    }
@tboothman
Copy link
Owner

Presumably the real bug here is that it's trying to use 2009 as a month

@jcvignoli
Copy link
Author

The bug? You mean, in my code?

@tboothman
Copy link
Owner

In your description you put "Undefined index: 2009" which is surely referring to trying to do $this->months[2009] which would mean something thought 2009 was a month when it used that method.

@jcvignoli
Copy link
Author

Hi there,

I execute the method $this->person->pubmovies() where $this is the current class, and person the Imdb\Person class.

@duck7000
Copy link
Contributor

Like @tboothman said the real problem here is that some interviews don't start with a date but with a year like jorge rivero but others too. (Jack Nicholson)
The method used here is parsearticles() in person.php line 935.
This line get wrong data (year instead of date) and parses it to monthNo, hence the error.
I'm not really sure how to fix that, it would involve restructuring the preg_match from line 931 i guess?
Or simply leave out the month number?

@duck7000
Copy link
Contributor

I'm working on this to fix it, there are a lot of problems with parsearticles()

@duck7000
Copy link
Contributor

@jcvignoli can you test my PR to ensure it works correctly?
if so, @tboothman it would be nice if it get merged into master so it can benefit everyone?

@jcvignoli
Copy link
Author

@duck7000 it works! :)

@duck7000
Copy link
Contributor

Thanks for testing!
Now we have to wait if and when it will be merged, but in the meantime you or anyone else at least can use it.

@duck7000
Copy link
Contributor

Still waiting for this to be reviewed/merged

@duck7000 duck7000 mentioned this issue Oct 22, 2022
@duck7000
Copy link
Contributor

Too bad for you i closed this PR, i have enough of the lax attitude here.
I hope you did get the fixed version, if not we can arrange something.

@jcvignoli
Copy link
Author

Hope it will be included in a next release!

@duck7000
Copy link
Contributor

I doubt it..

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

3 participants