0

This would be in an install file in a module. The purpose is to create setting for a module that is already installed (the module is node_revision_delete). I know how to use variable_set to change a value in the variable table but not when it is longblob. Do I just use the variables from the module? Do you know of any examples I could look at?

2
  • All variables values are stored as longblob in the variable table. Are you asking how to set a complex value (as opposed to an int or string)? Commented Sep 17, 2020 at 3:51
  • yes, I think that is what I am asking. Should I use the variables from the module? Commented Sep 17, 2020 at 11:25

1 Answer 1

0

With variable_set() you can set a persistent variable to any PHP value, including array. variable_set() will serialize the value passed as second argument, and variable_get() will unserialize that value. If you pass an array to variable_set() for a persistent variable, variable_get() will return an array for the same persistent variable (if another module doesn't change that persistent variable's value to an integer, for example).

Suppose that you want to change the value of node_revision_delete_minimum_age_to_delete_time, which is set from that module in its installation hook using the following code.

 $node_revision_delete_minimum_age_to_delete_time = array( 'max_number' => 12, 'time' => 'months', ); variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time); 

If you want to change max_number to 24, you would use code similar to the following one.

$node_revision_delete_minimum_age_to_delete_time = variable_get('node_revision_delete_minimum_age_to_delete_time', array()); if (is_array($node_revision_delete_minimum_age_to_delete_time)) { $node_revision_delete_minimum_age_to_delete_time['max_number'] = 24; variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time); } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.