![]() ![]() Making some developing I've accidentally commented out a line of drupal core code and after refreshing a page everything was gone away. Output should be something like this: -+-+-+ To check if this fix applies to you run: select name, uid Should this happen to you, you can fix your database by issuing the following query: UPDATE users SET uid = 0 WHERE name = '' The result of this is when importing a faulty database dump, your anonymous user record gets imported as (highest user ID) +1 instead of user ID 0. Output should be like this: -+-+-+įixing cases where the import changed the uid valuesĬertain database dump programs, such as older versions of phpMyAdmin, do not respect MySQL's SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO" directive. Select name, uid from users where name = '' INSERT INTO `users` (`uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`, `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`) This pair of statements will bring the user back on Drupal 6: SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO" You can also insert directly with a specific value for the auto-incrementing UID if you tell your database to use a different SQL_MODE. ![]() For Drupal 6 using a slightly different technique This will insert a new row getting a random UID and then the update query fixes to get the right uid for the user. via Drush: drush -u 1 sql-query "INSERT INTO users (name, pass, mail, theme, signature, language, init, timezone) VALUES ('', '', '', '', '', '', '', '')"ĭrush -u 1 sql-query "UPDATE users SET uid = 0 WHERE name = ''" UPDATE users SET uid = 0 WHERE name = '' Į.g. Drupal 7įor Drupal 7, you can run two queries: INSERT INTO users (name, pass, mail, theme, signature, language, init, timezone) VALUES ('', '', '', '', '', '', '', '') via Drush: drush -u 1 sql-query "INSERT INTO users (uid, langcode, uuid) VALUES (0, "en", "") " Drupal 8įor Drupal 8, you can run the following query: INSERT INTO users (uid, langcode, uuid) VALUES (0, "en", "") Į.g. ![]() Below are different techniques that work on Drupal 7 or Drupal 6. The technique to fix it depends on a few factors. There are many ways to accidentally delete the uid 0 (Anonymous) user: a mistaken query that forgot to use "and uid != 0" or a Views Bulk Operations view that was a little too aggressive. "warning: Invalid argument supplied for foreach() in /includes/form.inc on line 1181." and various other strange errors from Drupal coreįixing cases where you accidentally deleted the user."Could not login with user ID #0." error from Drush.Having the Anonymous user deleted in your site breaks Drupal in unexpected ways, including a message like: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |