Cáceres
Account created on 4 October 2011, over 12 years ago
#

Merge Requests

Recent comments

🇪🇸Spain alvar0hurtad0 Cáceres

Problem/ motivation

The responsibility of the iconify service should not include writing to the file system, although it should use a caching system.

Proposed solution

* Create a new service for the cache
* Inject the cache service to the iconify service
* Create proper testing for the new service and clean the ones in the iconify service.

🇪🇸Spain alvar0hurtad0 Cáceres

Thanks Joachim, I think it's now fixed.

🇪🇸Spain alvar0hurtad0 Cáceres

A partir del 20 de junio que terminen los enanos con el cole y las extraescolares, sin problemas.

🇪🇸Spain alvar0hurtad0 Cáceres

I'd be great to find a more meaningful module name:

https://git.drupalcode.org/project/url_text/-/blob/1.x/url_text.info.yml...

name: URL

Same here:
https://git.drupalcode.org/project/url_text/-/blob/1.x/src/Plugin/Field/...

 *   label = @Translation("URL"),

The mailto format doesn't seem to be correct:
https://en.wikipedia.org/wiki/Mailto
https://git.drupalcode.org/project/url_text/-/blob/1.x/src/Plugin/Field/...

      'mailto' => 'mailto://',

I've tested the module and honestly I don't see any real difference with the plain text fields:

🇪🇸Spain alvar0hurtad0 Cáceres

I think this patch applies in an old version of the module before the stable release.
Could you check if the error still exists with current release?
I could not reproduce.

🇪🇸Spain alvar0hurtad0 Cáceres

Thanks @brooke_heaton, I've submited a commit that should fix this issue.

I'll create a new release including also #3424520

🇪🇸Spain alvar0hurtad0 Cáceres

Hello Brooke,

Thank you very much for the MR and raising the issue. Looks good to me but it'll be great if you could use a ternary operation in order to avoid an extra indentation level.

it's something we're trying to do in the whole codebase and it'll make it more homogeneous.

Thank you very much.

🇪🇸Spain alvar0hurtad0 Cáceres

I see this as a security issue:

https://git.drupalcode.org/project/sharepoint_connector/-/blob/1.0.x/src...

  public function access(Route $route) {
    return ($this->moduleHandler->moduleExists('webform')) ? AccessResult::allowed() : AccessResult::forbidden();
  }

In my eyes we should compliment with a permission or provide a neutral result in order to allow other existing permissions to return a forbidden if the user should not access to the route. Also the webform module is a dependency in in the info.yml file, so it seems like this access check is always true.

🇪🇸Spain alvar0hurtad0 Cáceres

also includes simplifications of the module and fixes to some CS problems.

🇪🇸Spain alvar0hurtad0 Cáceres

Some screenshots are added and the roadmap.
I think now is way more clear how to use the module.

🇪🇸Spain alvar0hurtad0 Cáceres

Some images to make things easier

🇪🇸Spain alvar0hurtad0 Cáceres

Seguí los pasos de la documentación para instalar con una configuración existente:

https://git.drupalcode.org/project/la_es/-/blob/1.0.x/docs/setup.md?ref_...

La instalación falló al ejecutar este comando:
ddev drush si --existing-config

🇪🇸Spain alvar0hurtad0 Cáceres

Hello @fgarlin could you please confirm you can pull the repo and find a drupal instalation that makes sense?

🇪🇸Spain alvar0hurtad0 Cáceres

Para mi, los criterios mínimos de inclusión para que una camp se celebre son:
* Opciones libres de alérgenos/intolerancias en las comidas.
* Opciones veganas en las comidas.
* Requerir que las venues sean accesibles para personas con silla de ruedas.
* Obligación de aceptar el COC de la comunidad drupal junto con un grupo diverso de personas velando por que se cumpla.
* Opciones de actividades en Inglés y Español en cada slot que ocupe la camp.
* Requerir a los ponentes realizar una formación sobre charlas inclusivas (No encuentro el link de la que tuvimos que hacer en los dev days, pero me llevó menos de una hora y saqué algunos tips importantes).
* Dedicar al menos una slide en la charla de bienvenida para hablar de inclusión.
* Tipografías que prioricen la legibilidad en los programas.

🇪🇸Spain alvar0hurtad0 Cáceres

Hello @huzooka,
I've added the missing types to the tests.

Sorry for reopen the issue, but I think with this is now ready .

🇪🇸Spain alvar0hurtad0 Cáceres

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

🇪🇸Spain alvar0hurtad0 Cáceres

Hello,
I actively contribute by moderating strings for the Spanish localisation. I think it is very important to give credits to moderation (accepted/rejected strings) as it is the big bottleneck.
Currently some users send large batches of strings, sometimes even translated with automatic translators, so a big part of the responsibility is transferred to the moderator and in many occasions he/she has to propose an alternative translation according to the translation guidelines for each language.

🇪🇸Spain alvar0hurtad0 Cáceres

Thanks Soliman, your code helped me.

🇪🇸Spain alvar0hurtad0 Cáceres

Finally move to a protected method

🇪🇸Spain alvar0hurtad0 Cáceres

Thanks for the suggestions to all.
I'm doing a deep re-architecture and your suggestions are make me think.

For example this:

-      if ($field_type == 'entity_reference' && (in_array($field->getSettings()['target_type'], ['node', 'media']))) {
+      $target_types = ['node', 'media'];
+      if ($field_type == 'entity_reference' && (in_array($field->getSettings()['target_type'], $target_types))) {

Motivates this issue I've just created.
https://www.drupal.org/project/autotagger/issues/3363099 📌 Move source fields to an annotation Fixed

🇪🇸Spain alvar0hurtad0 Cáceres

Sorry for the confusion @apaderno @tgauges, you're right.

I learned something today, thanks for that.

I'll do a deeper review of the code.

🇪🇸Spain alvar0hurtad0 Cáceres

Hello @tgauges,

you should include only the module in the repo.

the repository should be inisialized into the

entity_reference_delete_check_paragraph_url

folder in your case.

🇪🇸Spain alvar0hurtad0 Cáceres

Hi @leandro713,
you can keep the tests if you add your settings in the setup method.

🇪🇸Spain alvar0hurtad0 Cáceres

Hello @kishan@lnwebworks,
sorry for the ping-pong but I still see some enhancements:

  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountProxy
   */
  protected $currentUser;

Maybe this should be @var \Drupal\Core\Session\AccountProxyInterface as the rest of attributes.

🇪🇸Spain alvar0hurtad0 Cáceres

Thanks for the fixes @kishan@lnwebworks I still see some enhancements:

line 81:

   * @param Drupal\Core\Messenger\MessengerInterface $messenger
   *   The Messenger.

There's a missing \

line 193:

if (!empty($query) && !empty($field)) {
$field variable should not be empty but I can't find the initialisation of $field variable in the method.

  public function limitSubscriptions(CartEntityAddEvent $event) {

    // Entity type manager service.
    // Getting subscription storage.
    $subscription_storage = $this->entityTypeManager->getStorage("commerce_subscription");
    // Getting current user id using service.
    $current_user_id = $this->currentUser->id();
    // Entity query for getting subscriptions ids for subscriptions.
    $query = $subscription_storage->getQuery()->condition("uid", $current_user_id)->condition("state", ["active"], "IN")->accessCheck(FALSE)->execute();
    $store = $this->currentStore->getStore();
    $cart = $this->cartProvider->getCart("default", $store);
    $simple_products_count = 0;
    $subscription_products_count = 0;

    foreach ($cart->getItems() as $order_item) {

      $order = $order_item->getOrder();
      $entity = $order_item->getPurchasedEntity();
      $has_field = $entity->hasField('billing_schedule');
      $quantity = $order_item->quantity->value;

      // Increment the counter for the respective product type.
      if (!empty($has_field)) {
        $subscription_products_count++;
      }
      else {
        $simple_products_count++;
      }

      if ($quantity >= 2 && !empty($has_field)) {

        $matching_order_item = $this->orderItemMatcher->match($order_item, $cart->getItems());
        if ($matching_order_item) {

          $new_quantity = 1;
          $matching_order_item->setQuantity($new_quantity);
          $matching_order_item->save();

        }
        $this->messenger->deleteAll();
        $this->messenger->addError($this->t('You have already added product subscriptions in cart.'));
        $response = new RedirectResponse('/cart');
        $response->send();
        return;
      }
    }
    if ($subscription_products_count > 1 && !empty($has_field)) {
      foreach ($cart->getItems() as $order_item) {
        $this->messenger->deleteAll();
        $this->messenger->addError($this->t('You have already added product subscriptions in cart.'));
      }
      $ord_id = $order->id();
      $order = $this->entityTypeManager->getStorage('commerce_order')->load($ord_id);
      if (!empty($order_item)) {
        $this->cartManager->removeOrderItem($order, $order_item);
        $response = new RedirectResponse('/cart');
        $response->send();
        return;
      }
    }

    if (!empty($query) && !empty($field)) {
      $this->messenger->deleteAll();
      $order_item = $event->getOrderItem();
      $orders = $this->cartProvider->getCarts();

      foreach ($orders as $order) {
        $this->cartManager->removeOrderItem($order, $order_item);
      }
      $this->messenger->addError($this->t('You have already active subscriptions.'));
    }
  }
🇪🇸Spain alvar0hurtad0 Cáceres

From my point of view, the provided settings should be non-existent examples or not provide example settings at all:

links:
  Ono:        "http://ono.es"
  Yoigo:      "http://yoigo.com"
  Vodafone:   "http://vodafone.es"
  Telefonica: "http://telefonica.net"

In the defined test.

The documentation refers only to drupal 8 but according to the info file, the module is also compatible with 9:

/**
 * Tests the Drupal 8 seo_keyword_links module functionality.
 *
 * @group seo_keyword_links
 */
class SeoKeywordLinksTestTestCase extends WebTestBase {

Also WebTestBase is deprecated in drupal 8.8 and removed in drupal 9:
https://api.drupal.org/api/drupal/core%21modules%21simpletest%21src%21We...

🇪🇸Spain alvar0hurtad0 Cáceres

Hi,

According to EntityFormInterface, the save entity should return an integer value:

   * @return int
   *   Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
   */
  public function save(array $form, FormStateInterface $form_state);

but in Form\FileRenameForm, save() method returns also NULL:

  public function save(array $form, FormStateInterface $form_state) {
    $pathinfo = pathinfo($this->entity->getFileUri());
    $filename_new = $form_state->getValue('new_filename') . '.' . $pathinfo['extension'];

    if ($filename_new != $this->entity->getFilename()) {
      $filepath_new = str_replace($this->entity->getFilename(), $filename_new, $this->entity->getFileUri());
      // Invoke pre-rename hooks.
      $this->moduleHandler->invokeAll('file_prerename', [$this->entity]);
      // Rename existing file.
      $this->fileSystem->move($this->entity->getFileUri(), $filepath_new, FileSystemInterface::EXISTS_REPLACE);
      $log_args = [
        '%old' => $this->entity->getFilename(),
        '%new' => $filename_new,
      ];
      // Update file entity.
      $this->entity->setFilename($filename_new);
      $this->entity->setFileUri($filepath_new);
      $status = $this->entity->save();
      // Notify and log.
      $this->messenger()->addStatus($this->t('File %old was renamed to %new', $log_args));
      $this->logger('file_entity')->info($this->t('File %old renamed to %new'), $log_args);
      // Invoke hooks if there are some.
      $this->moduleHandler->invokeAll('file_rename', [$this->entity]);

      return $status;
    }
    return NULL;
  }
🇪🇸Spain alvar0hurtad0 Cáceres

Thanks,

From my point of view, the hook_help should be a bit more specific:

function clear_base64_image_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.clear_base64_image':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<h3>' . t('Configuration') . '</h3>';
      return $output;
  }
}

In /src/Form/ClearBase64ImageList.php line 121 maybe should use render array rather than build the link.

Markup::create('<a href="' . $data['description'] . '" target="_blank">  Display </a>'),

same file, lines 318 and next

      if ($getImgType) {
        $mime_type = 'png';
      }
      if ($getImgType == 2) {
        $mime_type = 'jpg';
      }

Seems to override once and again the same variable. Also I think some constants should be used in oder to make the code easier to understand.

Line 328

$new_file = empty($imgTitle) ? $directory . $node->nid->value . '-' . substr($linkHref, 120, 10) . '-' . $date . '.' . $mime_type : $directory . $imgTitle . '.' . $mime_type;

Maybe needs some explanaition in comments, as the link substr($linkHref, 120, 10) really depends on variable factors.

In general for that file we should not mix camel case and snake case in same file:
https://www.drupal.org/docs/develop/standards/php/php-coding-standards#s...

🇪🇸Spain alvar0hurtad0 Cáceres

Hi @apaderno I can also add things to the review if it's OK.

🇪🇸Spain alvar0hurtad0 Cáceres

Some code enhancements.

in line 154:
if ($has_field && !empty($has_field)) {
the $has_field && part is redundant as it's checked in the second condition.

Same in line 161:
if ($quantity >= 2 && $has_field && !empty($has_field)) {

and 178:
if ($subscription_products_count > 1 && $has_field && !empty($has_field)) {

In line 185:
$this->cartManager->removeOrderItem($order, $order_item);
$order_item may be NULL if $cart->getItems()is null, so WSOD could happen.

In line 199:
$this->messenger->addError($this->t('You have already active subscriptions'));
The message should end with a .

🇪🇸Spain alvar0hurtad0 Cáceres

The info.yml file maybe needs some improvemets:

dependencies:
  - drupal:commerce
  - drupal:commerce_recurring

Please check how this works:
https://www.drupal.org/docs/develop/creating-modules/let-drupal-know-abo...

ependencies: a list of other modules your module depends on. Dependencies on Drupal core or contrib modules should be namespaced in the format {project}:{module}, where {project} is the project name as it appears in the Drupal.org URL (e.g. drupal.org/project/paragraphs) and {module} is the module's machine name.

🇪🇸Spain alvar0hurtad0 Cáceres

Please consider don't provide credits in case of minor contributions (like this comment I'm doing right now)

🇪🇸Spain alvar0hurtad0 Cáceres

I've been testing the patch in real life and I found an issue, this new patch prevents some issues in when you need to save several paths for same controller.

Production build 0.69.0 2024