When accessing admin/content and using the delete multiple action, this error happens:

( ! ) Fatal error: Call to a member function has() on a non-object in /webs/contrib/drupal8/core/lib/Drupal/Core/Form/ConfirmFormBase.php on line 51

We need to add tests showing the failure and fix the buildForm method by adding the request to it

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Component: views.module » node system
Priority: Normal » Major
Status: Active » Needs review
FileSize
2.43 KB

This seemed to be not the only place.

tim.plunkett’s picture

Issue tags: +Needs tests
pcambra’s picture

Issue tags: -Needs tests
FileSize
4.83 KB
3.54 KB

Removed the part from TranslatableForm as that one needs a deeper fix (everything seems to be broken in that file), I'll open a followup for that one and check with the D8MI guys

Here's a fix for the nodes one with tests, the interdiff is the test file that should not pass the tests plus the removal of the translatable form bit.

pcambra’s picture

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Beautiful. Great work @pcambra!

dawehner’s picture

Nice test coverage!

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.phpundefined
@@ -40,16 +40,85 @@ public function testBulkForm() {
+    $this->assertFalse($node->status, 'Node has been unpublished');

Shouldn't we use the EntityNG way of accessing the data?

pcambra’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
4.48 KB
5.05 KB

Now with moar entityNG :))

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Works for me.

Berdir’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.phpundefined
@@ -40,16 +40,85 @@ public function testBulkForm() {
+    $this->assertTrue($node->isSticky() == NODE_NOT_STICKY);

This shouldn't need the == ... part. isSticky() returns boolean, this only works because of the == condition. Same for a bunch of those isSticky() and isPromoted() below.

+++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.phpundefined
@@ -40,16 +40,85 @@ public function testBulkForm() {
+    $node = entity_load('node', $node->id(), TRUE);
+    $this->assertTrue(empty($node), 'Node has been deleted');

I think an assertNull($node) makes more sense here, checking a node is "empty" feels strange.

Berdir’s picture

Also, definition nitpick.. using methods has nothing to do with NG, the whole point of it is to hide that there's NG below it ;)

pcambra’s picture

Status: Needs work » Needs review
FileSize
4.93 KB
2.9 KB

Thanks for the comments Berdir, this should fix #9

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you berdir for the review.

The points of berdir seems to be adressed.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.phpundefined
@@ -40,16 +40,85 @@ public function testBulkForm() {
+    $this->assertTrue($node->isPublished());
...
+    $this->assertTrue($node->isPublished());

I think we need a message here as the default message is not going to be helpful. I think the message will be "Value FALSE is TRUE." :)

pcambra’s picture

Status: Needs work » Needs review
FileSize
5.08 KB
2.27 KB

Addressed #13

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

webchick’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs followup

This fix looks good for this one page, and the tests look great. Although, it looks like the root problem derives from the fact that the Request parameter on ConfirmFormBase::buildForm() is optional, despite the fact that it's actually not:

public function buildForm(array $form, array &$form_state, Request $request = NULL) {
    $path = $this->getCancelPath();
    // Prepare cancel link.
    if ($request->query->has('destination')) { # <-- Uh-oh!
      $options = drupal_parse_url($request->query->get('destination'));
    }

...so when return parent::buildForm($form, $form_state); happens, boom.

So let's get a follow-up filed to either remove the "= NULL" part of that function signature, or else actually make it optional.

In the meantime, committed and pushed to 8.x. Thanks!

tim.plunkett’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tonytroy’s picture

FileSize
5.08 KB

I had he same problem but the patch drupal-2049569-14.patch didn't work for me (it generated an error) so i add a little modification and now it works fine !

Hope it can help.

tonytroy’s picture

Status: Closed (fixed) » Patch (to be ported)
FileSize
5.08 KB

I had he same problem but the patch drupal-2049569-14.patch didn't work for me (it generated an error) so i add a little modification and now it works fine !

Hope it can help.

jibran’s picture

Status: Patch (to be ported) » Closed (fixed)

@tonytroy Please create a new issue. Describe the new bug and post your patch there. After #16 the patch is the part of drupal core now you have to post the new changes in new issue. Thank you for your help.