colymba / GridFieldBulkEditingTools

SilverStripe GridField Components set for bulk upload and bulk record edit, unlink & delete :package::boom:
BSD 3-Clause "New" or "Revised" License
88 stars 81 forks source link

BulkImage Handler gives errors #33

Closed Firesphere closed 11 years ago

Firesphere commented 11 years ago

In my newsmodule, enabling the Image-editor gives me errors. It breaks when I try $gridFieldConfig->addComponent(new GridFieldBulkImageUpload());

Giving the error "Error at framework/model/UnsavedRelationList.php line 290: Uncaught LogicException: alterDataQuery can't be called on an UnsavedRelationList. (admin/news/News/EditForm/field/News/item/new)"

Do you have any clue what might cause this? I can occasionally reproduce this, seems to be related to another module (maybe?)

colymba commented 11 years ago

Just gave it a quick try and I can't seem to reproduce the error. We are talking about this module (https://github.com/Firesphere/silverstripe-newsmodule) right? :) I've uncommented line 265 or News.php and bulk upload is working etc..

Do you have a back-trace of the error?... just to see the functions being called and so on..

Firesphere commented 11 years ago

Yeh, it's the newsmodule indeed ;)

You can see it happen at newsmodule.casa-laguna.net user/pwd: news@test.com/newsmodule

Here's a long dump:

ERROR [User Error]: Uncaught LogicException: GridField HTML fragment 'bulk-edit-tools' was given content, but not defined.  Perhaps there is a supporting GridField component you need to add?
IN GET /admin/news/News/EditForm/field/News/item/6
Line 324 in /home/casalagu/domains/casa-laguna.net/public_html/newsmodule/framework/forms/gridfield/GridField.php

Source
======
  315:                  }
  316:              }
  317:          }
  318:      }
  319: 
  320:      // Check for any undefined fragments, and if so throw an exception
  321:      // While we're at it, trim whitespace off the elements
  322:      foreach($content as $k => $v) {
  323:          if(empty($fragmentDefined[$k])) {
* 324:              throw new LogicException("GridField HTML fragment '$k' was given content,"
  325:              . " but not defined.  Perhaps there is a supporting GridField component you need to add?");
  326:          }
  327:      }
  328: 
  329:      $total = count($list);
  330:      if($total > 0) {

Trace
=====
GridField->FieldHolder()
ViewableData.php:363

ViewableData->obj(FieldHolder,,,1)
ViewableData.php:436

ViewableData->XML_val(FieldHolder,,1)

call_user_func_array(Array,Array)
SSViewer.php:156

SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:502

SSViewer_DataPresenter->__call(XML_val,Array)
.cache.framework.admin.templates.CMSTabSet.ss:52

SSViewer_DataPresenter->XML_val(FieldHolder,,1)
.cache.framework.admin.templates.CMSTabSet.ss:52

include(/tmp/silverstripe-cache-home-casalagu-domains-casa-laguna.net-public_html-newsmodule/casalagu/.cache.framework.admin.templates.CMSTabSet.ss)
SSViewer.php:894

SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-home-casalagu-domains-casa-laguna.net-public_html-newsmodule/casalagu/.cache.framework.admin.templates.CMSTabSet.ss,TabSet,,Array)
SSViewer.php:960

SSViewer->process(TabSet,)
ViewableData.php:336

ViewableData->renderWith(Array)
TabSet.php:83

TabSet->FieldHolder()
ViewableData.php:363

ViewableData->obj(FieldHolder,,,1)
ViewableData.php:436

ViewableData->XML_val(FieldHolder,,1)

call_user_func_array(Array,Array)
SSViewer.php:156

SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:502

SSViewer_DataPresenter->__call(XML_val,Array)
.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss:160

SSViewer_DataPresenter->XML_val(FieldHolder,,1)
.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss:160

include(/tmp/silverstripe-cache-home-casalagu-domains-casa-laguna.net-public_html-newsmodule/casalagu/.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss)
SSViewer.php:894

SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-home-casalagu-domains-casa-laguna.net-public_html-newsmodule/casalagu/.cache.framework.admin.templates.Includes.LeftAndMain_EditForm.ss,Form,,Array)
SSViewer.php:960

SSViewer->process(Form,)
ViewableData.php:336

ViewableData->renderWith(Array)
Form.php:1236

Form->forTemplate()
ViewableData.php:437

ViewableData->XML_val(ItemEditForm,,1)

call_user_func_array(Array,Array)
SSViewer.php:156

SSViewer_Scope->__call(XML_val,Array)
SSViewer.php:502

SSViewer_DataPresenter->__call(XML_val,Array)
.cache.framework.templates.GridFieldDetailForm.ss:2

SSViewer_DataPresenter->XML_val(ItemEditForm,,1)
.cache.framework.templates.GridFieldDetailForm.ss:2

include(/tmp/silverstripe-cache-home-casalagu-domains-casa-laguna.net-public_html-newsmodule/casalagu/.cache.framework.templates.GridFieldDetailForm.ss)
SSViewer.php:894

SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-home-casalagu-domains-casa-laguna.net-public_html-newsmodule/casalagu/.cache.framework.templates.GridFieldDetailForm.ss,ViewableData_Customised,,Array)
SSViewer.php:960

SSViewer->process(ViewableData_Customised,)
ViewableData.php:336

ViewableData->renderWith(GridFieldDetailForm)
GridFieldDetailForm.php:280

GridFieldDetailForm_ItemRequest->edit(SS_HTTPRequest)
RequestHandler.php:278

RequestHandler->handleAction(SS_HTTPRequest,edit)
RequestHandler.php:190

RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
GridFieldDetailForm.php:87

GridFieldDetailForm->handleItem(GridField,SS_HTTPRequest)
GridField.php:694

GridField->handleRequest(SS_HTTPRequest,DataModel)
RequestHandler.php:212

RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
RequestHandler.php:212

RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153

Controller->handleRequest(SS_HTTPRequest,DataModel)
LeftAndMain.php:397

LeftAndMain->handleRequest(SS_HTTPRequest,DataModel)
AdminRootController.php:89

AdminRootController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:325

Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:143

Director::direct(/admin/news/News/EditForm/field/News/item/6,DataModel)
main.php:128
colymba commented 11 years ago

that seems to be for a different error? due to an old version of GridFieldBulkEditingTools since the bulk-edit-tools html fragment as been removed in the current dev-master. Seems like GridFieldBulkEditingTools.php was removed as it should be but GridFieldBulkImageUpload.php is still trying to used the old html fragment.

Try to update the module again or flushing the cache.

Firesphere commented 11 years ago

That's odd, since it's a fresh installation as far as I know.

I'll give it a few more tests later this evening.

jenniferaslan commented 11 years ago

We are trying a brand-new install of the Firesphere news module, which requires this module. When attempting to edit a previously saved newsarticle, we get this error:

[User Error] Uncaught LogicException: GridField HTML fragment 'bulk-edit-tools' was given content, 
but not defined. Perhaps there is a supporting GridField component you need to add?
GET /admin/news/News/EditForm/field/News/item/4/edit

Line 324 in .../framework/forms/gridfield/GridField.php

I downloaded the news module and its requirements today, to make sure I had the most recent versions, and did a /dev/build. That did not help. I am using SilverStripe Framework 3.0.5 (we are not ready to move to 3.1 yet). Any ideas on how to fix this error?

By the way, we get this same error when creating a news article for the first time as well. When we go to another interface in the CMS after that, we get the message telling us that we have unsaved changes on that page. However, if we click okay and then come back to the News module in the sidebar, we see that the news article was actually saved in some way because we see it listed. It's hard to tell if it's complete, though, because trying to edit the article yields the error and we can't get to the article editing interface.

Firesphere commented 11 years ago

Yes, this issue is related to the GFBET (It's too long to type).

Solution is to fork the Master_3.0 from my repository (don't use the master, it's incompatible with 3.0!) and comment out the following line in silverstripe-newsmodule/code/objects/News.php : 278: $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));

That should fix this issue. I have not yet gotten to fix this for 3.0.5, I'm sorry. If it doesn't, you can even comment out line 272 upto 291 (This disables the slideshow-feature)

Do note you have the correct branches for 3.0.5.

p.s. Upgrading to 3.1 isn't that much work, it's almost as simple as "remove framework and CMS dir and add the new ones to it"

jenniferaslan commented 11 years ago

I had to comment out this whole section, beginning with line 272:

        $gridFieldConfig = GridFieldConfig_RecordEditor::create();
        /** Please make sure you have the latest GridFieldBulkEditingTools installed! Some older versions bug out! */
        $gridFieldConfig->addComponent(new GridFieldBulkImageUpload());
        $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
        $fields->addFieldToTab(
            'Root',
            Tab::create(
                'SlideshowImages',
                _t($this->class . '.SLIDE', 'Slideshow'),
                $gridfield = GridField::create(
                    'SlideshowImage',
                    _t($this->class . '.IMAGES', 'Slideshow Images'),
                    $this->SlideshowImages()
                        ->sort('SortOrder'), 
                    $gridFieldConfig)
            )
        );

Now, I seem to be able to edit the stories and add new ones.

P.S. We haven't started using 3.1 yet because it's not yet offered as the stable download by silverstripe.org. We need our clients’ sites to be on the stable version. We have had some bad experiences in the past when trying to use the pre-releases.

colymba commented 11 years ago

I think it might be a dependency issue. The news module defines "colymba/GridFieldBulkEditingTools" : "*" which might download the master branch instead of the 0.5 which is 3.0 compatible and still has the bulk-edit-tools HTML fragment defined.

Although, am not 100% and will need to run some tests...

jenniferaslan commented 11 years ago

When I downloaded it today, I made sure to get the 0.5 version and not the 1.0 version of this module.

colymba commented 11 years ago

Right. Got a test version running on SS 3.0.X

So I found out that it is indeed a problem with the newsmodule missing a line for the GridFieldConfig of News.php (line 274). Since we are running SS 3.0 we need to use the banch 0.5 of bulkUpload which requires 2 components to be added like so (see readme for info):

$gridFieldConfig->addComponent(new GridFieldBulkEditingTools());
$gridFieldConfig->addComponent(new GridFieldBulkImageUpload());

You need to add GridFieldBulkEditingTools which is the base component and defines the HTML fragment. If you add this, all runs fine! :)

@Firesphere my suggestion is to add that config line to the master_3.0 since it is supposed to be 3.0 compatible. Maybe update the readme/dependencies so it points to SS 3.0.* and bulkUpload 0.5? Might help to avoid confusions?

And a question too, shouldn't the newsmodule dependency be with silverstripe/cms not just silverstripe/framework?

jenniferaslan commented 11 years ago

Thanks colymba. That removes the error and adds the Slideshow tab to the news article editing interface.

colymba commented 11 years ago

No worries :smile: Like @Firesphere mentioned updating to SS 3.1 is a good idea and I am pretty sure the stable is right around the corner (June!?). You'll be able to use the master for bulkUpload which make things more stable etc...

Firesphere commented 11 years ago

Colymba: Yes, I was in the process of updating Master_3.0 to be compatible with 3.0.x again, but I have had a bit of a time-issue (Or, a lack-of-time issue, to be exact ;) ). Issue opened on my repo. (And you're correct, CMS is a dependency too :) )

colymba commented 11 years ago

sounds great. yeah, I though remembering I had an issue a little while back where I tried the newsmodule with just the framework and I was mission Sitree...