Drupal core's entity reference selection plugin for nodes only allows referencing unpublished nodes if the logged in user has the "bypass node access" permission. This is a very powerful permission that you may not want to give to your editors. This module provides an alternate entity reference selection plugin that does not require that permission for referencing unpublished nodes.

I am looking to have this module reviewed as being that the main purpose is to show unpublished data to users, it leaves a window of possible vulnerability.

Project link

https://www.drupal.org/project/entity_reference_unpublished

git clone --branch 8.x-1.x https://git.drupal.org/project/entity_reference_unpublished.git

Comments

lahoosascoots created an issue. See original summary.

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpsgitdrupalorgprojectentity_reference_unp...

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

lahoosascoots’s picture

Status: Needs work » Needs review

Updated code to fix all issues found by pareview.

rwohleb’s picture

This module doesn't seem to currently do anything. The EntityReferenceSelection plugin is basically empty. This seems to have been submitted too early? Am I missing something?

namespace Drupal\entity_reference_unpublished\Plugin\EntityReferenceSelection;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;

/**
 * Unpublished content plugin of the Entity Reference Selection plugin.
 *
 * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
 * @see \Drupal\Core\Entity\Annotation\EntityReferenceSelection
 * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface
 * @see \Drupal\Core\Entity\Plugin\Derivative\DefaultSelectionDeriver
 * @see plugin_api
 *
 * @EntityReferenceSelection(
 *   id = "unpublished",
 *   label = @Translation("Unpublished Default"),
 *   entity_types = {"node"},
 *   group = "unpublished",
 *   weight = 0,
 * )
 */
class UnpublishedNodeSelection extends DefaultSelection {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);
    $form['target_bundles']['#title'] = $this->t('Content types');

    return $form;
  }

}
lahoosascoots’s picture

Hi. If you compare this class with it’s parent you’ll see the difference.

avpaderno’s picture

Issue summary: View changes

I tested it on simplytest.me and I can confirm the module works as described. The important step is setting the reference method of the node reference field to Unpublished Default, or the node reference field would use the default reference method Drupal core has.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Needs review » Reviewed & tested by the community

I would rather implement a new permission that allows just to link unpublished nodes. There must be a reason for Drupal not to shown all the unpublished nodes to any user.

I don't have any reason to think it's a security breach, though. It is clearly not the same as allowing any user to get a list of usernames.

I am going to approve the application in the next hours.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

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