Polylang possible fix for 'Missing argument 2' error
-
I’ve come across a couple of errors from Polylang in combination with another plugin, in my case Profile Builder Pro v.2.1.9.
Warning: Missing argument 2 for PLL_Admin_Sync::add_meta_boxes() in [MY_SERVER_PATH]\wp-content\plugins\polylang\admin\admin-sync.php on line 46 Warning: Missing argument 2 for PLL_Plugins_Compat::cft_copy() in [MY_SERVER_PATH]\wp-content\plugins\polylang\include\plugins-compat.php on line 226After googling for these errors I found that they were more common and not limited to my specific case/plugin. I looked at the code and found that both mentioned functions need the same parameters.
@param string $post_type unused @param object $post current post objectWhat strikes me is that the first parameter
$post_typeis stated as ‘unused’. Is this because of legacy? I’d think an unused parameter could be removed completely, or if it’s a optional parameter, moved to the end of the argument list with a default value.
My guess is that these other plugins send the$postparameter, but it gets handled as the$post_typeparameter while post is still missing.The following edit in both functions made the errors go away, but is this an actual fix or am I likely to break stuff?
– giving the second parameter a default value offalse
– using$post_typeas$postwhen only one parameter is givenfunction [FUNCTION_NAME]($post_type, $post=false) { if ( !$post ) $post = $post_type; [...]
The topic ‘Polylang possible fix for 'Missing argument 2' error’ is closed to new replies.