Drupal 9.2.7 on XAMPP 7.3.29 , 7.4.21 on Windows 10 Home.
I tried to create a custom module which allows global JavaScript and CSS (effective in all webpages in my website), by creating the directory root/modules/globalrs
with the following files:
globalrs.info.yml
name: globalrs
type: module
core_version_requirement: ^8 || ^9
description: 'globalrs'
libraries:
- globalrs/globalrs
globalrs.module
function globalrs_preprocess_page(&$variables) {
$variables['#attached']['library'][] = 'globalrs/globalrs';
}
globalrs.libraries.yml
globalrs:
js:
behavior.js: {}
css:
theme:
style.css: {}
style.css
* {
background: red;
}
My problem
My problem is that the website won't load, instead the following error appears:
The website encountered an unexpected error. Please try again later.
Even if I delete the module directory and flush all caches (flushing all cache_
tables as well as the cachetags
table, and flushing the browser's cache, the website still has that error;
Since that error is generic, I don't know how to start to solve the problem.
A bug as a possible reason
It may be that the problem started after I have added $settings['rebuild_access'] = TRUE;
to the end of /sites/default/settings.php, saved the file and then navigated in my web browser to localhost/example.com/core/rebuild.php, where I got the following error:
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1044] Access
denied for user 'example.com'@'localhost' to database 'example.com' in
Edit (removing the rest of the error messages because this is caused by an unrelated error while restoring a backup):
I believe that the problem happened sometime when I tried to restore a
backup of the website to a new empty database with the same name which
was registered as associated with the database user (or appeared to be
such) but actually wasn't
Update - solution
I paste this here after Clive deleted my answer:
I revoked all database-specific privileges that the database user had on the database with the same name and then re-granted these database-specific privileges1 to that user; I could then access the website.