'title', 'fillpdf_fields' => 'value', ); foreach ($tables as $table => $column) { // Only attempt to act on tables that exist. if (!db_table_exists($table)) { continue; } // Grab all values that need to be updated. $query = db_select($table) ->distinct() ->fields($table, array($column)) ->condition($column, '%[webform:%', 'LIKE') ->execute(); while ($result = $query->fetch()) { $old = $result->$column; // Filter old value to get new value. $new = str_replace('[webform:meta-nid]', '[node:nid]', $old); $new = str_replace('[webform:meta-sid]', '[submission:sid]', $new); $new = str_replace('[webform:meta-remote_addr]', '[submission:ip-address]', $new); $new = preg_replace('/\[webform:meta-nid:([^\]]*)\]/', '[node:$1]', $new); $new = preg_replace('/\[webform:meta-submitted(:[^\]]*)?\]/', '[submission:date$1]', $new); $new = preg_replace('/\[webform:meta-uid(:[^\]]*)?\]/', '[submission:user$1]', $new); $new = preg_replace('/\[webform:meta-label-([^\]]+)\]/', '[submission:values:$1:label]', $new); $new = preg_replace('/\[webform:val-([^\]]+)\]/', '[submission:values:$1]', $new); // Change all old values to new value, once per value. if ($old !== $new) { db_update($table) ->fields(array( $column => $new, )) ->condition($column, $old, '=') ->execute(); } } } }