Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David Hernández’s picture

Assigned: Unassigned » David Hernández

Working on this.

David Hernández’s picture

Assigned: David Hernández » Unassigned
FileSize
4.68 KB

I'm unassigning this issue from me as I will be helping somewhere else. Maybe I will be back to this later, but as I'm not sure, I prefer to leave it unassigned, just in case anyone wants to continue with it.

Anyways, I'm adding a initial patch with part of the changes (most of the getters). Is still necessary to create the required setters and update the code of the CustomBlock class.

YesCT’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, custombloginterface-with-methods-2028035-2.patch, failed testing.

David Hernández’s picture

Assigned: Unassigned » David Hernández

Reassigning this back to me.

David Hernández’s picture

Attaching an almost-green patch. Still working on it.

David Hernández’s picture

Status: Needs work » Needs review

Changing status

Status: Needs review » Needs work

The last submitted patch, customblockinterface-with-methods-2028035-6.patch, failed testing.

David Hernández’s picture

Assigned: David Hernández » Unassigned

Unassigned

tim.plunkett’s picture

Component: block.module » custom_block.module
Berdir’s picture

Status: Needs work » Needs review
FileSize
23.76 KB

Removed unnecessary methods and converted a lot of code to method calls and related cleanup.

Status: Needs review » Needs work

The last submitted patch, customblockinterface-with-methods-2028035-11.patch, failed testing.

larowlan’s picture

Issue tags: +#pnx-sprint

Tagging

Berdir’s picture

Fixed the revision id test, I have no idea how that is passing right now, it is wrong.

   // This will create a new revision that is not "front facing".
     // Save this as a non-default revision.
     $loaded->setNewRevision();
-    $loaded->isDefaultRevision = FALSE;
+    $loaded->isDefaultRevision(FALSE);
     $loaded->block_body = $this->randomName(8);
     $loaded->save();

isDefaultRevision is a protected property that goes through __set() which adds it to $this->values. Not what you want...

Removed getInfo() in favor of label().

Berdir’s picture

Issue tags: +#pnx-sprint

Ups.

Status: Needs review » Needs work

The last submitted patch, customblockinterface-with-methods-2028035-14.patch, failed testing.

DizzyC’s picture

Assigned: Unassigned » DizzyC
johnennew’s picture

Status: Needs work » Needs review
FileSize
2.59 KB
25.37 KB

Tests are failing correctly as last patch breaks the ability to translate a block using the content_translate module.

Attached is a patch which should pass the tests (they do locally). Why this small change makes a difference I do not know and makes no sense to me!

Fragment which caused the tests to pass and fixes the functionality with content translation from the patch in #14. In core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php

     $form['langcode'] = array(
       '#title' => t('Language'),
       '#type' => 'language_select',
-      '#default_value' => $block->language()->id,
+      '#default_value' => $block->langcode->value,
       '#languages' => Language::STATE_ALL,
       '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'],
     );

I assume we do not want to store the langcode on the block class. The original patch in #14 seems to be the right way to set the langcode on a new block which is a translation of another but doing this breaks the association between the newly translated block and the original block. It appears like the langcode form field is doing different things in different situations which makes is difficult to diagnose.

Berdir’s picture

Assigned: DizzyC » plach

Uh, oh, thanks for tracking that down!

Seems like a case for @plach to look into.

plach’s picture

No time to look into this right now, but the change does not look good to me at first sight, although it fixes tests. We want to encourage people to always use the langcode() method otherwise translations would stop working. Did you try $block->getUntranslated()->language()->id?

Berdir’s picture

Ah, right. ->langcode is not translatable, so $entity->getTranslation('de')->langcode->value is still the old langcode.

I remember that we had to do this as well for the config/content entity issue.

That's... confusing. Can we do something about it?

Berdir’s picture

Status: Needs review » Needs work

Someone up for a quick re-roll and try the approach suggested in #20?

johnennew’s picture

Assigned: plach » johnennew
Status: Needs work » Active

Looks like this is needs a re-roll as well. I'll give it a go now

johnennew’s picture

Status: Active » Needs review
FileSize
25.06 KB

@plach's suggestion in #20 appears to work, rerolled patch attached. Interdiff isn't working.

Berdir’s picture

Status: Needs review » Needs work
Issue tags: +Novice, +#pnx-sprint, +Entity Field API

The last submitted patch, drupal8.custom-block.module.2028035-24.patch, failed testing.

vladan.me’s picture

Status: Needs work » Needs review
FileSize
24.63 KB

Trying to reroll #24

Berdir’s picture

Assigned: johnennew » Unassigned
Issue summary: View changes
Status: Needs review » Needs work
  1. +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
    @@ -27,11 +27,11 @@ class CustomBlockFormController extends ContentEntityFormController {
         // Set up default values, if required.
    -    $block_type = entity_load('custom_block_type', $block->type->value);
    -    // If this is a new custom block, fill in the default values.
    -    if (isset($block->id->value)) {
    -      $block->set('log', NULL);
    +    if (!$block->isNew()) {
    +      $block->setRevisionLog(NULL);
         }
    +
    +    $block_type = entity_load('custom_block_type', $block->bundle());
         // Always use the default revision setting.
    

    Looks like the $block_type assignment moved below the other change, making the diff bigger than it has to by. Try to move it back into the original order to keep the necessary changes as small as possible.

  2. +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
    @@ -49,27 +49,30 @@ public function form(array $form, array &$form_state) {
         // Basic block information.
         // These elements are just values so they are not even sent to the client.
    -    foreach (array('revision_id', 'id') as $key) {
    -      $form[$key] = array(
    -        '#type' => 'value',
    -        '#value' => $block->$key->value,
    -      );
    -    }
    +    $form['id'] = array(
    +      '#type' => 'value',
    +      '#value' => $block->id(),
    +    );
    +
    +    $form['revision_id'] = array(
    +      '#type' => 'value',
    +      '#value' => $block->getRevisionId(),
    +    );
    

    Now that I look at this again, why do we even need this stuff? Shouldn't be here IMHO.

    Try to remove those two form definitions and see what happens.

  3. +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php
    @@ -137,18 +77,13 @@ public function createDuplicate() {
     
    -  /**
    -   * {@inheritdoc}
    -   */
    -  public function getRevisionId() {
    -    return $this->revision_id->value;
    -  }
    
    @@ -309,4 +227,34 @@ public function getChangedTime() {
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getRevisionId() {
    +    return $this->get('revision_id')->value;
    +  }
    

    It seems this is just moved to a different location. Just like the first example, try to move it to the original location to keep the patch size down and make it easier to review.

vladan.me’s picture

Uploading patch according to #28

vladan.me’s picture

Status: Needs work » Needs review
Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockInterface.php
    @@ -16,6 +16,36 @@
    +   *
    +   * @param string info
    

    info needs to be $info, didn't notice that before.

  2. +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockInterface.php
    @@ -16,6 +16,36 @@
    +   * @return \Drupal\custom_block\CustomBlock
    +   *   The class instance that this method is called on.
    

    Should be CustomBlock*Interface*.

vladan.me’s picture

Status: Needs work » Needs review
FileSize
1.38 KB
24.36 KB

Looking good now?

larowlan’s picture

Status: Needs review » Needs work

The last submitted patch, 32: drupal8_custom-block-module-1.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
Issue tags: -#pnx-sprint
FileSize
23.84 KB

no longer applies, re-roll

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

This is ready, I only rerolled so reckon I'm clear to Rtbc

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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