-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX HTTPBulkToolsResponse.addSuccessRecords()
fn
#271
Conversation
This function was trying to merge 2 arrays with PHP fn `array_push()` which was failing if the second parameter was array as well. This fix replaces `array_push()` with `array_merge()` fn. Resolves silverstripe#187
There is not enough information in the linked issue for me to quickly reproduce the bug nor test this PR. Can you please add some detailed reproduction/test steps? |
Hm, I don't really have any special config I think: class A extends DataObject {
private static $many_many = array(
'B' => 'B',
);
public function getCMSFields() {
$fields = parent::getCMSFields();
if ($this->exists()) {
$bulkManager = new BulkManager();
$bulkManager->removeBulkAction(EditHandler::class);
$bulkManager->removeBulkAction(DeleteHandler::class);
$config = $fields->dataFieldByName('B')->getConfig();
$config->addComponent($bulkManager);
$config->getComponentByType(GridFieldAddExistingAutocompleter::class)
->setSearchList(B::get());
$fields->dataFieldByName('B')->setConfig($config);
}
return $fields;
} Does this help? |
That might help, but what I really need are steps to follow. |
In the admin, I see this error when I try to unlink one or more instances of |
I had to set up the following in order to follow those steps: expand to see codeThis is similar to what you had, but with missing use statements and closing brace namespace App;
use Colymba\BulkManager\BulkAction\DeleteHandler;
use Colymba\BulkManager\BulkAction\EditHandler;
use Colymba\BulkManager\BulkManager;
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter;
use SilverStripe\ORM\DataObject;
class A extends DataObject
{
private static $many_many = [
'B' => B::class,
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
if ($this->isInDB()) {
$bulkManager = new BulkManager();
$bulkManager->removeBulkAction(EditHandler::class);
$bulkManager->removeBulkAction(DeleteHandler::class);
$config = $fields->dataFieldByName('B')->getConfig();
$config->addComponent($bulkManager);
$config->getComponentByType(GridFieldAddExistingAutocompleter::class)
->setSearchList(B::get());
$fields->dataFieldByName('B')->setConfig($config);
}
return $fields;
}
} I also needed a namespace App;
use SilverStripe\ORM\DataObject;
class B extends DataObject
{
} namespace App;
use SilverStripe\Admin\ModelAdmin;
class AlphabetAdmin extends ModelAdmin
{
private static $url_segment = 'alphabet';
private static $menu_title = 'ALPHABET';
private static $managed_models = [
A::class,
B::class,
];
} With that I can both reproduce the original error and see that the PR resolves it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Works well locally.
It's a little concerning that this is a bug in the CMS 4 version of the module and hasn't bothered anyone enough to fix until now. 😅
We really need to add tests to this module. If you'd like to tackle that I'd definitely support you in it.
In the meantime, thanks a bunch for fixing this!
Failed JS CI job is unrelated to PR changes. |
Thank you @GuySartorelli for your time working on this as well for the feedback on my PR, I really appreciate it. |
Description
This function was trying to merge 2 arrays with PHP fn
array_push()
which was failing if the second parameter was array as well. This fix replacesarray_push()
witharray_merge()
fn.Manual testing steps
See the linked issue.
Issues
Pull request checklist