Support » Plugin: Disable User Gravatar » php7.2 Deprecated: Function create_function() is deprecated

  • I just migrated php to 7.2 and reviewing all installed plugins. I do have problems with your plugin:
    Deprecated: Function create_function() is deprecated in disable-user-gravatar/disable-user-gravatar.php on line 35
    add_filter('user_profile_picture_description', create_function('$desc', 'return "";'));
    This should be really easy to fix by using an anonymous function or a utility function of WordPress:
    add_filter('user_profile_picture_description', '__return_empty_string' );
    I have tested this by modifying the filter to always return “Hello World”. After this I verified the behaviour by looking under a profile picture and “Hello World” was printed.
    Then I applied my Patch to use '__return_empty_string'. After this there is no output there.

    1. I’m not sure if __return_empty_string is appropriate because of the parameters. But I don’t get an error complaining about missing parameters of __return_empty_string.
    2. According to the user_profile_picture_description hook there is a second parameter $profileuser since WordPress 4.7.0. This one is missing in your current implementation by the way.

    Target WordPress version: since this fix uses__return_empty_string which was introduced in 3.7.0 the target version might increase. If this is not acceptable just use a anonymous function.

    Please note: you use __return_true which was introduced in 3.0.0. But the plugin min version is 2.7.0. Please increase to at least 3.0.0.

    • This topic was modified 3 months, 1 week ago by  No3x. Reason: added code tags
    • This topic was modified 3 months, 1 week ago by  No3x. Reason: added one more code tag
    • This topic was modified 3 months, 1 week ago by  No3x. Reason: fixed grammar
    • This topic was modified 3 months, 1 week ago by  No3x.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marcus

    (@netweblogic)

    Hi,

    Thanks for your suggestion.

    __return_empty_string is exactly what I’ll be adding, I’ve got that patch locally and have been meaning to update but short on time.

    I hadn’t thought of the target version, but yes good point. I think frankly 4.0 could even be the minimum, that’s already quite old 🙂

    Hopefully nobody uses such an old WordPress version. If you increase to 4.0 then you should also replace the deprecated (in version 3.3.0) get_user_by_email($id_or_email) by get_user_by('email', $id_or_email);.

    I’m looking forward to your new release.

    • This reply was modified 3 months, 1 week ago by  No3x.
    Plugin Author Marcus

    (@netweblogic)

    noted, thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.