Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

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,530
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
  • 971
11 votes
1 answer
592 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,225
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
9 votes
1 answer
4k 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,348
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
  • 777
7 votes
1 answer
5k 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,423
7 votes
1 answer
834 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
484 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
  • 97.5k
6 votes
1 answer
377 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
  • 61
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,348
6 votes
2 answers
1k 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,235
6 votes
0 answers
58 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
6 votes
0 answers
349 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,235
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
2k 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
  • 490
5 votes
1 answer
433 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
3k 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
1 answer
307 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
679 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
496 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
284 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
3k 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
214 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
577 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
3k 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
  • 556
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
1k views

How do I know which services.yml is active?

If I have multiple services.yml in the sites/default/ directory, how can I determine which one Drupal is actually loading? Is there a drush command to check this? Or is there some other way to verify ...
Patrick Kenny's user avatar
4 votes
2 answers
780 views

Moved an old installation profile now site is broken

I have a d9 site with an old installation profile originally written for d8. I was having some issues with the profile preventing the uninstallation of some modules so I tried moving the entire folder ...
tanbog's user avatar
  • 1,263
4 votes
1 answer
395 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
544 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.9k
4 votes
1 answer
735 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
1k 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
1 answer
1k views

How do I run PHPUnit tests?

Having just kind of gotten my head around Simpletest functional testing in Drupal 8.x, I've now started trying to use PHPUnit testing since Simpletest has been deprecated in Drupal 9.1.x. I started by ...
quant's user avatar
  • 556
4 votes
2 answers
118 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
460 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
120 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
160 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
365 views

JSON:API FieldEnhancers - removing a resource object from a JSON:API response

I need to remove a resource object (in this case a paragraph) from a JSON:API response when it matches a specific condition. I do not want to delete it, I just want to exclude the object from the ...
theine's user avatar
  • 41
4 votes
0 answers
3k 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
507 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
295 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
130 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

1
2 3 4 5
36