• I think I found a possible bug in the JW Player Plugin.
    It’s realated to another bug fix, described here:
    https://www.ads-software.com/support/topic/plugin-jw-player-plugin-for-wordpress-jw-player-breaks-wordpress-media-editor?replies=2

    If you enable wp_debug, you can see lots of Notices everywhere, as the variable $post doesn’t exist in the following function, so I suppose it’s not working correctly:

    function url_attached_file($file, $attachment_id) {
      $external = get_post_meta($attachment_id, LONGTAIL_KEY . "external", true);
      if (substr($post["post_mime_type"], 0, 5) == "video" || $external) {
        $upload_dir = wp_upload_dir();
        return str_replace($upload_dir["basedir"] . "/", "", $file);
      }
      return $file;
    }

    How can I get the $post in that function?
    Global variable? Third parameter?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • JW Player

    (@longtail-video)

    @zoltanthemage,

    Thank you for posting this. I will investigate this. Look for a possible fix in an upcoming update.

    Thanks.

    Hi
    I can confirm that a lot of notices are displaying when WP_DEBUG option is turned on. Those messages are not preventing the plugin to work, but they are very annoying and force to set WP_DEBUG option off to use the plugin correctly.

    The main source of the notice are undefined variable that are not checked.
    Example :
    Notice: Undefined index: html5_file in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWShortcode.php on line 235
    if the html5 file has not not been specified.
    The line 235 is the following :
    $html5 = $atts["html5_file"];
    You should not access “html5_file” index of $atts array without verifying its existence:
    $html5 = array_key_exists("html5_file", $atts) ? $atts["html5_file"] : 'default_value';

    In the above example with the $post variable, you should declare it before using it. $post is a global WP variable that holds the current post :

    function url_attached_file($file, $attachment_id) {
        global $post;
        $minetype = $post["post_mime_type"];
        [...]
    }

    Here is a list of notice I have :
    On the front end, when displaying a video :

    Notice: Undefined index: html5_file in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWShortcode.php on line 235
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWShortcode.php on line 243
    
    Notice: Undefined index: download_file in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWShortcode.php on line 246
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWShortcode.php on line 254

    On the backend, when displaying the option page or when showing the add video tab :

    Notice: Undefined index: jwplayermodule_state in wp-content/plugins/jw-player-plugin-for-wordpress/admin/AdminContext.php on line 27 
    
    Notice: Undefined index: jwplayermodule_config in wp-content/plugins/jw-player-plugin-for-wordpress/admin/AdminContext.php on line 45 
    
    Notice: Undefined index: jwplayermodule_config in wp-content/plugins/jw-player-plugin-for-wordpress/admin/AdminContext.php on line 111 
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/framework/LongTailFramework.php on line 39 
    
    Undefined variable: errors in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWMediaFunctions.php on line 371 
    
    Notice: Undefined variable: id in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWURLImportManager.php on line 99 
    
    Notice: Undefined index: paged in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 25 
    
    Notice: Undefined variable: new_playlist_id in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 80
    
    Notice: Undefined index: paged in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 227
    
    Notice: Undefined index: 196 in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 300 
    
    Notice: Undefined index: 193 in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 300 
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 305 
    
    Notice: get_attachment_icon_src est déprécié depuis la version 2.5! Utilisez wp_get_attachment_image_src() à la place. in wp-includes/functions.php on line 3303 
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/media/EmbedManager.php on line 305
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWMediaFunctions.php on line 441 
    
    Notice: Trying to get property of non-object in wp-content/plugins/jw-player-plugin-for-wordpress/media/JWMediaFunctions.php on line 260

    I forgot another issue that needs to be solved to remove the warnings. The $post variable is not an array but an object, so you have to use the -> operator to access its properties. Here is the right syntax :

    function url_attached_file($file, $attachment_id) {
      global $post;
      $external = get_post_meta($attachment_id, LONGTAIL_KEY . "external", true);
      if (substr($post->post_mime_type, 0, 5) == "video" || $external) {
         $upload_dir = wp_upload_dir();
         return str_replace($upload_dir["basedir"] . "/", "", $file);
       }
       return $file;
    }
    JW Player

    (@longtail-video)

    @fab1en,

    Thank you for point this out. I’ve begun work on updating the necessary code to remove the notices.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: JW Player Plugin for WordPress] small bug giving lots of Notices’ is closed to new replies.