Ahmedabad
Account created on 26 April 2022, over 2 years ago
#

Merge Requests

Recent comments

🇮🇳India KumudB Ahmedabad

kumudb changed the visibility of the branch 3293287-entityreferencelabelformatter-doesnt-have-view-entity-access to hidden.

🇮🇳India KumudB Ahmedabad

I am not able to reproduce this on Drupal 11.x.dev version there is no error occuring while creating or editing node type with entity reference fields.
Steps to Reproduce
1. Create a Content Type

  • Add fields that reference other entities, such as Commerce Products or other content types.
  • Allow any logged-in user to create/edit these nodes

.

2.Test Permissions:

  • Ensure permissions are assigned such that non-moderator roles can interact with these fields.

3. Test Node Edit:

  • Create a node type.
  • Attempt to edit the node as a user with minimal privileges.

4.Check Field Configuration:

  • Review the entity reference field’s storage and widget settings.
  • Ensure the selection handler is correctly set and aligns with the referenced entity type.
🇮🇳India KumudB Ahmedabad

MR has been raised for this issue. Please review and merge.

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

There is conflict on MR so I have implement code here, please update this on MR , below error is displaying on MR
Conflict: This file was modified in both the source and target branches. Ask someone with write access to resolve it.

To resolve the issue where the EntityReferenceLabelFormatter improperly renders links to entities when the user has "view label" access but not "view" access, we need to add an additional access check within the viewElements() function. Specifically, we should ensure that the link is rendered only if the user has both "view label" and "view" access to the entity.

/**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    $output_as_link = $this->getSetting('link');

    foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
      $label = $entity->label();
      // Check if the user has "view label" access.
        if ($entity->access('view label')) {
            $uri = NULL;
      // If the link is to be displayed, ensure "view" access as well.
      if ($output_as_link && !$entity->isNew() && $entity->access('view')) {
                try {
                    $uri = $entity->toUrl();
                }
        catch (UndefinedLinkTemplateException $e) {
          // This exception is thrown by \Drupal\Core\Entity\Entity::urlInfo()
          // and it means that the entity type doesn't have a link template nor
          // a valid "uri_callback", so don't bother trying to output a link for
          // the rest of the referenced entities.
          $output_as_link = FALSE;
        }
      }

      if ($output_as_link && isset($uri) && !$entity->isNew()) {
        $elements[$delta] = [
          '#type' => 'link',
          '#title' => $label,
          '#url' => $uri,
          '#options' => $uri->getOptions(),
        ];

        if (!empty($items[$delta]->_attributes)) {
          $elements[$delta]['#options'] += ['attributes' => []];
          $elements[$delta]['#options']['attributes'] += $items[$delta]->_attributes;
          // Unset field item attributes since they have been included in the
          // formatter output and shouldn't be rendered in the field template.
          unset($items[$delta]->_attributes);
        }
      }
      else {
        $elements[$delta] = ['#plain_text' => $label];
      }
      $elements[$delta]['#entity'] = $entity;
      $elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
    }

    return $elements;
  }

Key Changes Made

1. Added view label Access Check:

  • Before rendering anything, ensure the user has at least "view label" access to the entity.
    if ($entity->access('view label')) { ... }
    

2. Added view Access Check for Links:

  • Ensure that links are rendered only if the user has both "view label" and "view" access to the entity.
if ($output_as_link && !$entity->isNew() && $entity->access('view')) { ... }

Testing the Changes

Scenario 1: User with Both "view label" and "view" Access

  • Expect the label to render as a clickable link to the entity's canonical page.

Scenario 2: User with Only "view label" Access

  • Expect the label to render as plain text, with no clickable link.

Scenario 3: User with No Access

  • Expect no label to be rendered for entities the user lacks access to.
🇮🇳India KumudB Ahmedabad

Issue with <q> Tags in CKEditor 5
I wanted to bring to your attention an issue regarding the handling of <q> tags in CKEditor 5. It appears that these tags are being automatically modified due to CKEditor 5's built-in paragraph handling features.

I conducted tests on the official CKEditor site, and I encountered the same behavior with the

For reference, I have attached a screen recording demonstrating the behavior.

Unfortunately, this means there may be no solution available from our side to prevent the

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

As shown in the attached recording, when creating a new workflow, the dropdown now defaults to the empty option, allowing users to actively choose the appropriate moderation state rather than defaulting automatically. This behavior aligns with the intended functionality.

Please review the code and recording for confirmation

🇮🇳India KumudB Ahmedabad

I have completed the required changes for this feature. Initially, the 'Default moderation state' field was set as a required field; however, as per the final requirements, it does not need to be mandatory. I have reverted the code that enforced this, and an empty option has been added to the 'Default moderation state' dropdown in the Workflow Settings form to prompt users to make an active selection.

Please review the current changes in this branch, which now align with the updated requirements.

Patch file also attached.

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

After checking out the branch where @walli made changes, I applied a custom hook in the module file. As a result, the is_external field now appears as a filter option. I have attached a screenshot for reference and custom module code.

Steps to Reproduce:
Step 1: Set Up a Content Type with a Link Field
1.Create a Custom Content Type:

  • Go to Structure -> Content types.
  • Click on Add content type and create a new content type (e.g., "Article with Link").
  • Add necessary fields like "Title" and "Body."

2. Add a Link Field:

  • While editing the content type, click on the Manage fields tab.
  • Add a new field, select Link as the field type, and name it something like "External Link."

3.Create Content:

  • Create a few nodes for this content type.
  • Populate the link field with both external links (e.g., https://example.com) and internal links (e.g., /node/1).

Step 2: Check for Limitations in Default Views
1.Create a View:

  • Go to Structure -> Views.
  • Click on Add view.
  • Create a new view based on the "Article with Link" content type.
  • In the view, try to add filters or sorts based on whether the link is external or internal.

2.Observation:

  • Notice that there is no built-in way to filter or sort content based on whether the link is external or internal.

The MR code remian as it is and just apply this hook

/**
 * Implements hook_views_data_alter().
 */
function customTest_views_data_alter(array &$data) {
  $field_name = 'field_external'; // Replace with your link field's machine name.

  if (isset($data["node__{$field_name}"])) {
    // Define the custom field handler.
    $data["node__{$field_name}"]['is_external'] = [
      'title' => t('Is External'),
      'help' => t('Indicates if the link is external.'),
      'field' => [
        'id' => 'is_external_field', // Use the ID from the @ViewsField annotation in IsExternalField.
      ],
      'filter' => [
        'id' => 'boolean',
      ],
      'sort' => [
        'id' => 'standard',
      ],
      'group' => t('Custom'),
    ];
  }
}

🇮🇳India KumudB Ahmedabad
core/modules/views/src/Plugin/views/field/EntityField.php
/**
   * {@inheritdoc}
   */
  public function getValue(ResultRow $values, $field = NULL) {
    // Ensure that we're getting the specific entity for the current row.
    $entity = $this->getEntity($values);

    // Ensure the object is not NULL before attempting to translate it.
    if ($entity === NULL) {
      return NULL;
    }
    // Retrieve the translated object for this specific row.
    $translated_entity = $this->getEntityFieldRenderer()->getEntityTranslationByRelationship($entity, $values);

    // Fetch the field items for the current entity's row.
    $field_item_list = $translated_entity->{$this->definition['field_name']} ?? NULL;

    if ($field_item_list === NULL) {
      // There isn't anything we can do without a valid field.
      return NULL;
    }

    $field_item_definition = $field_item_list->getFieldDefinition();

    $values = [];
    foreach ($field_item_list as $field_item) {
      /** @var \Drupal\Core\Field\FieldItemInterface $field_item */
      if ($field) {
        $values[] = $field_item->$field;
      }
      // Find the value using the main property of the field.
      elseif ($main_property_name = $field_item->mainPropertyName()) {
        $values[] = $field_item->{$main_property_name};
      }
      else {
        // Default to using the 'value' property.
        $values[] = $field_item->value;
      }
    }
    // Ensure the field is handled based on its cardinality.
    if ($field_item_definition->getFieldStorageDefinition()->getCardinality() == 1) {
      // Single cardinality field should return a single value.
      return reset($values);
    }
    else {
      // Multi-value field handling.
      // Check if grouping is enabled or not.
      if ($this->options['group_rows'] === FALSE) {
        // If grouping is disabled, return individual values.
        return $values;
      }
      else {
        // If grouping is enabled, return the values as a concatenated string.
        return implode(', ', $values);
      }
    }
  }

This is the code and its working for me please review it.

🇮🇳India KumudB Ahmedabad

This patch addresses the issue where the `getValue()` method in Views returns values from multiple rows, even when it should only return values for a single row.

Steps to reproduce:
1. Create a view that shows entity fields.
2. Add a multi-value field and ensure the "Display all values in the same row" option is unchecked.
3. Programmatically execute the view and use the `getValue()` method to retrieve field values.

Expected behavior: The field values should only display for the given row.
Patch solution: Adjusted the `getValue()` method to fetch data directly from the passed `$row` argument rather than `$row->_entity`.

Test instructions:

- Create a view with a multi-value field and verify that only values for a specific row are returned.

MR is created
https://git.drupalcode.org/project/drupal/-/merge_requests/9914

🇮🇳India KumudB Ahmedabad

I have verified your changes, and its working as expected on Drupal version 11.x, here I attached the screen recording and screen shot.
Earlier it was not displaying "more" link when specified items are displaying.

Now it is working as expected.

Description also Updated

🇮🇳India KumudB Ahmedabad

I have tested this on local and it is working as expected, PHPUnit testing taking more time so here I am adding the code, Modified the Function to Automatically Handle Invalid Permissions

/**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    parent::calculateDependencies();
    // Load all permission definitions.
    $permission_definitions = \Drupal::service('user.permissions')->getPermissions();
    $valid_permissions = array_intersect($this->permissions, array_keys($permission_definitions));
    $invalid_permissions = array_diff($this->permissions, $valid_permissions);
    if (!empty($invalid_permissions)) {
      \Drupal::logger('user')->warning('Removing non-existent permissions from role: "@permissions".', ['@permissions' => implode(', ', $invalid_permissions)]);
      // Remove invalid permissions from the role.
      $this->permissions = $valid_permissions;
    }
    foreach ($valid_permissions as $permission) {
      // Depend on the module that is providing this permissions.
      $this->addDependency('module', $permission_definitions[$permission]['provider']);
      // Depend on any other dependencies defined by permissions granted to
      // this role.
      if (!empty($permission_definitions[$permission]['dependencies'])) {
        $this->addDependencies($permission_definitions[$permission]['dependencies']);
      }
    }
    return $this;
  }

Logging Instead of Throwing an Exception:
Instead of throwing a RuntimeException, we log a warning using \Drupal::logger('user')->warning() when invalid permissions are found. This allows the system to recover from the error without breaking.

Automatically Removing Invalid Permissions:
The invalid permissions are removed from the role by resetting $this->permissions to $valid_permissions. This ensures that roles are no longer linked to non-existent permissions.

Rest of the Logic Remains Unchanged:
The valid permissions are processed as they were originally, adding necessary dependencies based on the permissions.

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

Hi @murilohp,

I have reviewed your code, and it is working for me on my local setup as well. The mail notification is sent only when the email address is available. I am attaching mail screen shot as well.

🇮🇳India KumudB Ahmedabad

I have reviewed the patch #5, its working for me in Drupal version 8.x and 9.x , there is no error while installing the module Smartmenus.js. I have test it on my local.

🇮🇳India KumudB Ahmedabad

While checkout to this current branch, getting this below error, Drupal version 11.x

The website encountered an unexpected error. Try again later.

Error: Class "Drupal\system\Element\RenderElementBase" not found in include() (line 14 of core/modules/system/src/Element/StatusReportPage.php).
Composer\Autoload\{closure}() (Line: 427)
Composer\Autoload\ClassLoader->loadClass()
class_exists() (Line: 96)
Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (Line: 17)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 166)
Drupal\Core\Render\ElementInfoManager->createInstance() (Line: 135)
Drupal\Core\Render\ElementInfoManager->buildInfo() (Line: 91)
Drupal\Core\Render\ElementInfoManager->getInfo() (Line: 356)
Drupal\Core\Render\Renderer->doRender() (Line: 240)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 60)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 736)
Drupal\Core\DrupalKernel->handle() (Line: 19)
🇮🇳India KumudB Ahmedabad

In Drupal version 11.x, I have successfully tested patch #33 in my local environment, and it is functioning as expected. However, I believe that my review may not be sufficient to ensure all aspects are covered. Therefore, I recommend moving this patch to the "Needs Review" status so that it can receive further evaluation from the community.

Thank you!

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

In Drupal version 10.x with the 2.4.x-dev release, the like/dislike functionality for both comments and content is working as expected. I was unable to reproduce the issue in my local setup, and everything appears to be functioning correctly.

we can close this.

Steps to Reproduce
To reproduce the issue, follow these steps:

1. Create a New Drupal 10.x with the 2.4.x-dev release Installation: Or Start with a fresh installation of Drupal 10.

2. Install the Like/Dislike Module: Use Composer to add the drupal/like_dislike module.

3. Add Like/Dislike Field to Node Types:

  • Go to Structure > Content types.
  • For both Article and Page, add a field of type like_dislike.

4. Add Like/Dislike Field to Comments:

  • Go to Structure > Comment types.
  • Add a like_dislike field to the default Comment type.

5. Create Content:

  • Create a new Article or Page.
  • Add comments to this content, ideally from different users.

I have attached a screen recording for your reference.

🇮🇳India KumudB Ahmedabad

in Drupal version 11.x , above patch is working as expected and there is no error in my local as well. here I attached screenshots as well.

🇮🇳India KumudB Ahmedabad

kumudb changed the visibility of the branch 3063877-add-page-access-permissions to hidden.

🇮🇳India KumudB Ahmedabad

kumudb changed the visibility of the branch 3063877-add-access-control to active.

🇮🇳India KumudB Ahmedabad

Here are the Screenshot attached for issue which is not reflected on file listing page.

🇮🇳India KumudB Ahmedabad

As per the review, I have learned that the permissions for "Edit any file" and "Edit own file" are correctly listed under file permissions; however, they are not reflected on the file listing page. Currently, only the delete option is visible for the admin role. When permissions are granted to other roles, the edit options still do not appear on the file list or usage page. These changes are not being reflected as expected.

🇮🇳India KumudB Ahmedabad

Resolution: Issue Not Reproducible in Drupal 10.2.3

After further testing, I was unable to reproduce this issue on a site running Drupal version 10.2.3. The warnings related to the mkdir(): Permission Denied error when attempting to create the php/twig folder in sites/default/files are not occurring in this version.

Given that the issue does not persist in 10.2.3, I am marking this issue as resolved and closing it.

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

I have verified the changes and have raised a MR to address the issue of inconsistent plugin representation in the CKEditor configuration interface. Please review the PR at your convenience. Thank you!

🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

It appears that this issue has been resolved in the latest version of Drupal 11. I have tested the scenario and verified that the error message no longer includes the "(all languages)" suffix.

I have attached a screenshot for reference. Given that the problem is no longer present, I believe we can close this issue.

Thank you!

🇮🇳India KumudB Ahmedabad

I have closed this issue as I was unable to reproduce it with the latest pull from the 11.x branch. It appears that the issue has been resolved with recent fixes.

If anyone encounters a similar issue in the future, please feel free to open a new issue.

Thank you!

🇮🇳India KumudB Ahmedabad

I wanted to update regarding the issue we discussed. I pulled the latest code from the 11.x branch, and I was unable to reproduce the issue locally. This behavior was consistent with the problem we encountered previously, so it seems to be resolved with the recent changes.

For reference, I’ve attached recording that demonstrate the current state of the application.

Please let me know if you need any further information or if there’s anything else I should look into.

🇮🇳India KumudB Ahmedabad

In Drupal 11.x, I have attempted to reproduce the issue by creating a content type and adding fields such as a paragraph field and a date field (which is not required). I applied the validation function to this setup, but I am currently unable to reproduce the error. It seems that the issue might be related to an incorrect validation function name, which could lead to AJAX errors when collapsing or editing paragraph fields in the content type.

To reproduce the issue, follow these steps:

  1. Create a Content Type: Add the necessary fields, including a paragraph field and a date field.
  2. Apply the Validation Function: Implement the custom validation function to check the fields as per the requirements.
  3. /**
     * Implements hook_form_alter().
     */
    function customTweaks_form_alter(&$form, FormStateInterface $form_state, $form_id) {
      if ($form_id == 'node_product_form' || $form_id == 'node_product_edit_form') {
         $form['#validate'][] = 'customTweaks_node_form_validate';
      }
    }
    
    /**
     * Custom validation handler for the product node forms.
     */
    function customTweaks_node_form_validate(&$form, FormStateInterface $form_state) {
        // Only validate if the form is being submitted with published status.
        if ($form_state->getValue('status')['value'] == 1) {
          // Check for the product publish date field.
          if (empty($form_state->getValue('field_prod_publish_date')[0]['value'])) {
            $form_state->setErrorByName('field_prod_publish_date', t('The publish date field must be completed before publishing.'));
          }
        }
      }
  4. Test the Form: Attempt to collapse or edit the paragraph field in the content type and observe if AJAX errors occur. in this code it does not occur.
  5. If the validation function is incorrect or not properly implemented, it may lead to errors during these actions.
🇮🇳India KumudB Ahmedabad

kumudb made their first commit to this issue’s fork.

🇮🇳India KumudB Ahmedabad

There is an issue occurring when clicking on the entity used for the logo from the file system.

1. Upload a custom logo:
Navigate to Administration > Configuration > User Interface > Navigation > Settings.
Upload and save your custom logo.

2. Save the configuration:
Ensure the changes are saved properly.

3. Verify the issue:
Go to Administration > Content > Files.
Locate your most recently uploaded logo file.
Click on the Usage link for this file.
Observe the error that appears.

The website encountered an unexpected error. Try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "logo" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 138 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

🇮🇳India KumudB Ahmedabad

My apology, issue is exist. here change status

🇮🇳India KumudB Ahmedabad

MR has been created and merged for Drupal 10.x.1MR !1864 mergeable Please review it.

Production build 0.71.5 2024