• Resolved hchkscd

    (@hchkscd)


    Hi,
    We have a PHP Notice with WordPress 5.5.1.
    Thanks.

    PHP Notice: register_rest_route est appelée de la mauvaise manière. La définition de la route de l’API REST pour shariff/v1/share_counts n’a pas l’argument permission_callback nécessaire. Pour les routes de l’API REST qui sont destinées à être publiques, utilisez __return_true comme rappel de permission. (Ce message a été ajouté à la version 5.5.0.) in /wp-includes/functions.php on line 5225

    PHP Notice: register_rest_route is called the wrong way. Setting the REST API route for shariff/v1/share_counts does not have the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as a permission callback. (This message was added in version 5.5.0.) In /wp-includes/functions.php on line 5225

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi,
    same here.

    REST API changes in WordPress 5.5 are documented here:

    REST API changes in WordPress 5.5

    My change in the shariff.php file after line 210 to add that line:

    'permission_callback' => '__return_true',

    The function (shariff.php, line 187-215) after the my change:

    /** Register the wp rest api route and sanitize the input */
    function shariff3uu_sanitize_api() {
    	register_rest_route(
    		'shariff/v1',
    		'/share_counts',
    		array(
    			'methods'  => 'GET',
    			'callback' => 'shariff3uu_share_counts',
    			'args'     => array(
    				'url'       => array(
    					'sanitize_callback' => 'esc_url',
    					'required'          => true,
    					'description'       => __( 'URL of the post or page to request share counts for.', 'shariff' ),
    				),
    				'services'  => array(
    					'sanitize_callback' => 'sanitize_text_field',
    					'required'          => true,
    					'description'       => __( 'A list of services separated by |. Example: twitter|facebook|xing', 'shariff' ),
    				),
    				'timestamp' => array(
    					'sanitize_callback' => 'absint',
    					'description'       => __( 'Timestamp of the last update of the post. Used for dynamic cache lifespan.', 'shariff' ),
    				),
    			),
    			'permission_callback' => '__return_true',
    		)
    	);
    }
    add_action( 'rest_api_init', 'shariff3uu_sanitize_api' );

    I am getting this error as well. Disappointed to say that I will not be able to use Shariff until this is fixed. It’s a great plugin.

    @kometschuh
    Thank you for debugging this and providing the code. I am disappointed to see the dev has not even acknowledged your help, much less fix the problem. I am not a coder and will have to wait til the plugin is fixed.

    Plugin Author Jan-Peter

    (@starguide)

    Because it is not an error. It is a notice. Something you can only see if you have WP_DEBUG turned on, which you should never have in the first place on a production site.

    Thank you @kometschuh it will be updated with the next release.

    This is a community forum and plugin. All support and updates are provided from normal users in their spare time. There is no obligation whatsoever to help anyone for free. In 2020 there are definitely other things more important than to maintain a share button plugin.

    Hi @starguide,

    Thanks very much for your post and the plan for the update.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP Notice’ is closed to new replies.