id stringlengths 22 22 | drupal_version stringclasses 1
value | source_type stringclasses 1
value | source_url stringlengths 70 167 | instruction stringlengths 87 500 | context stringlengths 16 10.7k | response stringlengths 68 5.97k | tags listlengths 2 2 | created_at timestamp[s]date 2026-09-30 00:00:00 2026-09-30 00:00:00 |
|---|---|---|---|---|---|---|---|---|
api-drupal7-d46d7b64c5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_get_cached_available_releases/7.x | In Drupal 7, write the function `_update_get_cached_available_releases()` (file modules/update/update.module) so that it does the following: Returns all currently cached data about available releases for all projects. | Returns (Array): of data about available releases, keyed by project shortname.
File: modules/update/update.module | function _update_get_cached_available_releases() {
$data = array();
$cache_items = _update_get_cache_multiple('available_releases');
foreach ($cache_items as $cid => $cache) {
$cache->data['last_fetch'] = $cache->created;
if ($cache->expire < REQUEST_TIME) {
$cache->data['fetch_status'] = UPDATE_FET... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d474e0fc5f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.fetch.inc/function/_update_cron_notify/7.x | Implement `_update_cron_notify()` in PHP for Drupal 7. Required behavior: Performs any notifications that should be done once cron fetches new data. | This method checks the status of the site using the new data and, depending on the configuration of the site, notifies administrators via e-mail if there are new releases or missing security updates.
File: modules/update/update.fetch.inc | function _update_cron_notify() {
module_load_install('update');
$status = update_requirements('runtime');
$params = array();
$notify_all = (variable_get('update_notification_threshold', 'all') == 'all');
foreach (array('core', 'contrib') as $report_type) {
$type = 'update_' . $report_type;
if (isset($... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d47546d77b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_forms/7.x | I need the code for `search_forms()` in Drupal 7 (modules/search/search.module). It must do this: Implements hook_forms(). | File: modules/search/search.module | function search_forms() {
$forms['search_block_form']= array(
'callback' => 'search_box',
'callback arguments' => array('search_block_form'),
);
return $forms;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d4838d3da7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_stream_wrappers/7.x | Give me the example code for `hook_stream_wrappers()` in Drupal 7. Hook description: Registers PHP stream wrapper implementations associated with a module. | Provide a facility for managing and querying user-defined stream wrappers in PHP. PHP's internal stream_get_wrappers() doesn't return the class registered to handle a stream, which we need to be able to find the handler for class instantiation.
If a module registers a scheme that is already registered with PHP, it wil... | function hook_stream_wrappers() {
return array(
'public' => array(
'name' => t('Public files'),
'class' => 'DrupalPublicStreamWrapper',
'description' => t('Public local files served by the webserver.'),
'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
),
'private' => array(
'name' => ... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-d48dee8972 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_active_help/7.x | In Drupal 7, write the function `menu_get_active_help()` (file includes/menu.inc) so that it does the following: Returns the help associated with the active menu item. | File: includes/menu.inc | function menu_get_active_help() {
$output = '';
$router_path = menu_tab_root_path();
// We will always have a path unless we are on a 403 or 404.
if (!$router_path) {
return '';
}
$arg = drupal_help_arg(arg(NULL));
foreach (module_implements('help') as $module) {
$function = $module . '_help';
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d4afeadba4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.install/function/taxonomy_update_7008/7.x | In Drupal 7, write the function `taxonomy_update_7008()` (file modules/taxonomy/taxonomy.install) so that it does the following: Change the weight columns to normal int. | File: modules/taxonomy/taxonomy.install | function taxonomy_update_7008() {
db_drop_index('taxonomy_term_data', 'taxonomy_tree');
db_change_field('taxonomy_term_data', 'weight', 'weight', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The weight of this term in relation to other terms.',
), array(
'index... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d4b719dc66 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_menu/7.x | I need the code for `statistics_menu()` in Drupal 7 (modules/statistics/statistics.module). It must do this: Implements hook_menu(). | File: modules/statistics/statistics.module | function statistics_menu() {
$items['admin/reports/hits'] = array(
'title' => 'Recent hits',
'description' => 'View pages that have recently been visited.',
'page callback' => 'statistics_recent_hits',
'access arguments' => array('access statistics'),
'file' => 'statistics.admin.inc',
);
$item... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d4bd4ad4cf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.install/function/contact_uninstall/7.x | Implement `contact_uninstall()` in PHP for Drupal 7. Required behavior: Implements hook_uninstall(). | File: modules/contact/contact.install | function contact_uninstall() {
variable_del('contact_default_status');
variable_del('contact_threshold_limit');
variable_del('contact_threshold_window');
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d4c2df055b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.tokens.inc/function/poll_token_info/7.x | I need the code for `poll_token_info()` in Drupal 7 (modules/poll/poll.tokens.inc). It must do this: Implements hook_token_info(). | File: modules/poll/poll.tokens.inc | function poll_token_info() {
$node['poll-votes'] = array(
'name' => t("Poll votes"),
'description' => t("The number of votes that have been cast on a poll."),
);
$node['poll-winner'] = array(
'name' => t("Poll winner"),
'description' => t("The winning poll answer."),
);
$node['poll-winner-vote... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d4c36e6b38 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21image.gd.inc/function/image_gd_get_info/7.x | Implement `image_gd_get_info(stdClass $image)` in PHP for Drupal 7. Required behavior: Get details about an image. | Parameters:
- $image: An image object.
Returns: FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image: - "width": Width, in pixels. - "height": Height, in pixels. - "extension": Commonly used file extension for the image. - "mime_type": MIME type ('im... | function image_gd_get_info(stdClass $image) {
$details = FALSE;
$data = @getimagesize($image->source);
if (isset($data) && is_array($data)) {
$extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
$extension = isset($extensions[$data[2]]) ? $extensions[$data[2]] : '';
$details = array(
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d4c8df7ed6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_allowed_values_string/7.x | I need the code for `list_allowed_values_string($values)` in Drupal 7 (modules/field/modules/list/list.module). It must do this: Generates a string representation of an array of 'allowed values'. | This string format is suitable for edition in a textarea.
Parameters:
- $values: An array of values, where array keys are values and array values are labels.
Returns: The string representation of the $values array: - Values are separated by a carriage return. - Each value is in the format "value|label" or "value".
F... | function list_allowed_values_string($values) {
$lines = array();
foreach ($values as $key => $value) {
$lines[] = "$key|$value";
}
return implode("\n", $lines);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d4d27873f0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.install/function/text_update_7000/7.x | Implement `text_update_7000()` in PHP for Drupal 7. Required behavior: Change text field 'format' columns into varchar. | File: modules/field/modules/text/text.install | function text_update_7000() {
$spec = array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
);
$fields = _update_7000_field_read_fields(array(
'module' => 'text',
'storage_type' => 'field_sql_storage',
));
foreach ($fields as $field) {
if ($field['deleted']) {
$table ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d4d77c0d00 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/path_to_theme/7.x | I need the code for `path_to_theme()` in Drupal 7 (includes/theme.inc). It must do this: Returns the path to the current themed element. | It can point to the active theme or the module handling a themed implementation. For example, when invoked within the scope of a theming call it will depend on where the theming function is handled. If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the act... | function path_to_theme() {
global $theme_path;
if (!isset($theme_path)) {
drupal_theme_initialize();
}
return $theme_path;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d4e61be6d0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_assign_owner_action_validate/7.x | I need the code for `node_assign_owner_action_validate($form, $form_state)` in Drupal 7 (modules/node/node.module). It must do this: Validates settings form for node_assign_owner_action(). | File: modules/node/node.module | function node_assign_owner_action_validate($form, $form_state) {
$exists = (bool) db_query_range('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField();
if (!$exists) {
form_set_error('owner_name', t('Enter a valid username.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d53ae170a3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_dashboard_regions/7.x | In Drupal 7, write the function `dashboard_dashboard_regions()` (file modules/dashboard/dashboard.module) so that it does the following: Implements hook_dashboard_regions(). | File: modules/dashboard/dashboard.module | function dashboard_dashboard_regions() {
return array(
'dashboard_main' => 'Dashboard (main)',
'dashboard_sidebar' => 'Dashboard (sidebar)',
'dashboard_inactive' => 'Dashboard (inactive)',
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d546f6fc9f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.module/function/number_field_settings_form/7.x | In Drupal 7, write the function `number_field_settings_form($field, $instance, $has_data)` (file modules/field/modules/number/number.module) so that it does the following: Implements hook_field_settings_form(). | File: modules/field/modules/number/number.module | function number_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form = array();
if ($field['type'] == 'number_decimal') {
$form['precision'] = array(
'#type' => 'select',
'#title' => t('Precision'),
'#options' => drupal_map_assoc(range(10, 32)),
'#... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d559558e0f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_parse_dependency/7.x | I need the code for `drupal_parse_dependency($dependency)` in Drupal 7 (includes/common.inc). It must do this: Parses a dependency for comparison by drupal_check_incompatibility(). | Parameters:
- $dependency: A dependency string, which specifies a module dependency, and optionally the project it comes from and versions that are supported. Supported formats include: - 'module' - 'project:module' - 'project:module (>=version, version)'
Returns: An associative array with three keys: - 'name' include... | function drupal_parse_dependency($dependency) {
$value = array();
// Split out the optional project name.
if (strpos($dependency, ':')) {
list($project_name, $dependency) = explode(':', $dependency);
$value['project'] = $project_name;
}
// We use named subpatterns and support every op that version_com... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d59829c098 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/_statistics_format_item/7.x | In Drupal 7, write the function `_statistics_format_item($title, $path)` (file modules/statistics/statistics.module) so that it does the following: Formats an item for display, including both the item title and the link. | Parameters:
- $title: The text to link to a path; will be truncated to a maximum width of 35.
- $path: The path to link to; will default to '/'.
Returns: An HTML string with $title linked to the $path.
File: modules/statistics/statistics.module | function _statistics_format_item($title, $path) {
$path = ($path ? $path : '/');
$output = ($title ? "$title<br />" : '');
$output .= _statistics_link($path);
return $output;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d5b70124dd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_settings_form/7.x | In Drupal 7, write the function `install_settings_form($form, &$form_state, &$install_state)` (file includes/install.core.inc) so that it does the following: Form constructor for a form to configure and rewrite settings.php. | Parameters:
- $install_state: An array of information about the current installation state.
File: includes/install.core.inc | function install_settings_form($form, &$form_state, &$install_state) {
global $databases;
$profile = $install_state['parameters']['profile'];
$install_locale = $install_state['parameters']['locale'];
drupal_static_reset('conf_path');
$conf_path = './' . conf_path(FALSE);
$settings_file = $conf_path . '/set... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d5cb682108 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.install/function/statistics_update_7000/7.x | I need the code for `statistics_update_7000()` in Drupal 7 (modules/statistics/statistics.install). It must do this: Update the {accesslog}.sid column to match the length of {sessions}.sid | File: modules/statistics/statistics.install | function statistics_update_7000() {
db_change_field('accesslog', 'sid', 'sid', array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Browser session ID of user that visited page.',
));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d5d2ba2f4f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7.x | I need the code for `theme_table(array $variables)` in Drupal 7 (includes/theme.inc). It must do this: Returns HTML for a table. | Parameters:
- $variables (array): An associative array containing: - header: An array containing the table headers. Each element of the array can be either a localized string or an associative array with the following keys: - "data": The localized title of the table column. - "field": The database field represented in ... | function theme_table(array $variables) {
$header = $variables['header'];
$rows = $variables['rows'];
$attributes = $variables['attributes'];
$caption = $variables['caption'];
$colgroups = $variables['colgroups'];
$sticky = $variables['sticky'];
$empty = $variables['empty'];
// Add sticky headers, if ap... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d5d35b717c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/dblog_top/7.x | Implement `dblog_top($type)` in PHP for Drupal 7. Required behavior: Page callback: Shows the most frequent log messages of a given event type. | Messages are not truncated on this page because events detailed herein do not have links to a detailed view.
Parameters:
- $type (string): Type of database log events to display (e.g., 'search').
Returns (array): A build array in the format expected by drupal_render().
File: modules/dblog/dblog.admin.inc | function dblog_top($type) {
$header = array(
array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'),
array('data' => t('Message'), 'field' => 'message')
);
$count_query = db_select('watchdog');
$count_query->addExpression('COUNT(DISTINCT(message))');
$count_query->condition('type', $type);... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d5fc126d85 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_button/7.x | In Drupal 7, write the function `form_process_button($element, &$form_state)` (file includes/form.inc) so that it does the following: Processes a form button element. | Parameters:
- $element: An associative array containing the properties and children of the form button.
- $form_state: The $form_state array for the form this element belongs to.
Returns: The processed element.
File: includes/form.inc | function form_process_button($element, &$form_state) {
// We normally want to add drupal.form-single-submit so that the double submit
// protection can be added to the site, however, with the addition of
// javascript_always_use_jquery, this would make most pages with a login
// block or a search form have jque... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d601eb35cf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_append/7.x | Implement `ajax_command_append($selector, $html, $settings = NULL)` in PHP for Drupal 7. Required behavior: Creates a Drupal Ajax 'insert/append' command. | The 'insert/append' command instructs the client to use jQuery's append() method to append the given HTML content to the inside of each element matched by the given selector.
This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.
Parameters:
- $selector: A jQuery selector stri... | function ajax_command_append($selector, $html, $settings = NULL) {
return array(
'command' => 'insert',
'method' => 'append',
'selector' => $selector,
'data' => $html,
'settings' => $settings,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d60401a2dd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_login_destination/7.x | I need the code for `user_login_destination()` in Drupal 7 (modules/user/user.module). It must do this: Helper function to rewrite the destination to avoid redirecting to login page after login. | Third-party authentication modules may use this function to determine the proper destination after a user has been properly logged in.
File: modules/user/user.module | function user_login_destination() {
$destination = drupal_get_destination();
if ($destination['destination'] == 'user/login') {
$destination['destination'] = 'user';
}
return $destination;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d63ac82ec4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_render_cache_get/7.x | Implement `drupal_render_cache_get($elements)` in PHP for Drupal 7. Required behavior: Gets the rendered output of a renderable element from the cache. | Parameters:
- $elements: A renderable array.
Returns: A markup string containing the rendered content of the element, or FALSE if no cached copy of the element is available.
File: includes/common.inc | function drupal_render_cache_get($elements) {
if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
return FALSE;
}
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
if (!empty($cid) && $cache = cache_get($cid, $bin)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d64ac018e4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.module/function/profile_block_configure/7.x | Implement `profile_block_configure($delta = '')` in PHP for Drupal 7. Required behavior: Implements hook_block_configure(). | File: modules/profile/profile.module | function profile_block_configure($delta = '') {
// Compile a list of fields to show
$fields = array();
$result = db_query('SELECT name, title, weight, visibility FROM {profile_field} WHERE visibility IN (:visibility) ORDER BY weight', array(':visibility' => array(PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS)));
fore... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d65679d2e4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/theme_poll_choices/7.x | I need the code for `theme_poll_choices($variables)` in Drupal 7 (modules/poll/poll.module). It must do this: Returns HTML for an admin poll form for choices. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/poll/poll.module | function theme_poll_choices($variables) {
$form = $variables['form'];
drupal_add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight');
$is_admin= user_access('administer nodes');
$delta = 0;
$rows = array();
$headers = array('', t('Choice'));
if ($is_admin) {
$headers[] = t('Vote count'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d688bbd73a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_widget_info_alter/7.x | In Drupal 7, show an example implementation for `hook_field_widget_info_alter(&$info)` (modules/field/field.api.php): Perform alterations on Field API widget types. | Parameters:
- $info: Array of informations on widget types exposed by hook_field_widget_info() implementations.
File: modules/field/field.api.php | function hook_field_widget_info_alter(&$info) {
// Add a setting to a widget type.
$info['text_textfield']['settings'] += array(
'mymodule_additional_setting' => 'default value',
);
// Let a new field type re-use an existing widget.
$info['options_select']['field types'][] = 'my_field_type';
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-d68d8b51bb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7080/7.x | I need the code for `system_update_7080()` in Drupal 7 (modules/system/system.install). It must do this: Convert the 'format' column in {date_format_locale} to case sensitive varchar. | File: modules/system/system.install | function system_update_7080() {
$spec = array(
'description' => 'The date format string.',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'binary' => TRUE,
);
db_change_field('date_format_locale', 'format', 'format', $spec);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d6aa14aba9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.install/function/contact_update_7002/7.x | In Drupal 7, write the function `contact_update_7002()` (file modules/contact/contact.install) so that it does the following: Enable the 'access user contact forms' for registered users by default. | File: modules/contact/contact.install | function contact_update_7002() {
// Do not use user_role_grant_permission() since it relies on
// hook_permission(), which will not run for contact module if it is
// disabled.
db_merge('role_permission')
->key(array(
'rid' => DRUPAL_AUTHENTICATED_RID,
'permission' => 'access user contact forms'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d6c3d086a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21syslog%21syslog.module/function/syslog_facility_list/7.x | I need the code for `syslog_facility_list()` in Drupal 7 (modules/syslog/syslog.module). It must do this: Lists all possible syslog facilities for UNIX/Linux. | Returns (array): An array of syslog facilities for UNIX/Linux.
File: modules/syslog/syslog.module | function syslog_facility_list() {
return array(
LOG_LOCAL0 => 'LOG_LOCAL0',
LOG_LOCAL1 => 'LOG_LOCAL1',
LOG_LOCAL2 => 'LOG_LOCAL2',
LOG_LOCAL3 => 'LOG_LOCAL3',
LOG_LOCAL4 => 'LOG_LOCAL4',
LOG_LOCAL5 => 'LOG_LOCAL5',
LOG_LOCAL6 => 'LOG_LOCAL6',
LOG_LOCAL7 => 'LOG_LOCAL7',
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d6cd99d283 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_valid_uri/7.x | In Drupal 7, write the function `file_valid_uri($uri)` (file includes/file.inc) so that it does the following: Determines whether the URI has a valid scheme for file API operations. | There must be a scheme and it must be a Drupal-provided scheme like 'public', 'private', 'temporary', or an extension provided with hook_stream_wrappers().
Parameters:
- $uri: The URI to be tested.
Returns: TRUE if the URI is allowed.
File: includes/file.inc | function file_valid_uri($uri) {
// Assert that the URI has an allowed scheme. Barepaths are not allowed.
$uri_scheme = file_uri_scheme($uri);
if (empty($uri_scheme) || !file_stream_wrapper_valid_scheme($uri_scheme)) {
return FALSE;
}
return TRUE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d6e3ab20ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_load/7.x | I need the code for `image_style_load($name = NULL, $isid = NULL, $include = NULL)` in Drupal 7 (modules/image/image.module). It must do this: Loads a style by style name or ID. | May be used as a loader for menu items.
Parameters:
- $name: The name of the style.
- $isid: Optional. The numeric id of a style if the name is not known.
- $include: If set, this loader will restrict to a specific type of image style, may be one of the defined Image style storage constants.
Returns: An image style a... | function image_style_load($name = NULL, $isid = NULL, $include = NULL) {
$styles = image_styles();
// If retrieving by name.
if (isset($name) && isset($styles[$name])) {
$style = $styles[$name];
}
// If retrieving by image style id.
if (!isset($name) && isset($isid)) {
foreach ($styles as $name =>... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d70eb23f71 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_page_alter/7.x | In Drupal 7, show an example implementation for `hook_page_alter(&$page)` (modules/system/system.api.php): Perform alterations before a page is rendered. | Use this hook when you want to remove or alter elements at the page level, or add elements at the page level that depend on an other module's elements (this hook runs after hook_page_build().
If you are making changes to entities such as forms, menus, or user profiles, use those objects' native alter hooks instead (ho... | function hook_page_alter(&$page) {
// Add help text to the user login block.
$page['sidebar_first']['user_login']['help'] = array(
'#weight' => -10,
'#markup' => t('To post comments or add new content, you first have to log in.'),
);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-d737c78a4a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_system_info_alter/7.x | I need the code for `field_system_info_alter(&$info, $file, $type)` in Drupal 7 (modules/field/field.module). It must do this: Implements hook_system_info_alter(). | Goes through a list of all modules that provide a field type, and makes them required if there are any active fields of that type.
File: modules/field/field.module | function field_system_info_alter(&$info, $file, $type) {
if ($type == 'module' && module_hook($file->name, 'field_info')) {
$fields = field_read_fields(array('module' => $file->name), array('include_deleted' => TRUE));
if ($fields) {
$info['required'] = TRUE;
// Provide an explanation message (on... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d746e4113a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_block_view_alter/7.x | Implement `menu_block_view_alter(&$data, $block)` in PHP for Drupal 7. Required behavior: Implements hook_block_view_alter(). | File: modules/menu/menu.module | function menu_block_view_alter(&$data, $block) {
// Add contextual links for system menu blocks.
if ($block->module == 'system' && !empty($data['content'])) {
$system_menus = menu_list_system_menus();
if (isset($system_menus[$block->delta])) {
$data['content']['#contextual_links']['menu'] = array('adm... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d75be624b7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_autocomplete/7.x | I need the code for `user_autocomplete($string = '')` in Drupal 7 (modules/user/user.pages.inc). It must do this: Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users. | File: modules/user/user.pages.inc | function user_autocomplete($string = '') {
$matches = array();
if ($string) {
$result = db_select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute();
foreach ($result as $user) {
$matches[$user->name] = check_plain($user->name);
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d7763818ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21bartik%21template.php/function/bartik_process_html/7.x | I need the code for `bartik_process_html(&$variables)` in Drupal 7 (themes/bartik/template.php). It must do this: Override or insert variables into the page template for HTML output. | File: themes/bartik/template.php | function bartik_process_html(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_html_alter($variables);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d777e93fae | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_next/7.x | I need the code for `theme_pager_next($variables)` in Drupal 7 (includes/pager.inc). It must do this: Returns HTML for the "next page" link in a query pager. | Parameters:
- $variables: An associative array containing: - text: The name (or image) of the link. - element: An optional integer to distinguish between multiple pagers on one page. - interval: The number of pages to move forward when the link is clicked. - parameters: An associative array of query string parameters t... | function theme_pager_next($variables) {
$text = $variables['text'];
$element = $variables['element'];
$interval = $variables['interval'];
$parameters = $variables['parameters'];
global $pager_page_array, $pager_total;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$el... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d7a04e4377 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_is_empty/7.x | Implement `text_field_is_empty($item, $field)` in PHP for Drupal 7. Required behavior: Implements hook_field_is_empty(). | File: modules/field/modules/text/text.module | function text_field_is_empty($item, $field) {
if (!isset($item['value']) || $item['value'] === '') {
return !isset($item['summary']) || $item['summary'] === '';
}
return FALSE;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d7a8b172a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_array_merge_deep/7.x | Implement `drupal_array_merge_deep()` in PHP for Drupal 7. Required behavior: Merges multiple arrays, recursively, and returns the merged array. | This function is similar to PHP's array_merge_recursive() function, but it handles non-array values differently. When merging values that are not both arrays, the latter value replaces the former rather than merging with it.
Example:
Returns: The merged array.
File: includes/bootstrap.inc | function drupal_array_merge_deep() {
$args = func_get_args();
return drupal_array_merge_deep_array($args);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d7b416186f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_view/7.x | In Drupal 7, show an example implementation for `hook_user_view($account, $view_mode, $langcode)` (modules/user/user.api.php): The user's account information is being displayed. | The module should format its custom additions for display and add them to the $account->content array.
Parameters:
- $account: The user object on which the operation is being performed.
- $view_mode: View mode, e.g. 'full'.
- $langcode: The language code used for rendering.
File: modules/user/user.api.php | function hook_user_view($account, $view_mode, $langcode) {
if (user_access('create blog content', $account)) {
$account->content['summary']['blog'] = array(
'#type' => 'user_profile_item',
'#title' => t('Blog'),
'#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attribut... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-d7dc764ed2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_load_stylesheet_content/7.x | I need the code for `drupal_load_stylesheet_content($contents, $optimize = FALSE)` in Drupal 7 (includes/common.inc). It must do this: Processes the contents of a stylesheet for aggregation. | Parameters:
- $contents: The contents of the stylesheet.
- $optimize: (optional) Boolean whether CSS contents should be minified. Defaults to FALSE.
Returns: Contents of the stylesheet including the imported stylesheets.
File: includes/common.inc | function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
// Remove multiple charset declarations for standards compliance (and fixing Safari problems).
$contents = preg_replace('/^@charset\s+[\'"](\S*?)\b[\'"];/i', '', $contents);
if ($optimize) {
// Perform some safe CSS optimizations.
//... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d7dee10c4e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_validate_size/7.x | In Drupal 7, write the function `file_validate_size(stdClass $file, $file_limit = 0, $user_limit = 0)` (file includes/file.inc) so that it does the following: Checks that the file's size is below certain limits. | Parameters:
- $file: A Drupal file object.
- $file_limit: An integer specifying the maximum file size in bytes. Zero indicates that no limit should be enforced.
- $user_limit: An integer specifying the maximum number of bytes the user is allowed. Zero indicates that no limit should be enforced.
Returns: An array. If t... | function file_validate_size(stdClass $file, $file_limit = 0, $user_limit = 0) {
global $user;
$errors = array();
if ($file_limit && $file->filesize > $file_limit) {
$errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d7f28fa101 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_rdf_mapping/7.x | I need the code for `taxonomy_rdf_mapping()` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Implements hook_rdf_mapping(). | Returns (array): The rdf mapping for vocabularies and terms.
File: modules/taxonomy/taxonomy.module | function taxonomy_rdf_mapping() {
return array(
array(
'type' => 'taxonomy_term',
'bundle' => RDF_DEFAULT_BUNDLE,
'mapping' => array(
'rdftype' => array('skos:Concept'),
'name' => array(
'predicates' => array('rdfs:label', 'skos:prefLabel'),
),
'descri... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d802eb2ccf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_effects/7.x | Implement `image_effects()` in PHP for Drupal 7. Required behavior: Loads all image effects from the database. | Returns: An array of all image effects.
File: modules/image/image.module | function image_effects() {
$effects = &drupal_static(__FUNCTION__);
if (!isset($effects)) {
$effects = array();
// Add database image effects.
$result = db_select('image_effects', NULL, array('fetch' => PDO::FETCH_ASSOC))
->fields('image_effects')
->orderBy('image_effects.weight', 'ASC')
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d80e51bc3b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21help%21help.module/function/help_menu/7.x | In Drupal 7, write the function `help_menu()` (file modules/help/help.module) so that it does the following: Implements hook_menu(). | File: modules/help/help.module | function help_menu() {
$items['admin/help'] = array(
'title' => 'Help',
'description' => 'Reference for usage, configuration, and modules.',
'page callback' => 'help_main',
'access arguments' => array('access administration pages'),
'weight' => 9,
'file' => 'help.admin.inc',
);
foreach (m... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d8110ffa9c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/template_preprocess_user_profile/7.x | I need the code for `template_preprocess_user_profile(&$variables)` in Drupal 7 (modules/user/user.pages.inc). It must do this: Process variables for user-profile.tpl.php. | Parameters:
- $variables (array): An associative array containing: - elements: An associative array containing the user information and any fields attached to the user. Properties used: - #account: The user account of the profile being viewed.
File: modules/user/user.pages.inc | function template_preprocess_user_profile(&$variables) {
$account = $variables['elements']['#account'];
// Helpful $user_profile variable for templates.
foreach (element_children($variables['elements']) as $key) {
$variables['user_profile'][$key] = $variables['elements'][$key];
}
// Preprocess fields.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d8579a55b5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21theme.api.php/function/hook_preprocess/7.x | In Drupal 7, show an example implementation for `hook_preprocess(&$variables, $hook)` (modules/system/theme.api.php): Preprocess theme variables for templates. | This hook allows modules to preprocess theme variables for theme templates. It is called for all theme hooks implemented as templates, but not for theme hooks implemented as functions. hook_preprocess_HOOK() can be used to preprocess variables for a specific theme hook, whether implemented as a template or function.
F... | function hook_preprocess(&$variables, $hook) {
static $hooks;
// Add contextual links to the variables, if the user has permission.
if (!user_access('access contextual links')) {
return;
}
if (!isset($hooks)) {
$hooks = theme_get_registry();
}
// Determine the primary theme function argument.
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-d858523b1e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/install_goto/7.x | In Drupal 7, write the function `install_goto($path)` (file includes/install.inc) so that it does the following: Sends the user to a different installer page. | This issues an on-site HTTP redirect. Messages (and errors) are erased.
Parameters:
- $path: An installer path.
File: includes/install.inc | function install_goto($path) {
global $base_url;
include_once DRUPAL_ROOT . '/includes/common.inc';
header('Location: ' . $base_url . '/' . $path);
header('Cache-Control: no-cache'); // Not a permanent redirect.
drupal_exit();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d866d71d58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_delete/7.x | In Drupal 7, show an example implementation for `hook_delete($node)` (modules/node/node.api.php): Respond to node deletion. | This is a node-type-specific hook, which is invoked only for the node type being affected. See
Parameters:
- $node: The node that is being deleted.
File: modules/node/node.api.php | function hook_delete($node) {
db_delete('mytable')
->condition('nid', $node->nid)
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-d89822adca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.tokens.inc/function/taxonomy_tokens/7.x | Implement `taxonomy_tokens($type, $tokens, array $data = array(), array $options = array())` in PHP for Drupal 7. Required behavior: Implements hook_tokens(). | File: modules/taxonomy/taxonomy.tokens.inc | function taxonomy_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
$sanitize = !empty($options['sanitize']);
if ($type == 'term' && !empty($data['term'])) {
$term = $data['term'];
foreach ($tokens as $name => $original) {
switch ($name) {
c... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d8c323096c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_comment_load/7.x | Implement `rdf_comment_load($comments)` in PHP for Drupal 7. Required behavior: Implements hook_comment_load(). | File: modules/rdf/rdf.module | function rdf_comment_load($comments) {
foreach ($comments as $comment) {
// Pages with many comments can show poor performance. This information
// isn't needed until rdf_preprocess_comment() is called, but set it here
// to optimize performance for websites that implement an entity cache.
$comment->r... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d8e81dbee4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_batch_system_finished/7.x | In Drupal 7, write the function `_locale_batch_system_finished($success, $results)` (file includes/locale.inc) so that it does the following: Implements callback_batch_finished(). | Finished callback of system page locale import batch. Inform the user of translation files imported.
File: includes/locale.inc | function _locale_batch_system_finished($success, $results) {
if ($success) {
drupal_set_message(format_plural(count($results), 'One translation file imported for the newly installed modules.', '@count translation files imported for the newly installed modules.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d8f0723b4b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_date_time_lookup/7.x | I need the code for `system_date_time_lookup()` in Drupal 7 (modules/system/system.admin.inc). It must do this: Return the date for a given format string via Ajax. | File: modules/system/system.admin.inc | function system_date_time_lookup() {
// This callback is protected with a CSRF token because user input from the
// query string is reflected in the output.
if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'admin/config/regional/date-time/formats/lookup')) {
return MENU_ACCESS_DENIED;
}
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d9073fe488 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_field_by_ids/7.x | In Drupal 7, write the function `field_info_field_by_ids()` (file modules/field/field.info.inc) so that it does the following: Returns the same data as field_info_field_by_id() for every field. | Use of this function should be avoided when possible, since it loads and statically caches a potentially large array of information.
When iterating over the fields present in a given bundle after a call to field_info_instances($entity_type, $bundle), it is recommended to use field_info_field() on each individual field... | function field_info_field_by_ids() {
$cache = _field_info_field_cache();
return $cache->getFields();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d93a177cbe | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_edit_form_submit/7.x | Implement `shortcut_set_edit_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit handler for shortcut_set_edit_form(). | File: modules/shortcut/shortcut.admin.inc | function shortcut_set_edit_form_submit($form, &$form_state) {
$shortcut_set = $form_state['values']['shortcut_set'];
$shortcut_set->title = $form_state['values']['title'];
shortcut_set_save($shortcut_set);
drupal_set_message(t('Updated set name to %set-name.', array('%set-name' => $shortcut_set->title)));
$fo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d955961330 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_style_form_override_submit/7.x | I need the code for `image_style_form_override_submit($form, &$form_state)` in Drupal 7 (modules/image/image.admin.inc). It must do this: Submit handler for overriding a module-defined style. | File: modules/image/image.admin.inc | function image_style_form_override_submit($form, &$form_state) {
drupal_set_message(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $form_state['image_style']['label'])));
image_default_style_save($form_state['image_style']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d9809811fa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_textfield/7.x | Implement `theme_textfield($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a textfield form element. | Parameters:
- $variables: An associative array containing: - element: An associative array containing the properties of the element. Properties used: #title, #value, #description, #size, #maxlength, #required, #attributes, #autocomplete_path.
File: includes/form.inc | function theme_textfield($variables) {
$element = $variables['element'];
$element['#attributes']['type'] = 'text';
element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength'));
_form_set_class($element, array('form-text'));
$extra = '';
if ($element['#autocomplete_path'] && !empty($e... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d98e7b48ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_theme/7.x | I need the code for `forum_theme()` in Drupal 7 (modules/forum/forum.module). It must do this: Implements hook_theme(). | File: modules/forum/forum.module | function forum_theme() {
return array(
'forums' => array(
'template' => 'forums',
'variables' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
),
'forum_list' => array(
'template' => 'forum-list',
'variables... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d9b050d397 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.install/function/block_update_7005/7.x | I need the code for `block_update_7005()` in Drupal 7 (modules/block/block.install). It must do this: Update the {block_custom}.format column. | File: modules/block/block.install | function block_update_7005() {
// For an explanation of these updates, see the code comments in
// user_update_7010().
db_change_field('block_custom', 'format', 'format', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the block body... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-d9d311248f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.module/function/dblog_menu/7.x | In Drupal 7, write the function `dblog_menu()` (file modules/dblog/dblog.module) so that it does the following: Implements hook_menu(). | File: modules/dblog/dblog.module | function dblog_menu() {
$items['admin/reports/dblog'] = array(
'title' => 'Recent log messages',
'description' => 'View events that have recently been logged.',
'page callback' => 'dblog_overview',
'access arguments' => array('access site reports'),
'weight' => -1,
'file' => 'dblog.admin.inc',... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-d9f40991c0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/_field_info_prepare_instance_widget/7.x | Implement `_field_info_prepare_instance_widget($field, $widget)` in PHP for Drupal 7. Required behavior: Prepares widget specifications for the current run-time context. | The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646.
File: modules/field/field.info.inc | function _field_info_prepare_instance_widget($field, $widget) {
$cache = _field_info_field_cache();
return $cache->prepareInstanceWidget($widget, $field['type']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-da00519d27 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_url_trim/7.x | Implement `_filter_url_trim($text, $length = NULL)` in PHP for Drupal 7. Required behavior: Shortens long URLs to http://www.example.com/long/url... | File: modules/filter/filter.module | function _filter_url_trim($text, $length = NULL) {
static $_length;
if ($length !== NULL) {
$_length = $length;
}
// Use +3 for '...' string length.
if ($_length && strlen((string) $text) > $_length + 3) {
$text = substr($text, 0, $_length) . '...';
}
return $text;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-da7eef0f74 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_upload_max_size/7.x | Implement `file_upload_max_size()` in PHP for Drupal 7. Required behavior: Determines the maximum file upload size by querying the PHP settings. | Returns: A file size limit in bytes based on the PHP upload_max_filesize and post_max_size
File: includes/file.inc | function file_upload_max_size() {
static $max_size = -1;
if ($max_size < 0) {
// Start with post_max_size.
$max_size = parse_size(ini_get('post_max_size'));
// If upload_max_size is less, then reduce. Except if upload_max_size is
// zero, which indicates no limit.
$upload_max = parse_size(ini_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-da86f4545a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/options_help/7.x | In Drupal 7, write the function `options_help($path, $arg)` (file modules/field/modules/options/options.module) so that it does the following: Implements hook_help(). | File: modules/field/modules/options/options.module | function options_help($path, $arg) {
switch ($path) {
case 'admin/help#options':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Options module defines checkbox, selection, and other input widgets for the Field module. See the <a href="@field-help">Field module ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-da9e97c5ac | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_dirty/7.x | In Drupal 7, write the function `search_dirty($word = NULL)` (file modules/search/search.module) so that it does the following: Marks a word as "dirty" (changed), or retrieves the list of dirty words. | This is used during indexing (cron). Words that are dirty have outdated total counts in the search_total table, and need to be recounted.
File: modules/search/search.module | function search_dirty($word = NULL) {
$dirty = &drupal_static(__FUNCTION__, array());
if ($word !== NULL) {
$dirty[$word] = TRUE;
}
else {
return $dirty;
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-daa0a73970 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21announcements_feed%21announcements_feed.module/function/announcements_feed_help/7.x | In Drupal 7, write the function `announcements_feed_help($path)` (file modules/announcements_feed/announcements_feed.module) so that it does the following: Implements hook_help(). | File: modules/announcements_feed/announcements_feed.module | function announcements_feed_help($path) {
if ($path == 'admin/help#announcements_feed') {
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Announcements module displays announcements from the Drupal community. For more information, see the <a href="@documentation">online d... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-dab03d5d8e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_bootstrap_variables/7.x | In Drupal 7, write the function `_drupal_bootstrap_variables()` (file includes/bootstrap.inc) so that it does the following: Loads system variables and all enabled bootstrap modules. | File: includes/bootstrap.inc | function _drupal_bootstrap_variables() {
global $conf;
// Initialize the lock system.
require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
lock_initialize();
// Load variables from the database, but do not overwrite variables set in settings.php.
$conf = variable_initialize(isse... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dad76c2f02 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.admin.inc/function/filter_admin_disable_submit/7.x | Implement `filter_admin_disable_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for filter_admin_disable(). | File: modules/filter/filter.admin.inc | function filter_admin_disable_submit($form, &$form_state) {
$format = $form['#format'];
filter_format_disable($format);
drupal_set_message(t('Disabled text format %format.', array('%format' => $format->name)));
$form_state['redirect'] = 'admin/config/content/formats';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dadace462f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_role_validate/7.x | Implement `user_admin_role_validate($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form validation handler for the user_admin_role() form. | File: modules/user/user.admin.inc | function user_admin_role_validate($form, &$form_state) {
if (!empty($form_state['values']['name'])) {
if ($form_state['values']['op'] == t('Save role')) {
$role = user_role_load_by_name($form_state['values']['name']);
if ($role && $role->rid != $form_state['values']['rid']) {
form_set_error('n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-daee37251e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/color_form_system_theme_settings_alter/7.x | Implement `color_form_system_theme_settings_alter(&$form, &$form_state)` in PHP for Drupal 7. Required behavior: Implements hook_form_FORM_ID_alter(). | File: modules/color/color.module | function color_form_system_theme_settings_alter(&$form, &$form_state) {
if (isset($form_state['build_info']['args'][0]) && ($theme = $form_state['build_info']['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
$form['color'] = array(
'#type' => 'fieldset',
'#title' => t('Color sche... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-daf3af9257 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_current_script_url/7.x | In Drupal 7, write the function `drupal_current_script_url($query = array())` (file includes/install.inc) so that it does the following: Returns the URL of the current script, with modified query parameters. | This function can be called by low-level scripts (such as install.php and update.php) and returns the URL of the current script. Existing query parameters are preserved by default, but new ones can optionally be merged in.
This function is used when the script must maintain certain query parameters over multiple page ... | function drupal_current_script_url($query = array()) {
$uri = $_SERVER['SCRIPT_NAME'];
$query = array_merge(drupal_get_query_parameters(), $query);
if (!empty($query)) {
$uri .= '?' . drupal_http_build_query($query);
}
return $uri;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dafc31718a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_field_formatter_view/7.x | In Drupal 7, write the function `list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)` (file modules/field/modules/list/list.module) so that it does the following: Implements hook_field_formatter_view(). | File: modules/field/modules/list/list.module | function list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'list_default':
$allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
foreach ($items as $delta => $item) {
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-dafef8bf25 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_element_info/7.x | Implement `filter_element_info()` in PHP for Drupal 7. Required behavior: Implements hook_element_info(). | File: modules/filter/filter.module | function filter_element_info() {
$type['text_format'] = array(
'#process' => array('filter_process_format'),
'#base_type' => 'textarea',
'#theme_wrappers' => array('text_format_wrapper'),
);
return $type;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-db4009ec2f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_deliver/7.x | I need the code for `image_style_deliver($style, $scheme = NULL)` in Drupal 7 (modules/image/image.module). It must do this: Page callback: Generates a derivative, given a style and image path. | After generating an image, transfer it to the requesting agent.
Parameters:
- $style: The image style
- $scheme: The file scheme, for example 'public' for public files.
File: modules/image/image.module | function image_style_deliver($style, $scheme = NULL) {
$args = func_get_args();
array_shift($args);
array_shift($args);
$target = implode('/', $args);
$image_uri = $scheme . '://' . $target;
$image_uri = file_uri_normalize_dot_segments($image_uri);
if (file_stream_wrapper_valid_scheme($scheme)) {
$no... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-db4024b78f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_fields_list/7.x | I need the code for `field_ui_fields_list()` in Drupal 7 (modules/field_ui/field_ui.admin.inc). It must do this: Menu callback; lists all defined fields for quick reference. | File: modules/field_ui/field_ui.admin.inc | function field_ui_fields_list() {
$instances = field_info_instances();
$field_types = field_info_field_types();
$bundles = field_info_bundles();
$modules = system_rebuild_module_data();
$header = array(t('Field name'), t('Field type'), t('Used in'));
$rows = array();
foreach ($instances as $entity_type ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-db56e5b135 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.api.php/function/hook_comment_update/7.x | Give me the example code for `hook_comment_update($comment)` in Drupal 7. Hook description: The comment is being updated. | Parameters:
- $comment: The comment object.
File: modules/comment/comment.api.php | function hook_comment_update($comment) {
// Reindex the node when comments are updated.
search_touch_node($comment->nid);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-db76495daf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_profile/7.x | Implement `drupal_get_profile()` in PHP for Drupal 7. Required behavior: Gets the name of the currently active installation profile. | When this function is called during Drupal's initial installation process, the name of the profile that's about to be installed is stored in the global installation state. At all other times, the standard Drupal systems variable table contains the name of the current profile, and we can call variable_get() to determine... | function drupal_get_profile() {
global $install_state;
if (isset($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
}
else {
$profile = variable_get('install_profile', 'standard');
}
return $profile;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-db9abbdd2c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7013/7.x | I need the code for `user_update_7013(&$sandbox)` in Drupal 7 (modules/user/user.install). It must do this: Add user module file usage entries. | File: modules/user/user.install | function user_update_7013(&$sandbox) {
if (!isset($sandbox['progress'])) {
// Initialize batch update information.
$sandbox['progress'] = 0;
$sandbox['last_uid_processed'] = -1;
$sandbox['max'] = db_query("SELECT COUNT(*) FROM {users} u WHERE u.picture <> 0")->fetchField();
}
// Add usage entries... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dba83bb4d8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/_rdf_mapping_load_multiple/7.x | I need the code for `_rdf_mapping_load_multiple($type, array $bundles)` in Drupal 7 (modules/rdf/rdf.module). It must do this: Helper function to retrieve a set of RDF mappings from the database. | Parameters:
- $type: The entity type of the mappings.
- $bundles: The bundles the mappings refer to.
Returns: An array of RDF mapping structures, or an empty array.
File: modules/rdf/rdf.module | function _rdf_mapping_load_multiple($type, array $bundles) {
$mappings = db_select('rdf_mapping')
->fields(NULL, array('bundle', 'mapping'))
->condition('type', $type)
->condition('bundle', $bundles)
->execute()
->fetchAllKeyed();
foreach ($mappings as $bundle => $mapping) {
$mappings[$bund... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dbae49c9cb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/fix_gpc_magic/7.x | In Drupal 7, write the function `fix_gpc_magic()` (file includes/common.inc) so that it does the following: Fixes double-escaping caused by "magic quotes" in some PHP installations. | File: includes/common.inc | function fix_gpc_magic() {
static $fixed = FALSE;
if (!$fixed && ini_get('magic_quotes_gpc')) {
array_walk($_GET, '_fix_gpc_magic');
array_walk($_POST, '_fix_gpc_magic');
array_walk($_COOKIE, '_fix_gpc_magic');
array_walk($_REQUEST, '_fix_gpc_magic');
array_walk($_FILES, '_fix_gpc_magic_files');... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dbca24b7a1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_pass_rehash/7.x | Implement `user_pass_rehash($password, $timestamp, $login, $uid, $mail = '')` in PHP for Drupal 7. Required behavior: Creates a unique hash value for use in time-dependent per-user URLs. | This hash is normally used to build a unique and secure URL that is sent to the user by email for purposes such as resetting the user's password. In order to validate the URL, the same hash can be generated again, from the same information, and compared to the hash value from the URL. The URL normally contains both the... | function user_pass_rehash($password, $timestamp, $login, $uid, $mail = '') {
// Backwards compatibility: Try to determine a $uid if one was not passed.
// (Since $uid is a required parameter to this function, a PHP warning will
// be generated if it's not provided, which is an indication that the calling
// cod... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dbd18e31e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_type_delete_confirm/7.x | In Drupal 7, write the function `node_type_delete_confirm($form, &$form_state, $type)` (file modules/node/content_types.inc) so that it does the following: Menu callback; delete a single content type. | File: modules/node/content_types.inc | function node_type_delete_confirm($form, &$form_state, $type) {
$form['type'] = array('#type' => 'value', '#value' => $type->type);
$form['name'] = array('#type' => 'value', '#value' => $type->name);
$message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name));
$num_n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dbe15fd2c1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_managed_file_save_upload/7.x | In Drupal 7, write the function `file_managed_file_save_upload($element)` (file modules/file/file.module) so that it does the following: Saves any files that have been uploaded into a managed_file element. | Parameters:
- $element: The FAPI element whose values are being saved.
Returns: The file object representing the file that was saved, or FALSE if no file was saved.
File: modules/file/file.module | function file_managed_file_save_upload($element) {
$upload_name = implode('_', $element['#parents']);
if (empty($_FILES['files']['name'][$upload_name])) {
return FALSE;
}
$destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL;
if (isset($destination) && !file_prepare_dir... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dbf2190e7e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.install/function/trigger_schema/7.x | In Drupal 7, write the function `trigger_schema()` (file modules/trigger/trigger.install) so that it does the following: Implements hook_schema(). | File: modules/trigger/trigger.install | function trigger_schema() {
// The total index length (hook and aid) must be less than 333. Since the aid
// field is 255 characters, the hook field can have a maximum length of 78.
$schema['trigger_assignments'] = array(
'description' => 'Maps trigger to hook and operation assignments from trigger.module.',
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-dc1442f14f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.module/function/field_ui_form_node_type_form_submit/7.x | In Drupal 7, write the function `field_ui_form_node_type_form_submit($form, &$form_state)` (file modules/field_ui/field_ui.module) so that it does the following: Form submission handler for the 'Save and add fields' button. | File: modules/field_ui/field_ui.module | function field_ui_form_node_type_form_submit($form, &$form_state) {
if ($form_state['triggering_element']['#parents'][0] === 'save_continue') {
$form_state['redirect'] = _field_ui_bundle_admin_path('node', $form_state['values']['type']) .'/fields';
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dc2036a503 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_view_value/7.x | Implement `field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)` in PHP for Drupal 7. Required behavior: Returns a renderable array for a single field value. | Parameters:
- $entity_type: The type of $entity; e.g., 'node' or 'user'.
- $entity: The entity containing the field to display. Must at least contain the id key and the field data to display.
- $field_name: The name of the field to display.
- $item: The field value to display, as found in $entity->field_name[$langcode]... | function field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL) {
$output = array();
if ($field = field_info_field($field_name)) {
// Determine the langcode that will be used by language fallback.
$langcode = field_language($entity_type, $entity, $field_name, $lan... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dc371eb372 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_modules_submit/7.x | I need the code for `system_modules_submit($form, &$form_state)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Submit callback; handles modules form submission. | File: modules/system/system.admin.inc | function system_modules_submit($form, &$form_state) {
include_once DRUPAL_ROOT . '/includes/install.inc';
// Builds list of modules.
$modules = array();
// If we're not coming from the confirmation form, build the list of modules.
if (empty($form_state['storage'])) {
// If we're not coming from the confi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dc3fb3085f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_math_powmod/7.x | In Drupal 7, write the function `_openid_math_powmod($x, $y, $z)` (file modules/openid/openid.inc) so that it does the following: Calls the mul function from the available math library for OpenID. | File: modules/openid/openid.inc | function _openid_math_powmod($x, $y, $z) {
$library = _openid_get_math_library();
switch ($library) {
case 'gmp':
return gmp_powm($x, $y, $z);
case 'bcmath':
return bcpowmod($x, $y, $z);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dc5e8614f0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_permission/7.x | I need the code for `comment_permission()` in Drupal 7 (modules/comment/comment.module). It must do this: Implements hook_permission(). | File: modules/comment/comment.module | function comment_permission() {
return array(
'administer comments' => array(
'title' => t('Administer comments and comment settings'),
),
'access comments' => array(
'title' => t('View comments'),
),
'post comments' => array(
'title' => t('Post comments'),
),
'skip comme... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-dc74c35b95 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_cron/7.x | Implement `system_cron()` in PHP for Drupal 7. Required behavior: Implements hook_cron(). | Remove older rows from flood and batch table. Remove old temporary files.
File: modules/system/system.module | function system_cron() {
// Cleanup the flood.
db_delete('flood')
->condition('expiration', REQUEST_TIME, '<')
->execute();
// Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
// Use separate placeholders for the status to avoid a bug in some versions
// of PHP. See http://dru... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-dc76a68da9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/aggregator_page_source/7.x | In Drupal 7, write the function `aggregator_page_source($feed)` (file modules/aggregator/aggregator.pages.inc) so that it does the following: Page callback: Displays all the items captured from the particular feed. | Parameters:
- $feed: The feed for which to display all items.
Returns: The rendered list of items for a feed.
File: modules/aggregator/aggregator.pages.inc | function aggregator_page_source($feed) {
drupal_set_title($feed->title);
$feed_source = theme('aggregator_feed_source', array('feed' => $feed));
// It is safe to include the fid in the query because it's loaded from the
// database by aggregator_feed_load.
$items = aggregator_feed_items_load('source', $feed)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dc79f34f15 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_term_save/7.x | In Drupal 7, write the function `taxonomy_term_save($term)` (file modules/taxonomy/taxonomy.module) so that it does the following: Saves a term object to the database. | Parameters:
- $term: The taxonomy term object with the following properties: - vid: The ID of the vocabulary the term is assigned to. - name: The name of the term. - tid: (optional) The unique ID for the term being saved. If $term->tid is empty or omitted, a new term will be inserted. - description: (optional) The term... | function taxonomy_term_save($term) {
// Prevent leading and trailing spaces in term names.
$term->name = trim($term->name);
if (!isset($term->vocabulary_machine_name)) {
$vocabulary = taxonomy_vocabulary_load($term->vid);
$term->vocabulary_machine_name = $vocabulary->machine_name;
}
// Load the store... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dcc70d0af7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7065/7.x | I need the code for `system_update_7065()` in Drupal 7 (modules/system/system.install). It must do this: Remove the default value for sid. | File: modules/system/system.install | function system_update_7065() {
$spec = array(
'description' => "A session ID. The value is generated by Drupal's session handlers.",
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
);
db_drop_primary_key('sessions');
db_change_field('sessions', 'sid', 'sid', $spec, array('primary key'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dcc7d26258 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_query/7.x | In Drupal 7, write the function `db_query($query, array $args = array(), array $options = array())` (file includes/database/database.inc) so that it does the following: Executes an arbitrary query string against the active database. | Use this function for SELECT queries if it is just a simple query string. If the caller or other modules need to change the query, use db_select() instead.
Do not use this function for INSERT, UPDATE, or DELETE queries. Those should be handled via db_insert(), db_update() and db_delete() respectively.
Parameters:
- $... | function db_query($query, array $args = array(), array $options = array()) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->query($query, $args, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dce2a767fc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_toggle_page/7.x | In Drupal 7, write the function `toolbar_toggle_page()` (file modules/toolbar/toolbar.module) so that it does the following: Menu callback; toggles the visibility of the toolbar drawer. | File: modules/toolbar/toolbar.module | function toolbar_toggle_page() {
global $base_path;
// Toggle the value in the cookie.
drupal_setcookie('Drupal.toolbar.collapsed', !_toolbar_is_collapsed(),
array(
'samesite' => 'Lax',
'path' => $base_path,
)
);
// Redirect the user from where he used the toggle element.
drupal_goto();
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dce3e51f3a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.pages.inc/function/filter_tips_long/7.x | I need the code for `filter_tips_long($format = NULL)` in Drupal 7 (modules/filter/filter.pages.inc). It must do this: Page callback: Displays a page with long filter tips. | Returns (string): An HTML-formatted string.
File: modules/filter/filter.pages.inc | function filter_tips_long($format = NULL) {
if (!empty($format)) {
$output = theme('filter_tips', array('tips' => _filter_tips($format->format, TRUE), 'long' => TRUE));
}
else {
$output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
}
return $output;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-dcf644f0a2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_date_time_formats/7.x | Implement `system_date_time_formats()` in PHP for Drupal 7. Required behavior: Displays the date format strings overview page. | File: modules/system/system.admin.inc | function system_date_time_formats() {
$header = array(t('Format'), array('data' => t('Operations'), 'colspan' => '2'));
$rows = array();
drupal_static_reset('system_get_date_formats');
$formats = system_get_date_formats('custom');
if (!empty($formats)) {
foreach ($formats as $format) {
$row = array... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.