This project is archived. Its data is
read-only
.
Changes
Page history
Update Drupal Debug Hints
authored
Dec 26, 2024
by
Tom Wiesing
Hide whitespace changes
Inline
Side-by-side
Drupal-Debug-Hints.md
View page @
e6aa1651
Because drupal frequently misbehaves, here is a list of useful snippets.
Because drupal frequently misbehaves, here is a list of useful snippets.
This isn't intended for end-users of the distillery, but just listed here so we don't have to keep searching for it.
This isn't intended for end-users of the distillery, but just listed here so we don't have to keep searching for it.
# Export, Import and Edit/Delete Module Configs
# Export, Import and Edit/Delete Module Configs
The whole Drupal config can be exported with:
The whole Drupal config can be exported with:
```
```
drush cex -y
drush cex -y
```
```
This will export all config files to
`/web/sites/default/files/config_SOME_HASH/sync/`
.
This will export all config files to
`/web/sites/default/files/config_SOME_HASH/sync/`
.
Here you can edit/delete the configs that are causing problems.
Here you can edit/delete the configs that are causing problems.
After you're done you can import the config again with:
After you're done you can import the config again with:
```
```
drush cim -y
drush cim -y
```
```
# Enable Stack Traces
# Enable Stack Traces
The DSOD usually only says
`The website encountered an unexpected error. `
The DSOD usually only says
`The website encountered an unexpected error. `
When
`Reports > Recent Log Messages`
is inaccessible, you can enable full stack traces.
When
`Reports > Recent Log Messages`
is inaccessible, you can enable full stack traces.
Run
`vim web/sites/default/settings.php`
and add:
Run
`vim web/sites/default/settings.php`
and add:
```
php
```
php
$config
[
"system.logging"
][
"error_level"
]
=
"verbose"
;
$config
[
"system.logging"
][
"error_level"
]
=
"verbose"
;
```
```
Might have to ignore the readonly flag (with
`:w!`
).
Might have to ignore the readonly flag (with
`:w!`
).
# Clear APCu cahe to fix incorrect classloading
# Clear APCu cahe to fix incorrect classloading
When classes are not found, even though they are definitely there.
When classes are not found, even though they are definitely there.
Restart the system to clear the APCu cache, or disable APCu via:
Restart the system to clear the APCu cache, or disable APCu via:
`vim web/sites/default/settings.php`
and add:
`vim web/sites/default/settings.php`
and add:
```
php
```
php
$settings
[
'class_loader_auto_detect'
]
=
FALSE
;
$settings
[
'class_loader_auto_detect'
]
=
FALSE
;
```
```
Might have to ignore the readonly flag (with
`:w!`
).
Might have to ignore the readonly flag (with
`:w!`
).
# Manually deleting log messages
# Manually deleting log messages
Sometimes the log page fails to load with a fatal error.
Sometimes the log page fails to load with a fatal error.
Delete the watchdog messages by hand:
Delete the watchdog messages by hand:
```
```
drush watchdog:delete all
drush watchdog:delete all
```
```
# Manually disabling a module
# Manually disabling a module
When doing manual migrations or upgrades, an error like the following can occur
When doing manual migrations or upgrades, an error like the following can occur
```
```
(Currently using Missing or invalid modules The following modules are marked as installed in the core.extension
(Currently using Missing or invalid modules The following modules are marked as installed in the core.extension
configuration, but they are missing:
configuration, but they are missing:
```
```
To fix this, either re-install the module (using composer and friends) or run this code to disable it:
To fix this, either re-install the module (using composer and friends) or run this code to disable it:
```
php
```
php
drush
eval
"function disable(
\$
modname) {
\$
module_data = \Drupal::config('core.extension')->get('module'); unset(
\$
module_data[
\$
modname]); \Drupal::configFactory()->getEditable('core.extension')->set('module',
\$
module_data)->save(); }; disable('name-of-module'); "
drush
eval
"function disable(
\$
modname) {
\$
module_data = \Drupal::config('core.extension')->get('module'); unset(
\$
module_data[
\$
modname]); \Drupal::configFactory()->getEditable('core.extension')->set('module',
\$
module_data)->save(); }; disable('name-of-module'); "
```
```
You might also have to delete some config files the module comes with if you want to reinstall it:
You might also have to delete some config files the module comes with if you want to reinstall it:
```
```
drush config-delete module_name.settings_name
drush config-delete module_name.settings_name
```
```
# Remove Module Config
# Remove Module Config
Sometimes
`update.php`
says:
Sometimes
`update.php`
says:
```
```
Module my_already_removed_module has a schema in the key_value store, but is missing from your site.
Module my_already_removed_module has a schema in the key_value store, but is missing from your site.
Module update_test_0 has a schema in the key_value store, but is not installed.
Module update_test_0 has a schema in the key_value store, but is not installed.
```
```
As per
[
Drupal Doc
](
https://www.drupal.org/node/3137656
)
, to fix this without reinstalling, you can run:
As per
[
Drupal Doc
](
https://www.drupal.org/node/3137656
)
, to fix this without reinstalling, you can run:
```
```
drush php-eval "\Drupal::keyValue('system.schema')->delete('my_already_removed_module');"
drush php-eval "\Drupal::keyValue('system.schema')->delete('my_already_removed_module');"
drush php-eval "\Drupal::keyValue('system.schema')->delete('update_test_0');"
drush php-eval "\Drupal::keyValue('system.schema')->delete('update_test_0');"
```
```
Alternatively, you can also install the module again, deactivate and uninstall it, and then remove the files.
Alternatively, you can also install the module again, deactivate and uninstall it, and then remove the files.
# Fix Revision ID Field needs to be installed
# Fix Mismatched entity and/or field definitions
```
php
drush
eval
"
\$
edum =
\\
Drupal::entityDefinitionUpdateManager();
\$
fs =
\\
Drupal::service('entity_field.manager')->getFieldStorageDefinitions('wisski_individual');
\$
edum->updateFieldableEntityType(
\\
Drupal::entityTypeManager()->getDefinition('wisski_individual'),
\$
fs);"
1.
Install https://www.drupal.org/project/devel_entity_updates:
```
```
bash
# Fix Field $FIELD needs to be uninstalled
composer require
'drupal/devel_entity_updates:^4.2'
```
php
```
drush
eval
"
\$
manager =
\\
Drupal::entityDefinitionUpdateManager();
\$
definition =
\$
manager->getFieldStorageDefinition('some_field', 'corresponding_bundle');
NOTE: Version may have changed
\$
manager->uninstallFieldStorageDefinition(
\$
definition);
```
2.
Enable it
```
# Factory SSH Forwarding
drush install devel_entity_updates
```
To portforward all services you can use the following ssh command:
3.
Run the entup command
```
ssh -L 3306:sql:3306 -L 7200:triplestore:7200 -L 8080:phpmyadmin:80 -p 2222 slug@wisski.data.fau.de
```
```
drush entup
```
This forwards:
## Fix Revision ID Field needs to be installed
-
[
GraphDB on `localhost:7200`
](
http://localhost:7200
)
```
php
-
[
PhpMyAdmin on `localhost:8080`
](
http://localhost:8080/
)
drush
eval
"
\$
edum =
\\
Drupal::entityDefinitionUpdateManager();
\$
fs =
\\
Drupal::service('entity_field.manager')->getFieldStorageDefinitions('wisski_individual');
\$
edum->updateFieldableEntityType(
\\
Drupal::entityTypeManager()->getDefinition('wisski_individual'),
\$
fs);"
```
You can also access raw sql, e.g.:
# Fix Field $FIELD needs to be uninstalled
```
```
php
mysql --host=localhost --port=3306 --password --user=username
drush
eval
"
\$
manager =
\\
Drupal::entityDefinitionUpdateManager();
```
\$
definition =
\$
manager->getFieldStorageDefinition('some_field', 'corresponding_bundle');
\$
manager->uninstallFieldStorageDefinition(
\$
definition);
and load an sql file with
`source [filename]`
.
```
# Fix Behaim IDs when someone breaks them
# Factory SSH Forwarding
To portforward all services you can use the following ssh command:
```
DELETE { GRAPH <http://wwwdh.cs.fau.de/behaim/> { ?s ?p ?o } } WHERE {
```
GRAPH <http://wwwdh.cs.fau.de/behaim/> {
ssh -L 3306:sql:3306 -L 7200:triplestore:7200 -L 8080:phpmyadmin:80 -p 2222 slug@wisski.data.fau.de
?s a <http://erlangen-crm.org/120111/E31_Document> .
```
?s ?p ?o
}
This forwards:
}
```
-
[
GraphDB on `localhost:7200`
](
http://localhost:7200
)
-
[
PhpMyAdmin on `localhost:8080`
](
http://localhost:8080/
)
```
PREFIX owl: <http://www.w3.org/2002/07/owl#>
You can also access raw sql, e.g.:
DELETE { GRAPH <http://wwwdh.cs.fau.de/behaim/> { ?s2 owl:sameAs ?s } } WHERE {
GRAPH <http://wwwdh.cs.fau.de/behaim/> {
```
?s a <http://erlangen-crm.org/120111/E31_Document> .
mysql --host=localhost --port=3306 --password --user=username
?s ?p ?o .
```
?s2 owl:sameAs ?s
}
and load an sql file with
`source [filename]`
.
}
# Fix Behaim IDs when someone breaks them
```
```
```
PREFIX owl: <http://www.w3.org/2002/07/owl#>
DELETE { GRAPH <http://wwwdh.cs.fau.de/behaim/> { ?s ?p ?o } } WHERE {
INSERT {
GRAPH <http://wwwdh.cs.fau.de/behaim/> {
GRAPH <http://wwwdh.cs.fau.de/behaim/originatesFrom> {
?s a <http://erlangen-crm.org/120111/E31_Document> .
?x owl:sameAs ?newid .
?s ?p ?o
?newid owl:sameAs ?x
}
}
}
} WHERE {
```
GRAPH ?g {
# select old node ids
```
?x a <http://erlangen-crm.org/120111/E31_Document> .
PREFIX owl: <http://www.w3.org/2002/07/owl#>
?x <http://erlangen-crm.org/120111/P48_has_preferred_identifier> ?y .
DELETE { GRAPH <http://wwwdh.cs.fau.de/behaim/> { ?s2 owl:sameAs ?s } } WHERE {
?y a <http://erlangen-crm.org/120111/E42_Identifier> .
GRAPH <http://wwwdh.cs.fau.de/behaim/> {
?y <http://erlangen-crm.org/120111/P3_has_note> ?id .
?s a <http://erlangen-crm.org/120111/E31_Document> .
?s ?p ?o .
# create proper new URIS
?s2 owl:sameAs ?s
BIND( uri(CONCAT("http://wisski.cs.fau.de/behaim/node/", str(?id))) as ?newid)
}
}
}
}
```
```
# Extract single database from sql backup
```
PREFIX owl: <http://www.w3.org/2002/07/owl#>
Source: https://stackoverflow.com/a/25975930
INSERT {
GRAPH <http://wwwdh.cs.fau.de/behaim/originatesFrom> {
```
?x owl:sameAs ?newid .
sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql
?newid owl:sameAs ?x
```
}
} WHERE {
# Clearing all caches (including opcache)
GRAPH ?g {
# select old node ids
```
?x a <http://erlangen-crm.org/120111/E31_Document> .
drush cr
?x <http://erlangen-crm.org/120111/P48_has_preferred_identifier> ?y .
drush php:eval 'opcache_reset();'
?y a <http://erlangen-crm.org/120111/E42_Identifier> .
?y <http://erlangen-crm.org/120111/P3_has_note> ?id .
# create proper new URIS
BIND( uri(CONCAT("http://wisski.cs.fau.de/behaim/node/", str(?id))) as ?newid)
}
}
```
# Extract single database from sql backup
Source: https://stackoverflow.com/a/25975930
```
sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql
```
# Clearing all caches (including opcache)
```
drush cr
drush php:eval 'opcache_reset();'
```
```
\ No newline at end of file