Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chr.fritsch created an issue. See original summary.

chr.fritsch’s picture

chr.fritsch’s picture

Status: Active » Needs review
FileSize
21.37 KB

Here comes the first patch

Status: Needs review » Needs work

The last submitted patch, 3: pinterest_port_to_the-2905333-3.patch, failed testing. View results

gg4’s picture

@chr.fritsch Thanks! I will review and cut a 8.x-2.x early next week.

gg4’s picture

  1. +++ /dev/null
    @@ -1,14 +0,0 @@
    -{
    

    Why is composer.json being removed?

  2. +++ b/config/schema/media_entity_pinterest.schema.yml
    @@ -6,13 +6,6 @@ media_entity_pinterest.settings:
    +  label: '"Slideshow" media source configuration'
    

    Label seems incorrect.

  3. +++ b/tests/src/Unit/ConstraintsTest.php
    @@ -11,7 +11,7 @@ use Drupal\Tests\UnitTestCase;
    + * @group media_entity_pinterest
    

    I think we might want to run this with the rest of the tests in the media_entity group.

chr.fritsch’s picture

1. There is no need for it. d.o. auto generates one out of the info.yml
2. Fixed
3. Changed to media. I don't have any strong opinions on that

Status: Needs review » Needs work

The last submitted patch, 7: pinterest_port_to_the-2905333-7.patch, failed testing. View results

Mixologic’s picture

This is an issue with drupalci where it doesnt handle deleting a composer.json properly. See #2868739: deleting composer.json should not use ancillary directory

My suggestion is either to leave it in place (it doesnt actually need to be removed, composer facade handles its existence), or, remove it in a separate, isolated patch.

gg4’s picture

gg4’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: pinterest_port_to_the-2905333-10.patch, failed testing. View results

gg4’s picture

Status: Needs work » Needs review
FileSize
20.73 KB

Patch attached based on #7 with composer.json kept intact.

phenaproxima’s picture

Status: Needs review » Needs work

This patch looks fantastic. I found a few things you might consider changing before committing this, but nothing serious.

  1. +++ b/media_entity_pinterest.install
    @@ -5,11 +5,75 @@
    +  if (\Drupal::moduleHandler()->moduleExists('user')) {
    

    User is a required module and is always installed, so no need to check if it exists :)

  2. +++ b/media_entity_pinterest.install
    @@ -5,11 +5,75 @@
    +    user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['view media']);
    +    user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['view media']);
    

    This seems a bit presumptuous, no?

  3. +++ b/media_entity_pinterest.install
    @@ -5,11 +5,75 @@
    +function media_entity_pinterest_requirements($phase) {
    

    I'm not sure you need this function. I could be wrong, but I'm pretty sure that core's media_requirements() covers all of this.

  4. +++ b/src/Plugin/media/Source/Pinterest.php
    @@ -0,0 +1,156 @@
    +    // TODO: Implement providedFields() method.
    

    I'm pretty sure providedFields() is now getMetadataAttributes(), so I think this TODO can be removed :)

  5. +++ b/src/Plugin/media/Source/Pinterest.php
    @@ -0,0 +1,156 @@
    +      return FALSE;
    

    Again, I could be wrong but I believe that NULL is the value getMetadata() should return if it runs into trouble.

  6. +++ b/src/Plugin/media/Source/Pinterest.php
    @@ -0,0 +1,156 @@
    +      case 'id':
    +        if ($matches['id']) {
    +          return $matches['id'];
    +        }
    +        return FALSE;
    +
    +      case 'board':
    +        if ($matches['slug']) {
    +          return $matches['slug'];
    +        }
    +        return FALSE;
    +
    +      case 'user':
    +        if ($matches['username']) {
    +          return $matches['username'];
    +        }
    +        return FALSE;
    +    }
    +
    +    return FALSE;
    

    I think all of these return FALSEs should be NULL.

  7. +++ b/src/Plugin/media/Source/Pinterest.php
    @@ -0,0 +1,156 @@
    +    if (isset($this->configuration['source_field'])) {
    

    All media sources *require* a configured source field, so I'm not sure this isset() check is actually necessary.

  8. +++ b/src/Plugin/media/Source/Pinterest.php
    @@ -0,0 +1,156 @@
    +      $source_field = $this->configuration['source_field'];
    

    Nit: You could do $this->getSourceFieldDefinition()->getName() here.

chr.fritsch’s picture

Status: Needs work » Needs review
FileSize
18.18 KB
4.85 KB

Fixed all the nits

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. Thanks, @chr.fritsch!

  • bonus committed d769058 on 8.x-2.x authored by chr.fritsch
    Issue #2905333 by chr.fritsch, bonus: Pinterest Port to the proposed...
gg4’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @chr.fritsch and @phenaproxima. Much appreciated.

Also, since you both have spent some time with this code, any chance you could RBTC #2841662: [D8] Media entity Pinterest so we can get security coverage on this module?

Status: Fixed » Closed (fixed)

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