I am using Drupal 9.2.7 on XAMPP 7.3.29 , with PHP 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 root/modules/globalrs directory root/modules/globalrs
with the following files.:
globalrs.info.yml
globalrs.info.yml
name: globalrs
type: module
core_version_requirement: ^8 || ^9
description: 'globalrs'
libraries:
- globalrs/globalrs
globalrs.module
globalrs.module
function globalrs_preprocess_page(&$variables) {
$variables['#attached']['library'][] = 'globalrs/globalrs';
}
globalrs.libraries.yml
globalrs.libraries.yml
globalrs:
js:
behavior.js: {}
css:
theme:
style.css: {}
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 (theflushing all cache_cache_
tables, as well as the *cachetags`cachetags
table, and flushing the browser's cache), the website still has that error. Sinceerror;
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
I believe thatEdit (removing the problem happened sometime when I tried to restore a backuprest of the website toerror messages because this is caused by an unrelated error while restoring a new emptybackup):
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 with-specific privileges that the same name which was registered as associated withdatabase user had on the database user (or appeareddatabase with the same name and then re-granted these database-specific privileges1 to be such) but actually wasn'tthat user; I could then access the website.