When using the content browser on entity reference fields with a limited selection of allowed content types (Reference Type / Content Types), the entity browser does show all system wide available entity types instead of the limited types only. As this allows a user to add content references to nodes that he should not be able to, I consider this a bug.

Will happily provide further information, if required.

Comments

Mario Steinitz created an issue. See original summary.

mylies’s picture

Assigned: Unassigned » mylies
mylies’s picture

Assigned: mylies » Unassigned
samuel.mortenson’s picture

samuel.mortenson’s picture

Status: Active » Needs review
StatusFileSize
new5.07 KB

Here's a patch that, combined with the latest release of Entity Browser and the latest patch from [#32865928], provides a contextual filter that restricts content in the Content Browser by Content Type. You should be able to patch Entity Browser, patch Content Browser with this patch, then update databases to see the change.

Please test this and let me know what you think! I won't add it until Entity Browser commits/releases issue mentioned above, but early feedback would be much appreciated. Thanks!

samuel.mortenson’s picture

StatusFileSize
new5.07 KB

Re-roll.

greedesign’s picture

The patch failed for me however I was able to get it to work with this change to the patch file. After the patch failed my content_browser.install.rej file pointed to the use Drupal\Core\Config\ExtensionInstallStorage; line and when comparing it to to my file, my line was use \Drupal\Core\Config\ExtensionInstallStorage;. Not sure if this will be the case for others.

diff --git a/content_browser.install b/content_browser.install
index 6f97b74..5319396 100644
--- a/content_browser.install
+++ b/content_browser.install
@@ -6,6 +6,7 @@
  */
 
 use \Drupal\Core\Config\ExtensionInstallStorage;
+use \Drupal\views\Entity\View;

Sorry for not committing a new patch re-roll but I have never done that before and tight for time at work.

bappa.sarkar’s picture

Does not respect content type limitations - When we use entity browser with inline entity form. https://www.drupal.org/project/content_browser/issues/2929301

bappa.sarkar’s picture

StatusFileSize
new5.07 KB

The 2851687-6.patch not applicable in 8.x-1.0-alpha4 version due to a slash(\) added in the Drupal namespace in the install file.

ankit agrawal’s picture

I am getting the following error when trying to run update script for newly added update hook:

----------------- ----------- --------------- ------------------------------------------------------------------------------
  Module            Update ID   Type            Description
----------------- ----------- --------------- ------------------------------------------------------------------------------
 content_browser   8002        hook_update_n   Updates the content browser view to contextually filter by allowed bundles.
----------------- ----------- --------------- ------------------------------------------------------------------------------

// Do you wish to run the specified pending updates?: yes.

[notice] Update started: content_browser_update_8002
[error]  Error: Call to a member function getDisplay() on boolean in content_browser_update_8002() (line 127 of docroot/modules/contrib/content_browser/content_browser.install)
#0 vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(185): content_browser_update_8002(Array)
oriol_e9g’s picture

Version: 8.x-1.0-alpha4 » 8.x-1.x-dev
StatusFileSize
new5.07 KB

Rerolled patch.

samuel.mortenson’s picture

Does anyone have time to review and test the patch, then move the issue to RTBC?

antiorario’s picture

Status: Needs review » Reviewed & tested by the community

It seems to be working well.

  • oriol_e9g authored 69f3e4d on 8.x-1.x
    Issue #2851687 by samuel.mortenson, bappa.sarkar, oriol_e9g, greedesign...
samuel.mortenson’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @antiorario! I addressed #10 and #7 on commit as well.

This will be in the next Content Browser release, but I have to wait until Entity Browser has a new release that includes the Views plugin.

Status: Fixed » Closed (fixed)

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