Fatal Error in Bulk Edit
-
I’ve found a critical bug in the Bulk Edit feature of Dokan Pro.
When trying to use bulk editing on products, the site crashes with the following error:Uncaught ArgumentCountError: Too few arguments to function WeDevs\DokanPro\ProductBulkEdit::bulk_edit_save_product_brands(), 1 passed in /wp-includes/class-wp-hook.php on line 326 and exactly 2 expectedRoot causeInside
wp-content/plugins/dokan-pro/includes/ProductBulkEdit.php, at line 33, the hook is registered without specifying the number of arguments:add_action( 'dokan_before_bulk_edit_save_single_item', [ $this, 'bulk_edit_save_product_brands' ] );But the callback actually requires two arguments (
$product, $request_data). Because WordPress defaults to only 1, this results in a fatal error. Correct fixThe hook should be registered like this:
add_action( 'dokan_before_bulk_edit_save_single_item', [ $this, 'bulk_edit_save_product_brands' ], 10, 2 );Temporary workaroundUntil this is fixed in core, I’m using a small MU-plugin that removes and re-registers the callback properly. Here’s the code:
<?php /** * Plugin Name: Dokan Bulk Edit Fix – Accepted Args */ add_action('plugins_loaded', function () { $hook = 'dokan_before_bulk_edit_save_single_item'; global $wp_filter; if ( empty($wp_filter[$hook]) || !($wp_filter[$hook] instanceof WP_Hook) ) { return; } $hook_obj = $wp_filter[$hook]; foreach ($hook_obj->callbacks as $priority => $callbacks) { foreach ($callbacks as $id => $cb) { $fn = $cb['function']; $accepted = $cb['accepted_args'] ?? 1; if (is_array($fn) && is_object($fn[0]) && $fn[1] === 'bulk_edit_save_product_brands' && method_exists($fn[0], 'bulk_edit_save_product_brands') && $accepted < 2) { // Remove the wrong registration unset($hook_obj->callbacks[$priority][$id]); // Re-register correctly with 2 args add_action($hook, [$fn[0], 'bulk_edit_save_product_brands'], $priority, 2); } } } }, 20);RequestPlease adjust the hook registration in the official Dokan Pro codebase to avoid this fatal error for all users.
Thanks for your support!
The topic ‘Fatal Error in Bulk Edit’ is closed to new replies.