Support » Plugin: My Movie Database » a few code bugs?

  • Resolved electrolund


    My server is reporting a bunch of constantly possible code issues. They are repeating, but the four separate issues appear to be:

    [28-May-2019 03:48:22 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home5/rfl1973/public_html/wp-content/plugins/my-movie-database/mmdb_templates/partials/movie/movie-cast.php on line 11
    [28-May-2019 03:48:22 UTC] PHP Warning:  usort() expects parameter 1 to be array, null given in /home5/rfl1973/public_html/wp-content/plugins/my-movie-database/includes/tmdb_api/controller/classes/data/Movie.php on line 244
    [28-May-2019 03:48:22 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home5/rfl1973/public_html/wp-content/plugins/my-movie-database/includes/mmdb_views_helper.php on line 42
    [27-May-2019 22:25:19 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home5/rfl1973/public_html/wp-content/plugins/my-movie-database/mmdb_templates/partials/movie/movie-main.php on line 33

    I’m running plugin 1.2.1 and my server is running PHP 7.2.5, WP 5.2.1

    But perhaps more alarming is that the above errors are being reported as follows:
    x43 5/28/2019
    x51 5/27/2019
    x21 5/24/2019
    x16 5/23/2019

    I’m assuming the plugin does a crawl through the site on some period?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter electrolund


    I’d like to propose the following style of fix in movie-cast.php. From some reading here, it would appear that the function getCast() isn’t always returning an array. Perhaps a NULL or boolean FALSE? In any rate, using its contents then breaks.

        if (is_array($results))
    	    foreach ($results as $result): ?>
    	        <div class="<?php echo esc_attr($this->get_multiple_column_css());?> credits">
    	            <img class="img-circle" src="<?php echo esc_url($this->public_files->mmdb_get_profile_image($result, $tmdb)); ?>"/>
    	            <ul class="people">
    	                <li><?php echo esc_html($result['name']); ?></li>
    	                <li><?php echo esc_html__("Role", 'my-movie-db') . ':&nbsp;' . esc_html($result['character']); ?></li>
    	    <?php endforeach; ?>
        <?php endif; ?>

    I would apply this but then all the other files like movie-crew.php, movie-main.php, movie-trailer.php, not to mention elsewhere probably all need similar array integrity checks.

    Do you have a Github?

    Plugin Author Kostas Stathakos


    Hi electrolund, sorry for the late reply and thanks for your feedback as always.

    The plugin does NOT do a crawl of the site. I suspect what you’re seeing to be the result of a search engine bot crawling throught your pages that returns those errors(?).

    I am looking into this right now, I will report back ASAP. It seems to me the proposed solution would work, but it should not have been needed as there is a already a check (which is probably not working as it should?) earlier on in the code execution. What I mean is that the entire template part should not have been executed to begin with if there was no cast available.

    The github rep for this plugin is

    Thank you,

    Plugin Author Kostas Stathakos


    These issues are solved in the 1.3 version, thanks for reporting.

    Plugin Author Kostas Stathakos


    Also fixed in the 1.3 release are

    “server down plugin handling”



Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘a few code bugs?’ is closed to new replies.