drupal

Views usefull snippets

To remove views unsaved changes, sometimes can be usefull when after views change you cannot access edit page.

drush eval "\Drupal::keyValueExpirable('tempstore.shared.views')->delete('VIEW_NAME');"


To get query from the view:

$query = $view->getQuery();
$query_string = $query->query()->__toString();
dpm($query_string);

To get arguments: 

Change schema version of a module

For Drupal8+:
Manually setting the current schema version of a module

drush eval "\Drupal::service('update.update_hook_registry')->setInstalledVersion('my_module', 9001);"

Or in this way:

\Drupal::keyValue('system.schema')->set('my_module', (int) 9001);

For Drupal 7:

drush ev "drupal_set_installed_schema_version('my_module', 7025)"


To get installed version for Drupal8+:

Disable cron

Drupal 7:

// Disable drupal's built in cron trigger.
$conf['cron_safe_threshold'] = 0;

Drupal 8/9:

// Disable drupal's built in cron trigger.
$config['automated_cron.settings']['interval'] = 0;

Reset password for the admin user

For Drupal 7
restore admin password

drush sqlq "select name from users where uid=1"

Once you know the name, you can reset the password as follows:

drush upwd admin --password=pass

 

For Drupal 8+

drush user:password site-admin "password"

UPDATE ALL USER PASSWORDS TO ADMIN PASSWORD

drush sql-query "UPDATE users_field_data set pass=(SELECT pass FROM users_field_data where uid=1) WHERE uid <>1"

After this need to clear cache:
drush cr

 

Subscribe to drupal