I use Drupal 7.26 and securepages 7.x-beta2. I have problem with menu form (created by Menu Editor module 7.x-1.0-beta3). If I open main menu (a lot of menu items) in two browser tabs I get "The form has become outdated. Copy any unsaved work in the form below and then reload this page.". Problem is that even if I close one of tabs and reload page again error will not disappear.


warwickshaw’s picture

To fix the error message: 'The form has become outdated. ...' try moving the 'drupal_private_key' in to the Drupal 7 settings.php file.

The Issue
drupal_get_private_key() is not a safe function.

When variable_get() doesn't return a $key (some outage, maybe a memcached restarted) you suddenly and silently get assigned a new drupal_get_private_key.

If you are using multiple server Drupal system where each server has it's own MySql database replicated from a Master DB, a Slave DB can end up with it's own key (which Master doesn't see) and when the slave gets it's key cached in memcached the fun begins.

Mean while back in the D7 Admin, forms and menus that once worked start failing!

The Fix
The only safe place in D7 whether using a single or multi-server setup is to move 'drupal_private_key' value to the settings.php file.

$conf['drupal_private_key'] = '...';

To get the value execute on the Staging server (MySql master)
drush ev 'print drupal_get_private_key();'
and assign the value above.

You should have something like this (these are example values, don't use)
$drupal_hash_salt = 'j8lnCx-XF3gq_2NmnnHZ61Q3xlbKHFSzZ9EmUouPwKU';
$conf['drupal_private_key'] = 'Fnll-1ZETTb03CgO6PW4COWT7CjTBeRSAQzXqerq6FA';

Check the hash_salt is behaving correctly (should match $drupal_hash_salt)
drush ev 'print drupal_get_hash_salt();'

Copy these setting to all other servers in the same Drupal cluster.

On Stage update 'drupal_private_key' row with value used in the settings.php file. This will replicate and reset any MySql slaves out of sync.
update variable set value = '[drupal_private_key]' where name = 'drupal_private_key';

On Stage execute
drush cc all

Clear your browser cache.

You are good to go!

New D7 Projects
When ever you create a new Drupal project make this the first task after installation.

Other Symptoms of the Same Bug
Multiple Save, Cancel buttons appears after clicking Save or Cancel in Page layouts.

prernaprakash3452’s picture

It worked.But the error still shows up when I try to save existing contents.For new contents it is not creating any problem.Any idea ?

Mo Omar’s picture

bump to this last question.

donquixote’s picture

Is this problem specific to menu_editor + securepages, or does it also happen with other big forms in combination with securepages?

What you could do is artificially create a big heavy form in a custom module, and test it with securepages.

olisb’s picture

i get the same issue when trying to add a view as a menu item.
The view is quite big and contains 12 different blocks.
this hack seemed to 'fix' my issue https://www.drupal.org/node/2557327

thomas1977’s picture

Same problem here. Can't add new/edit existing menu items (Menu Views module used). Haven't had this problem before.

vlalieu’s picture

The problem is still there in Drupal version 7.43, when using OpenLayer3 version 7.x-3.1, and using the Open-layer Block Switcher.
I fixed it the dirty way directly in the code of includes/form.inc at line 1839 :
if (isset($element['#token']) && $element['#token']!= 'olebs_blockswitcher_form')

nitin.k’s picture

Setting form token to FALSE might be a solution but sometimes the function which you pass in access callback can lead to this error.