Comments

jfs.csantos created an issue. See original summary.

marcoscano’s picture

Status: Needs work » Needs review
StatusFileSize
new89.85 KB

Here a first version of the port.

In manual testing, I'm having some issues to upload files to the API, that disappear when I step through the code with the debugger, so I'm assuming some race condition must be happening. I have the same error with the current 8.x-1.x HEAD, though, so I wonder if it's due to my local setup or the testing account I'm using.

Some review, testing and feedback with this patch would be appreciated.

marcoscano’s picture

StatusFileSize
new89.75 KB
new672 bytes

Simplifying the check a bit.

berdir’s picture

  1. +++ b/bynder.info.yml
    @@ -6,7 +6,7 @@ core: 8.x
       - dropzonejs:dropzonejs
    

    should we also specifiy that this needs 8.x-2.x here?

  2. +++ b/bynder.install
    @@ -42,8 +42,20 @@ function bynder_requirements($phase) {
    +    // When reinstalling the media module we don't want to copy the icons when
    

    copy paste leftover (we shouldn't have deleted that function ;))

marcoscano’s picture

StatusFileSize
new1.21 KB
new89.76 KB

@Berdir thanks for reviewing!

jfs.csantos’s picture

Also, shouldn't the entity_browser be on 2.0 as well?

marcoscano’s picture

StatusFileSize
new89.84 KB
new840 bytes

We can make that a requirement to reduce confusion, but technically we don't depend on the new EB widget that was added in 2.x, so EB 1.x should work fine as well.

But it's true that if a site is using Media in core, it's probably a good idea to have all modules that deal with media entities in their 2.x branches.

Apparently, we weren't requiring Entity Browser in the info file, so I'm adding the entry with the 2.x restriction.

Thanks!

berdir’s picture

I think the dependency to entity_browser is kind of optional and only the demo module has an explicit dependency on it?

marcoscano’s picture

Oh that could indeed be the reason it was not required before.

However, unless I'm missing something, being the main integration with the API done through EB widgets (search / upload), I wonder what the use cases for using this module without it are? We would have a Media type (bundle) and a formatter, but all entities would need to be created through the standalone form, entering the remote UUID by hand?

Also, in the project page we state that Entity Browser is a requirement, so users probably already expect that. I believe it may make sense to include it as a hard requirement as well in the main module.

Thoughts?

marcoscano’s picture

Just remembered something relevant to take into account if we keep those minimum version restrictions in the info file.

Drupal doesn't parse info file versions for projects not packaged on Drupal.org, so if a site is using DropzoneJS or Entity Browser checked out from git or a -dev package, those restrictions will not be met, even if they are on the 2.x branches. Not sure if this is an issue in this case, but thought it would be worth mentioning here.

marcoscano’s picture

StatusFileSize
new90.27 KB
new1.17 KB

This prevents the race condition issue I experienced in some scenarios with the upload widget.

jfs.csantos’s picture

@marcoscano Just tried with both standard and lightning profiles on a fresh install and it works fine, good work mate!
Can you you try and test the update path from 8.4 -> 8.5, I'll give it a go as well.

Also, should we release this as a new 8.x-2.x branch since it's a breaking update?

jfs.csantos’s picture

StatusFileSize
new90.23 KB
new453 bytes

Just tried to install the bynder_demo module with the Lightning and had this issue:
[error] Configuration objects (core.entity_view_mode.media.thumbnail) provided by bynder_demo already exist in active configuration

Apparently the lightning_media module already sets up the core.entity_view_mode.media.thumbnail, so no need to have it there.

marcoscano’s picture

Hi!

Yes, I belive it is a good idea to release this as a 8.x-2.x branch, to make a clear difference from the existing branch. Other modules that integrate with Media Entity in contrib are doing the same for their branches compatible with media in core.

diff --git a/modules/demo/config/install/core.entity_view_mode.media.thumbnail.yml b/modules/demo/config/install/core.entity_view_mode.media.thumbnail.yml
deleted file mode 100644

Maybe instead of removing the file, we could move it into the modules/demo/config/optional/ instead? This way sites not using the lightning profile would get it, and it wouldn't be installed if already present.

marcoscano’s picture

StatusFileSize
new90.45 KB
new341 bytes

Here's a patch that implements the suggestion in #14

jfs.csantos’s picture

@marcoscano The upgrade path is fine, I just couldn't get the bynder_demo module to install on a clean site though. I tried with the latest patch and it still complains.
[error] Configuration objects provided by <em class="placeholder">bynder_demo</em> have unmet dependencies: <em class="placeholder">core.entity_view_display.media.bynder.thumbnail (core.entity_view_mode.media.thumbnail)</em>

Is this because the config in optional is only set up after the install one? I'm not sure how can we re-arrange the imports here.

marcoscano’s picture

StatusFileSize
new92.79 KB
new2.93 KB

Thanks for the feedback!

Yep, the order is important here... moving all of them to optional seems to be enough to have all of them enabled at the same time, and they won't try to override an existing config object that may exist with the same name.

jfs.csantos’s picture

Status: Needs review » Needs work
StatusFileSize
new5.59 KB
new328 bytes
new673 bytes

I don't think that worked Marco. It does install the module without any problems, but now there's an issue during the upload. Basically the file is uploaded and the media is added to the library, but it fails to add it to the field. See errors attached.

Can you test installing the bynder_demo module and uploading a file before submitting the new version please?

marcoscano’s picture

Hi João,

I'm trying to reproduce the issue, but I'm not being able to connect to the API. Is there any connectivity issue at this moment?

Server error: `GET https://*****.getbynder.com/api/v4/media/?limit=15&page=1&type=image&total=1` resulted in a `500 Internal Server Error` response:
{"message":"An error occurred","statuscode":500}

Thanks!

marcoscano’s picture

Could you please share steps to reproduce?

I have just tested again in a new install (standard profile), and although I still have the API errors like:

Method: getMediaList throws error with message: Server error: `GET https://*****.getbynder.com/api/v4/media/?limit=15&page=1&type=image&total=1` resulted in a `500 Internal Server Error` response: {"message":"An error occurred","statuscode":500}
Method: getMediaInfo throws error with message: Server error: `GET https://*****.getbynder.com/api/v4/media/C634B855-B97A-405D-AF9839DF4457621C/` resulted in a `500 Internal Server Error` response: {"message":"An error occurred","statuscode":500}

which prevent the upload from finishing, I don't experience the errors you mentioned in #18. Any additional info to help reproducing it would be appreciated.

Thanks!

jfs.csantos’s picture

Hi there Marcos,

I don't think we had any API issues, these are the steps to reproduce the errors found:

  • Install Drupal site with standard profile.
  • Install Bynder Demo module directly, through drush.
  • Set up Bynder credentials and upload settings
  • Try to upload a file - it does upload it and adds to the media field, but with the errors shown above.
  • When trying to upload multiple files it doesn't even add it to the Media field.

Can you try this once again? I'm also giving it another go to make sure it's not a problem with my environment.

marcoscano’s picture

StatusFileSize
new7.63 MB

Hi João, I'm still getting the error 500 today. Could you please double-check?

Here is what I'm doing: video

Could it be something related to the test account we are using? Could you please try with the same test account so we can see the differences?

Thanks!

(Note: on the video, when I type "dcdr", this is an alias for "drush" in my environment)

marcoscano’s picture

StatusFileSize
new4.71 MB

Thanks for solving the issue with the API account!

Now I can indeed reproduce the issue, and apparently it's due to the same racing condition we were experiencing above. In this issue we have introduced a workaround in #11 to avoid it in some scenarios, but it appears that now when it happens (trying to save the entity twice, with a duplicate UUID error message), we avoid that error but both transactions are rolled back somehow and the Entity Browser widget ends up not saving the entity, passing NULL to the field widget, which ultimately produces the error you described above.

However, as I mentioned before, I can reproduce the same racing conditions while testing with the current 8.x-1.x (without the patch): video

Could you please test and see if it also happens for you in the current dev version of the module? (i.e. using Media Entity contrib)

Thanks!

jfs.csantos’s picture

StatusFileSize
new3.75 MB

Hi there Marcos.
I just finished testing with both Drupal 8.4.6 and 8.5.1, Media Entity 1.x and Bynder 8.x-1.x...the error doesn't happen to me.
Not sure how this is happening to you if we are all in the same versions.

 ------------------ --------------------------------------------- --------- ----------------
  Package            Name                                          Status    Version
 ------------------ --------------------------------------------- --------- ----------------
  Media              Bynder (bynder)                               Enabled
  Media              Bynder demo (bynder_demo)                     Enabled
  User interface     Bynder Select2 integration (bynder_select2)   Enabled
  Chaos tool suite   Chaos tools (ctools)                          Enabled   8.x-3.0
  Media              dropzonejs (dropzonejs)                       Enabled   8.x-1.0-alpha8
  Other              Entity (entity)                               Enabled   8.x-1.0-beta3
  Media              Entity Browser (entity_browser)               Enabled   8.x-1.4
  Other              Entity Usage (entity_usage)                   Enabled   8.x-1.0-alpha5
  Media              Media entity (media_entity)                   Enabled   8.x-1.7
 ------------------ --------------------------------------------- --------- ----------------
marcoscano’s picture

StatusFileSize
new363 bytes

So this is the patch that should fix the race conditions. It should apply to both 1.x (current code) and 2.x (after patch #17).

jfs.csantos’s picture

Status: Needs work » Reviewed & tested by the community

Great Marcos, this looks good to go. Do you have permissions to create the 2.x branch and push this?

berdir’s picture

Status: Reviewed & tested by the community » Fixed

I can. Committed the conversion patch to the new 8.x-2.x branch/release, as well as comitting the race condition fix to both branches.

https://www.drupal.org/project/bynder/releases/8.x-2.x-dev

Status: Fixed » Closed (fixed)

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

dave reid’s picture

A side effect of moving all the config to /optional, is that we have an install profile that depends on the bynder module and adds fields to the media type, but we get an order issue:

When you’re doing a full site installation (i.e., install.php or drush site-install), optional config is treated a little bit differently. In such a case, all extensions are installed as normal, but their optional config is ignored initially. Then, at the end of the installation process1, once all extensions are installed (and their default config has been imported), all2 the optional config is imported in a single batch.

https://lightning.acquia.com/blog/optional-config-weirdness-drupal-8

I've moved any config that requires the Bynder media entity to our own /optional directories, which seems to resolve it, but it doesn't seem ideal. Maybe we should be copying and installing that confirm from our install profile itself instead of relying on the Bynder module's configuration?