#StackBounty: #8 #performance Performance is notoriously slow

Bounty: 100

This feels like a repeat post but I can’t find an actual answer. I just installed Drupal 8.4.4 on an Azure App Service (S3 Standard 4core 7GB RAM / PHP 7.0.6) and Azure Database for MySQL (Standard 100 computes / v5.6.26.0). I’ve been told the host isn’t the issue.

Out of the box, the admin side is incredibly slow, like 4-5 seconds per click. I enabled page caching, and CSS/JS are aggregating. Dog slow. I worked through this and created my content types, added a couple of extensions, and enabled BigPipe (reported to help but didn’t).

What am I missing? How do I improve performance before I ask my content authors to start loading up content?

Status report from Drupal. (I have since fixed the reported trusted host settings error)

Performance of the page in Chrome. Looks like 2.8s waiting on the page

I created a test.php file, and queried mysql directly, the key_value table, and dumped all of that to the page, about 576 rows, and it returned instantly. Appears to be Drupal specifically?

Devel bar on public page 182 DB queries

Devel bar on admin page 233 DB queries


Get this bounty!!!

#StackBounty: #8 #emails How to send multiple emails after creating a node

Bounty: 50

I’m using SMTP module to send e-mail messages after creating nodes. It takes about 3-4 seconds to send each such message using hook_node_insert. So if I want to send 10 messages, then I have to wait for 30-40 seconds for the iteration to complete and then only I get redirected to create new node. It’s very slow.

I tried use event KernelEvents::TERMINATE per this article, but it did not speed up the whole process.

Is there a way just to complete creating a node without waiting and immediately proceed to creating a new node, while sending e-mail messages at the same time?

Note: I don’t want to create queue and wait for the next cron run to send e-mails. Because e-mails need to be sent instantly after creating respective node


Get this bounty!!!

#StackBounty: #8 #i18n-l10n How to translate a French site into English without doing it manually throught the UI

Bounty: 50

I have installed a Drupal 8.5 site in French (monolingual). Then, I added content.

Of course, there are many strings in the PHP files of my custom theme/module I pass to t(). There are also many strings in the Twig files I translated with {{ 'a string'|trans }}.

After a while, I added English.

Unfortunately, I discovered that all the strings (interface) I just mentioned are seen by Drupal as English string.
As commented by @Berdir: ALL THE STRINGS IN THOSE FILES MUST BE IN ENGLISH.

The only thing that Drupal brings on the table (according to the @Berdir comment) for this situation is a checkbox/option in /admin/config/regional/language/edit/en that allow to translate MANUALLY in the UI the Original strings (French strings, but seen as English) into English.

According to the same comment, the Translation template extractor module and the Translation Management Tool module doesn’t handle this option /admin/config/regional/language/edit/en

To summarize: Drupal 8 can’t handle a multilingual site with original strings other than English (Except is you search all the strings manually in the UI, which is not doable if there are a lot of strings)

Thus, I assume that to handle this, we need some extra tools that I don’t know about.

Process Idea :

1- A tool will extract all the French strings coming from my php/twig files (into a PO file?)

2- After the translation, this tool (or another one) will replace the French strings in my php/twig file by the corresponding English Strings

3- I will replace my “old” php/twig files with the newly created (with English string inside)

4- I assume that some tool exist to swap the language of the PO file created by step 1 (FR=>EN to EN=>FR)

5- I assume I can import the swapped PO file into my Site to translate it into French

I have 2 questions:

A-Is it the best process? If not, do you have a better idea?

B-If it is the best process, do you know the tool(s) that can handle this?


Get this bounty!!!

#StackBounty: #8 #uri #debugging #clean-urls How to debug 404 on user/login user/register user/logout?

Bounty: 100

I have a Drupal 8 site on 8.4.2. When I upgrade it to 8.5.1, after running the database updates, the paths /user/register, /user/login, and /user/logout return a 404.

  • I can log in with Drush (drush uli myuser), so it is possible to actually log in, but the log in page is not displayed.
  • I tried uninstalling my custom modules, but the problem persists.
  • I looked at /admin/reports/dblog, but it just says “page not found” as the error for /user/login.

This question about a similar problem was closed as off topic because it was too specific; my question is about “how can I debug this?” not “what is the cause of my problem?”


Get this bounty!!!

#StackBounty: #8 #theming #forms #hooks #ubercart Theme Ubercart product node and form in Drupal 8

Bounty: 50

I’ve been trying to do a “simple task” with Drupal 8. Using Ubercart 4.x, I want to totally change the product (add to cart) page.

For that I’ve created a twig file called node–product.html.twig and I’ve fully customized it. But the form is not there.

In order to have the form I’ve added this to my .theme file:

function theme_preprocess_node__product(&$variables) {
  // Creates a AddToCartForm for the given product (with node->id());
  $form_object = new Drupaluc_productFormAddToCartForm($variables['node']->id());
  $variables['product_form'] = Drupal::formBuilder()->getForm($form_object, $variables['node']);
}

And now the form is accessible via the product_form variable in the node–product.html.twig file.

But that’s where my issue start, I only find two ways of handling the form, either I do this:

{{ form }}

But then I have the form with the “normal” design, or I create it myself by doing something like this:

<form id="{{ product_form['#form_id'] }}" method="{{ product_form['#method'] }}" action="{{ product_form['#action'] }}">
  (...)
</form>

This way works since I can now customize the attributes, but I don’t have access to their ID (I’m getting the values from the node–product node and not the form).

So my question is:
How can I handle this in order for me to fully customize the product node?


Get this bounty!!!

#StackBounty: #views #8 #search Search API group by issue with views

Bounty: 100

I have a content type thats is called course which has a field that is a reference to a taxonomy called category.

My specification tells to build a search where users can search for the course title, category and other fields that the course type has. The search functions like intended and everything works great except the display view. Here is my setup:

  • Drupal 8.5
  • Search Api with DB / Solr Backend. (tried both)

So to come back: each course can have multiple categorys to be in which means that the view has to be grouped by the category. If I do that my view displays this:

Category 1 Name

  • Course 1
  • Course 2

Category 1 Name, Category 2 Name

  • Course 3

Category 2 Name

  • Course 4
  • Course 5

Category 3 Name, Category 2 Name

  • Course 6

Category 3 Name

  • Course 7
  • Course 8
  • Course 9

As you can see courses that belong to multiple categorys are not listed underneath the respected category instead they are seperated by a comma. My goal is this:

Category 1 Name

  • Course 1
  • Course 2
  • Course 3

Category 2 Name

  • Course 3
  • Course 4
  • Course 5
  • Course 6

Category 3 Name

  • Course 6
  • Course 7
  • Course 8
  • Course 9

such behaivor is easy to do if you dont use search api and want just to display a normal view. I have already read this issue but it seems my goal is not possible.

I’m asking now here if something has changed or if its possible to get this done with writing custom code? Maybe tell search api to return every result and display them with custom code grouped by the categorys? Can anyone point me to the right direction?


Get this bounty!!!

#StackBounty: #8 #navigation Local tasks not correctly limited to base_route

Bounty: 50

I want to create a customized media library for my editors, with a tab navigation similar to the tabs on core’s admin/content view. It basically works, but I also want to add a tab leading to a specific “media” taxonomy vocabulary used by my media entities. As soon as I add the taxonomy tab to my YML file, the base_route filter no longer works.

Screenshot with correct behaviour on view pages:
Works correctly on view page

Screenshot with unwanted tabs on taxonomy page:
Unwanted tabs on taxonomy page
This is my custom modules’ links.task.yml.

# a common view page for all media types
wt_media.media_list:
  route_name: view.medialibrary.medialibrary
  base_route: view.medialibrary
  title: 'All media types'
# a view page only for images
wt_media.image_list:
  route_name: view.medialibrary.imagelibrary
  base_route: view.medialibrary
  title: Images
# a view page only for videos
wt_media.video_list:
  route_name: view.medialibrary.videolibrary
  base_route: view.medialibrary
  title: Videos
# a view page only for documents/files
wt_media.file_list:
  route_name: view.medialibrary.filelibrary
  base_route: view.medialibrary
  title: Documents
# as soon as I activate the following entry, all the tabs are shown
# on every taxonomy overview page, this is not wanted
wt_media.manage_taxonomy:
  route_name: entity.taxonomy_vocabulary.overview_form
  route_parameters:
    taxonomy_vocabulary: media
  base_route: view.medialibrary
  title: Manage Categories

How can I prevent my custom tabs from appearing on the taxonomy overview pages?


Get this bounty!!!

#StackBounty: #8 #blocks Custom Block from module not showing on front-end?

Bounty: 50

I have created a custom block in a custom module. Sometimes the block appears correctly, and sometimes the block doesn’t appear. The same happens when I clear the cache.

The build() method returns the following value.

return [
  '#markup' => $html,
  '#cache' => array('max-age' => 0)
];

I also tried with the following code.

return (array(
  '#type' => 'markup',
  '#cache' => array('max-age' => 0),
  '#markup' => $html,
));

These are the other methods of the block.

protected function blockAccess(AccountInterface $account) {
  return AccessResult::allowedIfHasPermission($account, 'access content');
}

public function blockForm($form, FormStateInterface $form_state) {
  $config = $this->getConfiguration();

  return $form;
}

public function blockSubmit($form, FormStateInterface $form_state) {
  $this->configuration['custom_block_settings'] = $form_state->getValue('custom_block_settings');
}


Get this bounty!!!

#StackBounty: #8 #taxonomy-terms #plugins How to correctly modify Taxonomy Term selection Plugin

Bounty: 50

I want some slight modifications of DrupaltaxonomyPluginEntityReferenceSelectionTermSelection::getReferenceableEntities(), for example to not use - to indicate term hierarchy. How can that be achieved?

I tried to extend that class in a custom module like that:

/**
 * Provides specific access control for the taxonomy_term entity type.
 *
 * @EntityReferenceSelection(
 *   id = "default:custom_taxonomy_term",
 *   label = @Translation("Custom Taxonomy Term selection"),
 *   entity_types = {"taxonomy_term"},
 *   group = "custom",
 *   weight = 2
 * )
 */
class CustomTermSelection extends TermSelection {

  /**
   * {@inheritdoc}
   */
  public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
    // Customization will be here...
  }
}

The plugin seems to be detected, it appears while debugging $selection_plugins in DrupalCoreFieldPluginFieldFieldTypeEntityReferenceItem::fieldSettingsForm(), but it won’t appear as reference method on editing the term reference field.

What else do I need to modify to get it work?


Get this bounty!!!