Questions tagged [9]

Version tags should be used only for questions that apply to a version only, not to merely say what version a site is using.

Filter by
Sorted by
Tagged with
14 votes
3 answers
2k views

Require v8 only contrib module with v9 patch

Given I have Drupal 9 composer installation with composer-patches plugin and given a contrib module with a stable v8 release, but no v9 release (not even dev branch) and given that contrib module has ...
Hudri's user avatar
  • 5,286
12 votes
2 answers
6k views

Command to install Drupal 9 with Composer

The latest version of Drupal 8 can be installed via Composer with the following command: composer create-project drupal/recommended-project mynewproject What is the equivalent command to install the ...
user320691's user avatar
12 votes
2 answers
2k views

Use custom content entity theme suggestions in own module?

I have a custom content entity called 'offer'. I've added template_preprocess_offer() and offer_theme() to the offer.module file. function offer_theme($existing, $type, $theme, $path) { return [ ...
Stef Van Looveren's user avatar
11 votes
1 answer
2k views

How do I apply patches from a merge request? [duplicate]

I used the patch #48 of Views exposed sort identifiers are not configurable. I need to update the core, and apply the latest rebased version of that. However, the issue hasn't be marked Fixed, and I ...
Giuseppe's user avatar
  • 897
11 votes
1 answer
583 views

Should I use Drush or Drupal Console with a new site?

Between Drush and Drupal Console, which seems to have similar functionalities, which one should I install?
user avatar
10 votes
1 answer
2k views

How to add a js script as type="module"

How to add type="module" to script added in MODULENAME.libraries.yml when i do: my-library: version: 1.x js: js/App.js: { } I get <script src="/modules/custom/MODULENAME/js/...
berramou's user avatar
  • 7,075
10 votes
2 answers
2k views

Set SameSite=strict for session cookies

I'm trying to figure out how to set the SameSite cookie attribute for Drupal 8 session cookies, but I can't find a solution. I thought SessionConfiguration might give me enough options, but it seems ...
mount_everest's user avatar
8 votes
2 answers
15k views

EntityQuery condition "is not equal to..."

Problem : I need filtering entities based on the value of a multiple-choice field. I want my query returns all entities except those who have a given value ('doe' for this example). Actual : multiple-...
Antoine Subit's user avatar
7 votes
2 answers
6k views

How can I verify users the first time they log in?

I was reading this article. I would like to know how logging in with the REST API in Drupal 8 works. By default, when users log in, Drupal will verify username and password. After the login, the ...
Jonh's user avatar
  • 747
7 votes
1 answer
4k views

drupal9 dev mode local settings : non existing cache.backend.null

In drupal9 my drupal8 local.settings.php conf generate an error when i empty cache Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have [error] requested a non-...
Matoeil's user avatar
  • 3,355
7 votes
1 answer
663 views

What method should I use instead of Drupal\Core\Entity\Query\Sql\Query::addExpression()?

I am using Entity Query to select nodes of two different types. The fetching seems to be working, but I want to sort the returned values. Both the content types have different date fields. I know I ...
Akansha's user avatar
  • 121
6 votes
4 answers
482 views

Is it better to use the latest version released 1 month ago, or use the older but still supported version?

I am going to create a new website: Is it better to use the latest major version recently released, or the previous still-supported version? For example, if Drupal 9 were released one month ago, ...
apaderno's user avatar
  • 97k
6 votes
2 answers
1k views

Is it bad practice to use the same hook twice?

I'm working a quite a big project and I use hook_entity_update() in three of my modules. I do this to keep my project structured and have different functions of my site in different modules. Is it ...
Joost's user avatar
  • 1,218
6 votes
0 answers
44 views

How to override the typehint for entityTypeManager with a more specific one?

I'm often frustrated by entityTypeManager because when I load entities, the typehint for the return value of the load methods is EntityInterface, but I want it to be a more specific interface (which I ...
Patrick Kenny's user avatar
5 votes
1 answer
3k views

Composer not applying patch: exceeded the timeout of 300 seconds [closed]

Since my update to the new OSX (Ventura 13) I'm having problems using composer. The biggest problem I have is that my patches aren't patched and end up with and exceeded the timeout of 300 seconds ...
Joost's user avatar
  • 1,218
5 votes
2 answers
1k views

Does the built-in PHP web server have disadvantages over other local development alternatives?

When watching Install Drupal for Local Development, I leant that Drupal 8 and Drupal 9 come with a built-in PHP web server that can be set up quickly by cloning the core and running php -S localhost:...
Jeroen's user avatar
  • 2,518
5 votes
3 answers
1k views

How can I restrict external URLs in link field to allow only certain domains?

After creating a Link field and use the Link with service icon format, I find out that there is no option to restrict external URLs to external domains that I want For example, if I only want to allow ...
MrIssue's user avatar
  • 75
5 votes
1 answer
189 views

Can services be autowired?

In drupal 8, each time we used to declare a class as a service by adding it to [module name].services.yml and then injecting it in the constructor of a different class. However, according to this ...
Jane's user avatar
  • 51
5 votes
1 answer
1k views

What should be used instead of raw filter?

Drupal 9 theming documentation indicates that the Twig raw filter is deprecated in favor of verbatim. The ds-field-expert.html.twig template uses raw to render the input in the prefix and suffix field,...
Sarah C's user avatar
  • 480
5 votes
1 answer
429 views

Locked myself out after enabling misconfigured Google Authenticator

I somehow managed to lock myself out of a Drupal 9 installation after setting up TFA with Google Authenticator login. So, i know my user1 name, my user 1 password, but TFA doesn't allow me backend ...
Berry Dingle's user avatar
5 votes
1 answer
2k views

In event subscriber, how to redirect if value doesnt exist?

I am trying to check a condition before page load, if value exists to load page if not to redirect. I am following this page I have created a /mymodule/mymodule.services.yml file and a /mymodule/src/...
May 's user avatar
  • 163
5 votes
2 answers
916 views

PHPUnit throws error: \Drupal\Tests\DocumentElement class not found

I have added some phpunit tests to my custom module. When trying to run them in I get this error: Class '\Drupal\Tests\DocumentElement' not found I have copied core/phpunit.xml.dist to core/phpunit....
naomi's user avatar
  • 1,155
5 votes
1 answer
267 views

Force a single value base field to be in a separate table?

I have a custom entity type (eg: myentitytype), and I would like to add a new base field to it via hook_entity_base_field_info(). As I understand it, single value fields (with a cardinality of 1) will ...
m.stenta's user avatar
  • 743
5 votes
1 answer
620 views

How do I replace drush_set_error()?

Just updating a module for Drupal 9 and Drush 10 and drush_set_error() no longer appears as a function in the Drush code (as far as I can see). What should I be using instead?
John's user avatar
  • 188
5 votes
1 answer
431 views

Enable layout builder on custom controller page

I created a simple page in a controller class: public function taxonomyPage($term) { return [ '#type' => 'markup', '#markup' => $this->t('<p>Need to render layout ...
Thomas Crawford's user avatar
5 votes
1 answer
230 views

Extending contrib module filelog service class displays PSR implementation error

I wanted to override the logger.filelog service from filelog module to make use of my own parser. An error occurred through drush cim and drush cr when the new custom module that overrides the service ...
Michael Chen's user avatar
5 votes
2 answers
2k views

What is the stable9 theme? When should I use it instead of stable?

https://www.drupal.org/node/3066038 Has this cryptic statement: However, defaulting to base theme: stable prevents automatic updates to the next major version of Drupal, since each major version may ...
̷c̷h̷x̷'s user avatar
5 votes
1 answer
193 views

How does the Geolocation content of a page filter is a Views block?

I have a website with Drupal 9 and the Geolocation module : https://www.drupal.org/project/geolocation I created a content type with a Geolocation field that contains coordinates. My website uses the ...
zoulou66's user avatar
4 votes
2 answers
490 views

How do I use \Drupal methods in a class?

I was out of Drupal for a few years, and PHP a couple years, due to having several years of jobs that didn't use Drupal between two that did. And I'm noticing a lot of functions that were reliable are ...
lilHar's user avatar
  • 151
4 votes
1 answer
2k views

What does the "Views: Filter by an entity reference view" reference method do?

I was just creating a reference type and noticed that there is a reference method called Views: Filter by an entity reference view. What does this do, and how does it differ from the Default method? I ...
quant's user avatar
  • 546
4 votes
1 answer
2k views

How do I override a single JavaScript file used in a library?

I am trying to override the Search API autocomplete JavaScript file. In mytheme.libraries, I added the following lines. mytheme_autocomplete: js: 'assets/js/autocomplete.js': { } In mytheme....
May 's user avatar
  • 163
4 votes
1 answer
2k views

How can I use core's WebP support instead of the WebP module?

According to the change record, Drupal 9.2 supports WebP for better image compression. I've been using the WebP module on my 9.1 site to serve WebP images, but it has a performance-killing bug and I ...
Patrick Kenny's user avatar
4 votes
1 answer
338 views

Mocking Settings (settings.php) within Unit tests

Drupal's Settings class is marked final and has no interface, meaning traditional PHPUnit mocking techniques will not work out of the box. Is it necessary to install third-party tools to be able to ...
CChiste's user avatar
  • 111
4 votes
1 answer
167 views

Drupal 8's last minor release = Drupal 9?

I have read about the planned release date of Drupal 9 is scheduled to be on June 3rd, 2020. I read this documentation about how to prepare a Drupal 8 site for Drupal 9: Prepare a Drupal 8 site for ...
hiew1's user avatar
  • 153
4 votes
1 answer
489 views

Properly storing an array in a config object

In a config object, I want to store an array of values. The keys matter. The stored value is coming from a checkboxes element, so the array would look something like: ['article' => 'article', 'page'...
Kevin's user avatar
  • 27.7k
4 votes
1 answer
568 views

drupal-scaffold composer append robots.txt

We recently upgraded to Drupal 9.3.0 with the composer layout. Each time we execute composer update the contents of robots.txt is overlayed with the file located in core/assets/scaffold/files/robots....
Greg Sims's user avatar
  • 573
4 votes
1 answer
840 views

How to properly log custom exceptions?

I'm trying to improve the code quality of my custom module by adding custom exceptions. Before, I was lazy and throwing \Exception everywhere, but I recently refactored all my code to use custom ...
Patrick Kenny's user avatar
4 votes
2 answers
103 views

Alter comment pager to jump to comment section right away?

I set up a content type and a specific comment type for this content. I set the comment pager to display 10 comments per page. When I now use the pager, I get redirected from the node URL itself www....
арно нюм's user avatar
4 votes
1 answer
391 views

How to prevent a node from being deleted while performing a delete operation?

I want to prevent a node from being deleted while a delete operation is performed on it. For example in administration panel if user clicks "Delete" on the node, the node shouldn't be ...
sailormoon's user avatar
4 votes
1 answer
91 views

What is the difference between Translation language, Translation source, and Original language?

Would anyone be able to explain to me what the difference is between "Original language", "Translation language", and "Translation source"? I think I have a pretty good ...
Lester Peabody's user avatar
4 votes
0 answers
132 views

How can I dynamically switch between two databases for ALL queries?

I need to copy some entities from one Drupal 9 database to different Drupal 9 database. I have searched and looked high and low, but none of the examples I have found work anywhere. I found no help on ...
Martin Joergensen's user avatar
4 votes
0 answers
250 views

How to deal with config sync changing the order of lines in files causing spurious changes in source control?

I am really enjoying Drupal 8/9's built-in config sync mechanism which allows you to export config to a directory. This makes it possible to store config in a git repo and easily deploy from dev to ...
naomi's user avatar
  • 1,155
4 votes
0 answers
2k views

Schema information for module is missing - how to fix?

I tried to install the Scheduler module but it did not install properly because we somehow did not have code for another custom module that the database thinks was installed. I got the code for the ...
Stephen Ash's user avatar
4 votes
0 answers
448 views

How do I fix the base URL issue while using load balancer

Since base URL is deprecated, and our Drupal 9 Site is using a load balancer, we are facing issues when setting up the base URL. Instead of the base URL, it displays the load balancer IP. Any help ...
John Aroza's user avatar
4 votes
1 answer
255 views

How can I have Behat create content with an address field properly filled?

I'm writting a Behat test, where I'm triying to create a content that uses a field address, generated by Address Module. I'm using Drupal 9.0.7, Address Module 1.9.0 and behat 3.8.1. My goal is to ...
Olalla Rodicio's user avatar
4 votes
1 answer
127 views

How do I set the display suite default region for newly created fields?

What needs to be done: Newly created fields in any content type should go to the hidden region of the DS Layout. Short background: In our project we use the Display Suite module, and we have the ...
Oleg Videnov's user avatar
  • 1,781
3 votes
2 answers
1k views

How can I replace a string in a text?

With {{ content.field_myfield.0 }}, I get a text. When I use {{ content.field_myfield.0|replace({"foo" : "bar"}) }}, nothing is rendered and no errors are reported. I also tried ...
May 's user avatar
  • 163
3 votes
3 answers
4k views

Upgrade Devel module and disable Kint

When upgrading from Devel 8.x-2.x to Devel 8.x-4.x in a composer based build, how do I handle the Kint module being removed per Remove Kint module and create a kint dumper plugin in devel? The service ...
esod's user avatar
  • 309
3 votes
1 answer
755 views

Why does Programmatic Node Unpublish not Work?

We recently upgraded to Drupal 9.3.0 using a Composer file layout. The resulting website is working correctly and is now running in the publish domain. We have a set of utilities that we run as ...
Greg Sims's user avatar
  • 573
3 votes
1 answer
2k views

How to check if path alias exists

In Drupal 8, my custom module includes the code if (\Drupal::service('path.alias_storage')->aliasExists($path, 'en')) { return true; } What should this look like in Drupal 9.2? Seems so simple,...
Marshall Morrise's user avatar

1
2 3 4 5
36