From 7ef898e2987a0272fc50f14b365122fc03f24ef1 Mon Sep 17 00:00:00 2001 From: Greg Netsas Date: Fri, 16 Feb 2024 09:19:08 +1100 Subject: [PATCH 01/10] Issue 6302: CSpell: Change mymodule to my_module in all of core. By @klonos and @quicksketch. --- core/includes/form.inc | 20 +-- core/includes/language.inc | 10 +- core/includes/lock.inc | 6 +- core/includes/module.inc | 4 +- core/includes/pager.inc | 12 +- core/modules/.DS_Store | Bin 0 -> 6148 bytes core/modules/admin_bar/admin_bar.api.php | 4 +- core/modules/ckeditor/ckeditor.api.php | 10 +- core/modules/ckeditor5/ckeditor5.api.php | 10 +- core/modules/config/config.api.php | 24 +-- core/modules/entity/entity.api.php | 6 +- core/modules/field/field.api.php | 22 +-- core/modules/filter/filter.api.php | 8 +- core/modules/image/image.api.php | 26 +-- core/modules/layout/layout.api.php | 20 +-- core/modules/node/node.api.php | 12 +- core/modules/search/search.module | 4 +- core/modules/system/system.api.php | 199 ++++++++++++----------- core/modules/system/system.module | 27 +-- core/modules/system/theme.api.php | 2 +- core/modules/taxonomy/taxonomy.api.php | 2 +- core/modules/telemetry/telemetry.api.php | 18 +- core/modules/user/user.api.php | 10 +- core/modules/views/views.api.php | 2 +- 24 files changed, 233 insertions(+), 225 deletions(-) create mode 100644 core/modules/.DS_Store diff --git a/core/includes/form.inc b/core/includes/form.inc index e99e6b3a814..b16053e3a34 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -709,25 +709,25 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) { * build info array so that the reference can be preserved. For example, a * form builder function with the following signature: * @code - * function mymodule_form($form, &$form_state, &$object) { + * function my_module_form($form, &$form_state, &$object) { * } * @endcode * would be called via backdrop_form_submit() as follows: * @code * $form_state['values'] = $my_form_values; * $form_state['build_info']['args'] = array(&$object); - * backdrop_form_submit('mymodule_form', $form_state); + * backdrop_form_submit('my_module_form', $form_state); * @endcode * For example: * @code - * // register a new user - * $form_state = array(); - * $form_state['values']['name'] = 'new-user'; - * $form_state['values']['mail'] = 'new.user@example.com'; - * $form_state['values']['pass']['pass1'] = 'password'; - * $form_state['values']['pass']['pass2'] = 'password'; - * $form_state['values']['op'] = t('Create new account'); - * backdrop_form_submit('user_register_form', $form_state); + * // Register a new user. + * $form_state = array(); + * $form_state['values']['name'] = 'new-user'; + * $form_state['values']['mail'] = 'new.user@example.com'; + * $form_state['values']['pass']['pass1'] = 'password'; + * $form_state['values']['pass']['pass2'] = 'password'; + * $form_state['values']['op'] = t('Create new account'); + * backdrop_form_submit('user_register_form', $form_state); * @endcode */ function backdrop_form_submit($form_id, &$form_state) { diff --git a/core/includes/language.inc b/core/includes/language.inc index 8eb67d9bab4..72a091e36fa 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -44,7 +44,7 @@ define('LANGUAGE_NEGOTIATION_DEFAULT', 'language-default'); * language (which by default inherits the interface language's values) * configurable: * @code - * function mymodule_language_types_info_alter(&$language_types) { + * function my_module_language_types_info_alter(&$language_types) { * unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']); * } * @endcode @@ -74,13 +74,13 @@ define('LANGUAGE_NEGOTIATION_DEFAULT', 'language-default'); * hook_language_negotiation_info_alter(). Here is an example snippet that lets * path prefixes be ignored for administrative paths: * @code - * function mymodule_language_negotiation_info_alter(&$negotiation_info) { + * function my_module_language_negotiation_info_alter(&$negotiation_info) { * // Replace the core function with our own function. - * $negotiation_info[LANGUAGE_NEGOTIATION_URL]['callbacks']['language'] = 'mymodule_from_url'; - * $negotiation_info[LANGUAGE_NEGOTIATION_URL]['file'] = backdrop_get_path('module', 'mymodule') . '/mymodule.module'; + * $negotiation_info[LANGUAGE_NEGOTIATION_URL]['callbacks']['language'] = 'my_module_from_url'; + * $negotiation_info[LANGUAGE_NEGOTIATION_URL]['file'] = backdrop_get_path('module', 'my_module') . '/my_module.module'; * } * - * function mymodule_from_url($languages) { + * function my_module_from_url($languages) { * // Use the core URL language negotiation provider to get a valid language * // code. * $langcode = locale_language_from_url($languages); diff --git a/core/includes/lock.inc b/core/includes/lock.inc index 60010aee503..cae792bfdf6 100644 --- a/core/includes/lock.inc +++ b/core/includes/lock.inc @@ -26,11 +26,11 @@ * name of the function performing the operation. A very simple example use of * this API: * @code - * function mymodule_long_operation() { - * if (lock_acquire('mymodule_long_operation')) { + * function my_module_long_operation() { + * if (lock_acquire('my_module_long_operation')) { * // Do the long operation here. * // ... - * lock_release('mymodule_long_operation'); + * lock_release('my_module_long_operation'); * } * } * @endcode diff --git a/core/includes/module.inc b/core/includes/module.inc index 5b2e29ef1c2..c9773b8563b 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -1049,7 +1049,7 @@ function backdrop_required_modules() { * 'unalterable' => $unalterable, * 'foo' => 'bar', * ); - * backdrop_alter('mymodule_data', $alterable1, $alterable2, $context); + * backdrop_alter('my_module_data', $alterable1, $alterable2, $context); * @endcode * * Note that objects are always passed by reference in PHP5. If it is absolutely @@ -1059,7 +1059,7 @@ function backdrop_required_modules() { * $context = array( * 'unalterable_object' => clone $object, * ); - * backdrop_alter('mymodule_data', $data, $context); + * backdrop_alter('my_module_data', $data, $context); * @endcode * * @param $type diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 4fdd0a46eaa..b0aa30ea3db 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -55,14 +55,14 @@ function pager_find_page($element = 0) { * @code * // First find the total number of items and initialize the pager. * $where = "status = 1"; - * $total = mymodule_select("SELECT COUNT(*) FROM data " . $where)->result(); - * $num_per_page = config_get('mymodule.settings', 'num_per_page'); + * $total = my_module_select("SELECT COUNT(*) FROM data " . $where)->result(); + * $num_per_page = config_get('my_module.settings', 'num_per_page'); * $page = pager_default_initialize($total, $num_per_page); * * // Next, retrieve and display the items for the current page. * $offset = $num_per_page * $page; - * $result = mymodule_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll(); - * $output = theme('mymodule_results', array('result' => $result)); + * $result = my_module_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll(); + * $output = theme('my_module_results', array('result' => $result)); * * // Finally, display the pager controls, and return. * $output .= theme('pager'); @@ -80,9 +80,9 @@ function pager_find_page($element = 0) { * // parameter corresponds to an actual page of results that will exist * // within the set. * $page = pager_find_page(); - * $num_per_page = config_get('mymodule.settings', 'num_per_page'); + * $num_per_page = config_get('my_module.settings', 'num_per_page'); * $offset = $num_per_page * $page; - * $result = mymodule_remote_search($keywords, $offset, $num_per_page); + * $result = my_module_remote_search($keywords, $offset, $num_per_page); * * // Now that we have the total number of results, initialize the pager. * pager_default_initialize($result->total, $num_per_page); diff --git a/core/modules/.DS_Store b/core/modules/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..39bca42f2d55679709f8da527f2e9bb77e66b337 GIT binary patch literal 6148 zcmeHKJ8r`;3?);e2++l2MqME{5RBvmzCeqnNQS@#Tr{(%oU2Fc<7aW*Zs`&{0@RZz zJ_&k*X^Mz;pNFkTD9)u6G%7#^?mz+iJ`}iNO`HP#(}BTT0APc#8|L0i z0E-2HHE{|=1g1d+2351g(4Zq;GOs31fk79|=0o#l%??HVcAQ^4U9<*rqyki6uE0Yq zTdV(j_#gfMoWvCspaOTLfHu2+*WpQ7TNjVBT3g`HaLf6En_=!03|@|bUXHP_a=h`R b$SXF-eodSLosPKEf&3XTU1(I`zZLiffUy;b literal 0 HcmV?d00001 diff --git a/core/modules/admin_bar/admin_bar.api.php b/core/modules/admin_bar/admin_bar.api.php index 4e5d2e254be..f8256d5f151 100644 --- a/core/modules/admin_bar/admin_bar.api.php +++ b/core/modules/admin_bar/admin_bar.api.php @@ -75,8 +75,8 @@ function hook_admin_bar_output_build(&$content) { $content['menu']['menu']['myitem'] = array( '#title' => t('My item'), // #attributes are used for list items (LI). - '#attributes' => array('class' => array('mymodule-myitem')), - '#href' => 'mymodule/path', + '#attributes' => array('class' => array('my_module-myitem')), + '#href' => 'my_module/path', // #options are passed to l(). '#options' => array( 'query' => backdrop_get_destination(), diff --git a/core/modules/ckeditor/ckeditor.api.php b/core/modules/ckeditor/ckeditor.api.php index 73e94203673..07da7c6f149 100644 --- a/core/modules/ckeditor/ckeditor.api.php +++ b/core/modules/ckeditor/ckeditor.api.php @@ -80,10 +80,10 @@ */ function hook_ckeditor_plugins() { $plugins['myplugin'] = array( - 'path' => backdrop_get_path('module', 'mymodule') . '/js/myplugin', + 'path' => backdrop_get_path('module', 'my_module') . '/js/myplugin', 'file' => 'plugin.js', - 'css' => array(backdrop_get_path('module', 'mymodule') . '/css/myplugin.css'), - 'enabled callback' => 'mymodule_myplugin_plugin_check', + 'css' => array(backdrop_get_path('module', 'my_module') . '/css/myplugin.css'), + 'enabled callback' => 'my_module_myplugin_plugin_check', 'buttons' => array( 'MyPlugin' => array( 'label' => t('My custom button'), @@ -113,7 +113,7 @@ function hook_ckeditor_plugins() { * @see hook_ckeditor_plugins() */ function hook_ckeditor_plugins_alter(array &$plugins) { - $plugins['someplugin']['enabled callback'] = 'mymodule_someplugin_enabled_callback'; + $plugins['someplugin']['enabled callback'] = 'my_module_someplugin_enabled_callback'; } /** @@ -143,7 +143,7 @@ function hook_ckeditor_plugins_alter(array &$plugins) { * @see _ckeditor_theme_css() */ function hook_ckeditor_css_alter(array &$css, $format) { - $css[] = backdrop_get_path('module', 'mymodule') . '/css/mymodule-ckeditor.css'; + $css[] = backdrop_get_path('module', 'my_module') . '/css/my_module-ckeditor.css'; } /** diff --git a/core/modules/ckeditor5/ckeditor5.api.php b/core/modules/ckeditor5/ckeditor5.api.php index 3789bd86300..b62cd7e438c 100644 --- a/core/modules/ckeditor5/ckeditor5.api.php +++ b/core/modules/ckeditor5/ckeditor5.api.php @@ -72,9 +72,9 @@ */ function hook_ckeditor5_plugins() { $plugins['myPlugin.MyPlugin'] = array( - 'library' => array('mymodule', 'mymodule.ckeditor5.myplugin'), - 'css' => array(backdrop_get_path('module', 'mymodule') . '/css/myplugin.css'), - 'enabled_callback' => 'mymodule_myplugin_plugin_check', + 'library' => array('my_module', 'my_module.ckeditor5.myplugin'), + 'css' => array(backdrop_get_path('module', 'my_module') . '/css/myplugin.css'), + 'enabled_callback' => 'my_module_myplugin_plugin_check', 'buttons' => array( 'myButton' => array( 'library' => array('my_module', 'my-module-ckeditor5-plugin'), @@ -101,7 +101,7 @@ function hook_ckeditor5_plugins() { * @see hook_ckeditor5_plugins() */ function hook_ckeditor5_plugins_alter(array &$plugins) { - $plugins['someplugin']['enabled callback'] = 'mymodule_someplugin_enabled_callback'; + $plugins['someplugin']['enabled callback'] = 'my_module_someplugin_enabled_callback'; } /** @@ -139,7 +139,7 @@ function hook_ckeditor5_plugins_alter(array &$plugins) { * @see _ckeditor5_theme_css() */ function hook_ckeditor5_css_alter(array &$css) { - $css[] = backdrop_get_path('module', 'mymodule') . '/css/mymodule-ckeditor5.css'; + $css[] = backdrop_get_path('module', 'my_module') . '/css/my_module-ckeditor5.css'; } /** diff --git a/core/modules/config/config.api.php b/core/modules/config/config.api.php index 63b6657ad39..f7f87bf12f0 100644 --- a/core/modules/config/config.api.php +++ b/core/modules/config/config.api.php @@ -62,7 +62,7 @@ function hook_config_info() { * @throws ConfigValidateException */ function hook_config_data_validate(Config $config, array $config_info) { - if ($config->getName() === 'mymodule.settings') { + if ($config->getName() === 'my_module.settings') { if (!module_exists($config->get('module'))) { throw new ConfigValidateException(t('The configuration "@file" could not be imported because the module "@module" is not enabled.', array('@file' => $config->getName(), '@module' => $config->get('module')))); } @@ -87,7 +87,7 @@ function hook_config_data_validate(Config $config, array $config_info) { * @throws ConfigValidateException */ function hook_config_create_validate(Config $staging_config, $all_changes) { - if ($staging_config->getName() === 'mymodule.settings') { + if ($staging_config->getName() === 'my_module.settings') { // Ensure that the name key is no longer than 64 characters. if (strlen($staging_config->get('name')) > 64) { throw new ConfigValidateException(t('The configuration "@file" must have a "name" attribute less than 64 characters.', array('@file' => $staging_config->getName()))); @@ -115,7 +115,7 @@ function hook_config_create_validate(Config $staging_config, $all_changes) { * @throws ConfigValidateException */ function hook_config_update_validate(Config $staging_config, Config $active_config, $all_changes) { - if ($staging_config->getName() === 'mymodule.settings') { + if ($staging_config->getName() === 'my_module.settings') { // Ensure that the name key is no longer than 64 characters. if (strlen($staging_config->get('name')) > 64) { throw new ConfigValidateException(t('The configuration "@file" must have a "name" attribute less than 64 characters.', array('@file' => $staging_config->getName()))); @@ -143,11 +143,15 @@ function hook_config_update_validate(Config $staging_config, Config $active_conf function hook_config_delete_validate(Config $active_config, $all_changes) { if (strpos($active_config->getName(), 'image.style') === 0) { // Check if another configuration depends on this configuration. - if (!isset($all_changes['mymodule.settings']) || $all_changes['mymodule.settings'] !== 'delete') { - $my_config = config('mymodule.settings'); + if (!isset($all_changes['my_module.settings']) || $all_changes['my_module.settings'] !== 'delete') { + $my_config = config('my_module.settings'); $image_style_name = $active_config->get('name'); if ($my_config->get('image_style') === $image_style_name) { - throw new ConfigValidateException(t('The configuration "@file" cannot be deleted because the image style "@style" is in use by "@mymodule".', array('@file' => $active_config->getName(), '@style' => $image_style_name, '@mymodule' => $my_config->getName()))); + throw new ConfigValidateException(t('The configuration "@file" cannot be deleted because the image style "@style" is in use by "@my_module".', array( + '@file' => $active_config->getName(), + '@style' => $image_style_name, + '@my_module' => $my_config->getName(), + ))); } } } @@ -172,9 +176,9 @@ function hook_config_create(Config $staging_config) { * Respond to configuration updates. * * @param Config $staging_config - * The configuration object for the settings about to be saved. This object - * is always passed by reference and may be modified to adjust the settings - * that are saved. + * The configuration object for the settings about to be saved. This object is + * always passed by reference and may be modified to adjust the settings that + * are saved. * @param Config $active_config * The configuration object for the settings being replaced. */ @@ -199,7 +203,7 @@ function hook_config_update(Config $staging_config, Config $active_config) { function hook_config_delete(Config $active_config) { if (strpos($active_config->getName(), 'image.style') === 0) { $image_style_name = $active_config->get('name'); - config('mymodule.image_style_addons.' . $image_style_name)->delete(); + config('my_module.image_style_addons.' . $image_style_name)->delete(); } } diff --git a/core/modules/entity/entity.api.php b/core/modules/entity/entity.api.php index 9742f07e982..315b32bdd53 100644 --- a/core/modules/entity/entity.api.php +++ b/core/modules/entity/entity.api.php @@ -219,7 +219,7 @@ function hook_entity_info_alter(&$entity_info) { */ function hook_entity_load($entities, $type) { foreach ($entities as $entity) { - $entity->foo = mymodule_add_something($entity, $type); + $entity->foo = my_module_add_something($entity, $type); } } @@ -379,7 +379,7 @@ function hook_entity_view($entity, $type, $view_mode, $langcode) { $entity->content['my_additional_field'] = array( '#markup' => $additional_field, '#weight' => 10, - '#theme' => 'mymodule_my_additional_field', + '#theme' => 'my_module_my_additional_field', ); } @@ -431,7 +431,7 @@ function hook_entity_view_alter(&$build, $type) { function hook_entity_prepare_view($entities, $type) { // Load a specific node into the user object to theme later. if ($type == 'user') { - $nodes = mymodule_get_user_nodes(array_keys($entities)); + $nodes = my_module_get_user_nodes(array_keys($entities)); foreach ($entities as $uid => $entity) { $entity->user_node = $nodes[$uid]; } diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index b2b96259fef..2500ad82fb1 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -187,13 +187,13 @@ function hook_field_info_alter(&$info) { // Add a setting to all field types. foreach ($info as $field_type => $field_type_info) { $info[$field_type]['settings'] += array( - 'mymodule_additional_setting' => 'default value', + 'my_module_additional_setting' => 'default value', ); } // Change the default widget for fields of type 'foo'. if (isset($info['foo'])) { - $info['foo']['default widget'] = 'mymodule_widget'; + $info['foo']['default widget'] = 'my_module_widget'; } } @@ -817,7 +817,7 @@ function hook_field_widget_info() { function hook_field_widget_info_alter(&$info) { // Add a setting to a widget type. $info['text_textfield']['settings'] += array( - 'mymodule_additional_setting' => 'default value', + 'my_module_additional_setting' => 'default value', ); // Let a new field type re-use an existing widget. @@ -966,9 +966,9 @@ function hook_field_widget_form_alter(&$element, &$form_state, $context) { */ function hook_field_widget_WIDGET_TYPE_form_alter(&$element, &$form_state, $context) { // Code here will only act on widgets of type WIDGET_TYPE. For example, - // hook_field_widget_mymodule_autocomplete_form_alter() will only act on - // widgets of type 'mymodule_autocomplete'. - $element['#autocomplete_path'] = 'mymodule/autocomplete_path'; + // hook_field_widget_my_module_autocomplete_form_alter() will only act on + // widgets of type 'my_module_autocomplete'. + $element['#autocomplete_path'] = 'my_module/autocomplete_path'; } /** @@ -1115,7 +1115,7 @@ function hook_field_formatter_info() { function hook_field_formatter_info_alter(&$info) { // Add a setting to a formatter type. $info['text_default']['settings'] += array( - 'mymodule_additional_setting' => 'default value', + 'my_module_additional_setting' => 'default value', ); // Let a new field type re-use an existing formatter. @@ -1241,7 +1241,7 @@ function hook_field_formatter_view($entity_type, $entity, $field, $instance, $la // customization. foreach ($items as $delta => $item) { $element[$delta] = array( - '#theme' => 'mymodule_theme_sample_field_formatter_themeable', + '#theme' => 'my_module_theme_sample_field_formatter_themeable', '#data' => $item['value'], '#some_setting' => $settings['some_setting'], ); @@ -1530,9 +1530,9 @@ function hook_field_attach_delete_revision($entity_type, $entity) { * @see field_purge_data() */ function hook_field_attach_purge($entity_type, $entity, $field, $instance) { - // find the corresponding data in mymodule and purge it + // Find the corresponding data in my_module and purge it. if ($entity_type == 'node' && $field->field_name == 'my_field_name') { - mymodule_remove_mydata($entity->nid); + my_module_remove_mydata($entity->nid); } } @@ -1732,7 +1732,7 @@ function hook_field_storage_info() { function hook_field_storage_info_alter(&$info) { // Add a setting to a storage type. $info['field_sql_storage']['settings'] += array( - 'mymodule_additional_setting' => 'default value', + 'my_module_additional_setting' => 'default value', ); } diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php index 7a202ca9167..b141310e96d 100644 --- a/core/modules/filter/filter.api.php +++ b/core/modules/filter/filter.api.php @@ -159,7 +159,7 @@ function hook_editor_info() { 'resizeable' => TRUE, ), 'file' => 'myeditor.admin.inc', - 'library' => array('mymodule', 'myeditor'), + 'library' => array('my_module', 'myeditor'), 'js settings callback' => '_myeditor_js_settings', ); return $editors; @@ -593,7 +593,7 @@ function hook_editor_EDITOR_js_settings($format, $filters, $existing_settings) { * @see hook_filter_format_disable() */ function hook_filter_format_insert($format) { - mymodule_cache_rebuild(); + my_module_cache_rebuild(); } /** @@ -610,7 +610,7 @@ function hook_filter_format_insert($format) { * @see hook_filter_format_disable() */ function hook_filter_format_update($format) { - mymodule_cache_rebuild(); + my_module_cache_rebuild(); } /** @@ -623,7 +623,7 @@ function hook_filter_format_update($format) { * @see hook_filter_format_update() */ function hook_filter_format_disable($format) { - mymodule_cache_rebuild(); + my_module_cache_rebuild(); } /** diff --git a/core/modules/image/image.api.php b/core/modules/image/image.api.php index b00878a6094..0ea082e9439 100644 --- a/core/modules/image/image.api.php +++ b/core/modules/image/image.api.php @@ -37,13 +37,13 @@ function hook_image_effect_info() { $effects = array(); - $effects['mymodule_resize'] = array( + $effects['my_module_resize'] = array( 'label' => t('Resize'), 'help' => t('Resize an image to an exact set of dimensions, ignoring aspect ratio.'), - 'effect callback' => 'mymodule_resize_effect', - 'dimensions callback' => 'mymodule_resize_dimensions', - 'form callback' => 'mymodule_resize_form', - 'summary theme' => 'mymodule_resize_summary', + 'effect callback' => 'my_module_resize_effect', + 'dimensions callback' => 'my_module_resize_dimensions', + 'form callback' => 'my_module_resize_form', + 'summary theme' => 'my_module_resize_summary', ); return $effects; @@ -59,9 +59,9 @@ function hook_image_effect_info() { */ function hook_image_effect_info_alter(&$effects) { // Override the Image module's crop effect with more options. - $effects['image_crop']['effect callback'] = 'mymodule_crop_effect'; - $effects['image_crop']['dimensions callback'] = 'mymodule_crop_dimensions'; - $effects['image_crop']['form callback'] = 'mymodule_crop_form'; + $effects['image_crop']['effect callback'] = 'my_module_crop_effect'; + $effects['image_crop']['dimensions callback'] = 'my_module_crop_dimensions'; + $effects['image_crop']['form callback'] = 'my_module_crop_form'; } /** @@ -77,8 +77,8 @@ function hook_image_effect_info_alter(&$effects) { function hook_image_style_save($style) { // If a module defines an image style and that style is renamed by the user // the module should update any references to that style. - if (isset($style['old_name']) && $style['old_name'] == config_get('mymodule.settings', 'image_style')) { - config_set('mymodule.settings', 'image_style', $style['name']); + if (isset($style['old_name']) && $style['old_name'] == config_get('my_module.settings', 'image_style')) { + config_set('my_module.settings', 'image_style', $style['name']); } } @@ -96,8 +96,8 @@ function hook_image_style_save($style) { function hook_image_style_delete($style) { // Administrators can choose an optional replacement style when deleting. // Update the modules style variable accordingly. - if (isset($style['old_name']) && $style['old_name'] == config_get('mymodule.settings', 'image_style')) { - config_set('mymodule.settings', 'image_style', $style['name']); + if (isset($style['old_name']) && $style['old_name'] == config_get('my_module.settings', 'image_style')) { + config_set('my_module.settings', 'image_style', $style['name']); } } @@ -115,7 +115,7 @@ function hook_image_style_delete($style) { */ function hook_image_style_flush($style) { // Empty cached data that contains information about the style. - cache('mymodule')->flush(); + cache('my_module')->flush(); } /** diff --git a/core/modules/layout/layout.api.php b/core/modules/layout/layout.api.php index 26ca45e14b8..c3a0469ecfc 100644 --- a/core/modules/layout/layout.api.php +++ b/core/modules/layout/layout.api.php @@ -140,8 +140,8 @@ function hook_layout_context_info() { * through hook_autoload_info(). * - path: Optional. Override the path to the file to be used. Ordinarily * theme functions are located in a file in the module path (for example: - * mymodule/mymodule.theme.inc) and template files are located in a - * subdirectory named templates (for example: mymodule/templates/), but if + * my_module/my_module.theme.inc) and template files are located in a + * subdirectory named templates (for example: my_module/templates/), but if * your file will not be in the default location, include it here. This * path should be relative to the Backdrop root directory. * - template: If specified, this theme implementation is a template, and @@ -161,7 +161,7 @@ function hook_layout_style_info() { 'title' => t('A new style'), 'description' => t('An advanced style with settings.'), // The theme key for rendering an individual block. - 'block theme' => 'mymodule_block', + 'block theme' => 'my_module_block', // Provide a class name if this style has settings. The class should extend // the LayoutStyle class. 'class' => 'MyModuleLayoutStyle', @@ -356,7 +356,7 @@ function hook_layout_presave(Layout $layout) { * from the path in the router item and you will rely on the system to set the * context, you should set the position of the context(s) in the layout to the * position in the router. Example: the path in the router item is - * mymodule/node/% and you wish to use the layout with path node/%. Then you + * my_module/node/% and you wish to use the layout with path node/%. Then you * would find the context at position 2 in the router item and set its * Context::position variable to 2, so that the layout with path node/% looks * at position 2 to set the context for that placeholder. @@ -589,7 +589,7 @@ function hook_block_configure($delta = '', $settings = array()) { */ function hook_block_save($delta, &$edit = array()) { if ($delta == 'my_block_delta') { - config_set('mymodule.settings', 'my_global_value', $edit['my_global_value']); + config_set('my_module.settings', 'my_global_value', $edit['my_global_value']); // Remove the value so it is not saved by Layout module. unset($edit['my_global_value']); } @@ -702,7 +702,7 @@ function hook_block_view_alter(&$data, $block) { // Add a theme wrapper function defined by the current module to all blocks // provided by the "some_module" module. if (is_array($data['content']) && $block->module == 'some_module') { - $data['content']['#theme_wrappers'][] = 'mymodule_special_block'; + $data['content']['#theme_wrappers'][] = 'my_module_special_block'; } } @@ -735,10 +735,10 @@ function hook_block_view_alter(&$data, $block) { */ function hook_block_view_MODULE_DELTA_alter(&$data, $block) { // This code will only run for a specific block. For example, if MODULE_DELTA - // in the function definition above is set to "mymodule_some_delta", the code - // will only run on the "some_delta" block provided by the "mymodule" module. - - // Change the title of the "some_delta" block provided by the "mymodule" + // in the function definition above is set to "my_module_some_delta", the code + // will only run on the "some_delta" block provided by the "my_module" module. + // + // Change the title of the "some_delta" block provided by the "my_module" // module. $data['title'] = t('New title of the block'); } diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index f650256fde9..6d0798ef51a 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -20,8 +20,8 @@ * node operation: * - Node-type-specific hooks: When defining a node type, node_type_save() * returns a 'base' component. Node-type-specific hooks are named - * base_hookname() instead of mymodule_hookname() (in a module called - * 'mymodule' for example). Only the node type's corresponding implementation + * base_hookname() instead of my_module_hookname() (in a module called + * 'my_module' for example). Only the node type's corresponding implementation * is invoked. For example, book_node_info() in book.module defines the base * for the 'book' node type as 'book'. So when a book node is created, * hook_insert() is invoked on book_insert() only. Hooks that are @@ -780,7 +780,7 @@ function hook_node_view(Node $node, $view_mode, $langcode) { $node->content['my_additional_field'] = array( '#markup' => $additional_field, '#weight' => 10, - '#theme' => 'mymodule_my_additional_field', + '#theme' => 'my_module_my_additional_field', ); } @@ -1014,8 +1014,8 @@ function hook_delete(Node $node) { * @ingroup node_api_hooks */ function hook_prepare(Node $node) { - if (!isset($node->mymodule_value)) { - $node->mymodule_value = 'foo'; + if (!isset($node->my_module_value)) { + $node->my_module_value = 'foo'; } } @@ -1247,7 +1247,7 @@ function hook_view(Node $node, $view_mode) { } $node->content['myfield'] = array( - '#markup' => theme('mymodule_myfield', $node->myfield), + '#markup' => theme('my_module_myfield', $node->myfield), '#weight' => 1, ); diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 9dc45844f13..0d60ff15a0d 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -991,8 +991,8 @@ function search_expression_insert($expression, $option, $value = NULL) { * * If your module needs to provide a more complicated search form, then you need * to implement it yourself without hook_search_info(). In that case, you should - * define it as a local task (tab) under the /search page (e.g. /search/mymodule) - * so that users know where to find it. + * define it as a local task (tab) under the /search page (e.g. + * /search/my_module), so that users know where to find it. */ /** diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index cc13eed9d9c..616a290fdde 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -80,8 +80,8 @@ function hook_hook_info_alter(&$hooks) { */ function hook_admin_paths() { $paths = array( - 'mymodule/*/add' => TRUE, - 'mymodule/*/edit' => TRUE, + 'my_module/*/add' => TRUE, + 'my_module/*/edit' => TRUE, ); return $paths; } @@ -460,7 +460,7 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { // When retrieving the router item for the current path... if ($path == $_GET['q']) { // ...call a function that prepares something for this request. - mymodule_prepare_something(); + my_module_prepare_something(); } } @@ -485,14 +485,14 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * components are passed to the callback function. For example, your module * could register path 'abc/def': * @code - * function mymodule_menu() { + * function my_module_menu() { * $items['abc/def'] = array( - * 'page callback' => 'mymodule_abc_view', + * 'page callback' => 'my_module_abc_view', * ); * return $items; * } * - * function mymodule_abc_view($ghi = 0, $jkl = '') { + * function my_module_abc_view($ghi = 0, $jkl = '') { * // ... * } * @endcode @@ -517,9 +517,9 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * allows you to re-use a callback function for several different paths. For * example: * @code - * function mymodule_menu() { + * function my_module_menu() { * $items['abc/def'] = array( - * 'page callback' => 'mymodule_abc_view', + * 'page callback' => 'my_module_abc_view', * 'page arguments' => array(1, 'foo'), * ); * return $items; @@ -532,14 +532,14 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * requested with optional path arguments, then the list array's arguments are * passed to the callback function first, followed by the optional path * arguments. Using the above example, when path 'abc/def/bar/baz' is requested, - * mymodule_abc_view() will be called with 'def', 'foo', 'bar' and 'baz' as + * my_module_abc_view() will be called with 'def', 'foo', 'bar' and 'baz' as * arguments, in that order. * * Special care should be taken for the page callback backdrop_get_form(), * because your specific form callback function will always receive $form and * &$form_state as the first function arguments: * @code - * function mymodule_abc_form($form, &$form_state) { + * function my_module_abc_form($form, &$form_state) { * // ... * return $form; * } @@ -552,7 +552,7 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * your module could register path 'my-module/%/edit': * @code * $items['my-module/%/edit'] = array( - * 'page callback' => 'mymodule_abc_edit', + * 'page callback' => 'my_module_abc_edit', * 'page arguments' => array(1), * ); * @endcode @@ -562,30 +562,30 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * * @subsection sub_autoload_wildcards Auto-Loader Wildcards * Registered paths may also contain special "auto-loader" wildcard components - * in the form of '%mymodule_abc', where the '%' part means that this path - * component is a wildcard, and the 'mymodule_abc' part defines the prefix for a - * load function, which here would be named mymodule_abc_load(). When a matching - * path is requested, your load function will receive as its first argument the - * path component in the position of the wildcard; load functions may also be - * passed additional arguments (see "load arguments" in the return value - * section below). For example, your module could register path - * 'my-module/%mymodule_abc/edit': + * in the form of '%my_module_abc', where the '%' part means that this path + * component is a wildcard, and the 'my_module_abc' part defines the prefix for + * a load function, which here would be named my_module_abc_load(). When a + * matching path is requested, your load function will receive as its first + * argument the path component in the position of the wildcard; load functions + * may also be passed additional arguments (see "load arguments" in the return + * value section below). For example, your module could register path + * 'my-module/%my_module_abc/edit': * @code - * $items['my-module/%mymodule_abc/edit'] = array( - * 'page callback' => 'mymodule_abc_edit', + * $items['my-module/%my_module_abc/edit'] = array( + * 'page callback' => 'my_module_abc_edit', * 'page arguments' => array(1), * ); * @endcode * When path 'my-module/123/edit' is requested, your load function - * mymodule_abc_load() will be invoked with the argument '123', and should + * my_module_abc_load() will be invoked with the argument '123', and should * load and return an "abc" object with internal id 123: * @code - * function mymodule_abc_load($abc_id) { - * return db_query("SELECT * FROM {mymodule_abc} WHERE abc_id = :abc_id", array(':abc_id' => $abc_id))->fetchObject(); + * function my_module_abc_load($abc_id) { + * return db_query("SELECT * FROM {my_module_abc} WHERE abc_id = :abc_id", array(':abc_id' => $abc_id))->fetchObject(); * } * @endcode * This 'abc' object will then be passed into the callback functions defined - * for the menu item, such as the page callback function mymodule_abc_edit() + * for the menu item, such as the page callback function my_module_abc_edit() * to replace the integer 1 in the argument array. Note that a load function * should return FALSE when it is unable to provide a loadable object. For * example, the node_load() function for the 'node/%node/edit' menu item will @@ -594,7 +594,7 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * * @subsection sub_argument_wildcards Argument Wildcards * You can also define a %wildcard_to_arg() function (for the example menu - * entry above this would be 'mymodule_abc_to_arg()'). The _to_arg() function + * entry above this would be 'my_module_abc_to_arg()'). The _to_arg() function * is invoked to retrieve a value that is used in the path in place of the * wildcard. A good example is user.module, which defines * user_uid_optional_to_arg() (corresponding to the menu entry @@ -1305,34 +1305,34 @@ function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) { * belong to the wizard, which all share the same wrapper callback. */ function hook_forms($form_id, $args) { - // Reroute the (non-existing) $form_id 'mymodule_first_form' to - // 'mymodule_main_form'. - $forms['mymodule_first_form'] = array( - 'callback' => 'mymodule_main_form', + // Reroute the (non-existing) $form_id 'my_module_first_form' to + // 'my_module_main_form'. + $forms['my_module_first_form'] = array( + 'callback' => 'my_module_main_form', ); // Reroute the $form_id and prepend an additional argument that gets passed to - // the 'mymodule_main_form' form builder function. - $forms['mymodule_second_form'] = array( - 'callback' => 'mymodule_main_form', + // the 'my_module_main_form' form builder function. + $forms['my_module_second_form'] = array( + 'callback' => 'my_module_main_form', 'callback arguments' => array('some parameter'), ); // Reroute the $form_id, but invoke the form builder function - // 'mymodule_main_form_wrapper' first, so we can prepopulate the $form array - // that is passed to the actual form builder 'mymodule_main_form'. - $forms['mymodule_wrapped_form'] = array( - 'callback' => 'mymodule_main_form', - 'wrapper_callback' => 'mymodule_main_form_wrapper', + // 'my_module_main_form_wrapper' first, so we can prepopulate the $form array + // that is passed to the actual form builder 'my_module_main_form'. + $forms['my_module_wrapped_form'] = array( + 'callback' => 'my_module_main_form', + 'wrapper_callback' => 'my_module_main_form_wrapper', ); // Build a form with a static class callback. - $forms['mymodule_class_generated_form'] = array( + $forms['my_module_class_generated_form'] = array( // This will call: MyClass::generateMainForm(). 'callback' => array('MyClass', 'generateMainForm'), // The base_form_id is required when the callback is a static function in // a class. This can also be used to keep newer code backwards compatible. - 'base_form_id' => 'mymodule_main_form', + 'base_form_id' => 'my_module_main_form', ); return $forms; @@ -1509,7 +1509,7 @@ function hook_module_implements_alter(&$implementations, $hook) { /** * Return additional themes provided by modules. * - * Only use this hook for testing purposes. Use a hidden MYMODULE_test.module + * Only use this hook for testing purposes. Use a hidden MY_MODULE_test.module * to implement this hook. Testing themes should be hidden, too. * * This hook is invoked from _system_rebuild_theme_data() and allows modules to @@ -1521,7 +1521,7 @@ function hook_module_implements_alter(&$implementations, $hook) { * is the corresponding path to the theme's .info file. */ function hook_system_theme_info() { - $themes['mymodule_test_theme'] = backdrop_get_path('module', 'mymodule') . '/mymodule_test_theme/mymodule_test_theme.info'; + $themes['my_module_test_theme'] = backdrop_get_path('module', 'my_module') . '/my_module_test_theme/my_module_test_theme.info'; return $themes; } @@ -1957,7 +1957,7 @@ function hook_flush_caches() { * An array of modules about to be installed. */ function hook_modules_preinstall($modules) { - mymodule_cache_clear(); + my_module_cache_clear(); } /** @@ -1969,7 +1969,7 @@ function hook_modules_preinstall($modules) { * An array of modules about to be enabled. */ function hook_modules_preenable($modules) { - mymodule_cache_clear(); + my_module_cache_clear(); } /** @@ -2014,8 +2014,8 @@ function hook_modules_installed($modules) { */ function hook_modules_enabled($modules) { if (in_array('lousy_module', $modules)) { - backdrop_set_message(t('mymodule is not compatible with lousy_module'), 'error'); - mymodule_disable_functionality(); + backdrop_set_message(t('my_module is not compatible with lousy_module'), 'error'); + my_module_disable_functionality(); } } @@ -2034,7 +2034,7 @@ function hook_modules_enabled($modules) { */ function hook_modules_disabled($modules) { if (in_array('lousy_module', $modules)) { - mymodule_enable_functionality(); + my_module_enable_functionality(); } } @@ -2056,11 +2056,11 @@ function hook_modules_disabled($modules) { */ function hook_modules_uninstalled($modules) { foreach ($modules as $module) { - db_delete('mymodule_table') + db_delete('my_module_table') ->condition('module', $module) ->execute(); } - mymodule_cache_rebuild(); + my_module_cache_rebuild(); } /** @@ -2667,31 +2667,31 @@ function hook_schema_alter(&$schema) { * @ingroup schemaapi */ function hook_schema_0() { - $schema['mymodule'] = array( - 'description' => 'The base table for mymodule.', + $schema['my_module'] = array( + 'description' => 'The base table for my_module.', 'fields' => array( - 'mymodule_id' => array( - 'description' => 'The primary identifier for mymodule.', + 'my_module_id' => array( + 'description' => 'The primary identifier for my_module.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'title' => array( - 'description' => 'The title column of mymodule.', + 'description' => 'The title column of my_module.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'description' => array( - 'description' => 'The description column of mymodule.', + 'description' => 'The description column of my_module.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), ), - 'primary key' => array('mymodule_id'), + 'primary key' => array('my_module_id'), ); return $schema; } @@ -2816,9 +2816,10 @@ function hook_install() { * updates should adhere to the * @link http://drupal.org/node/150215 Schema API. @endlink * - * Implementations of this hook should be placed in a mymodule.install file in - * the same directory as mymodule.module. Backdrop core's updates are implemented - * using the system module as a name and stored in database/updates.inc. + * Implementations of this hook should be placed in a my_module.install file in + * the same directory as my_module.module. Backdrop core's updates are + * implemented using the system module as a name and stored in + * database/updates.inc. * * Implementations of hook_update_N() are named (module name)_update_(number). * The numbers are composed of three parts: @@ -2840,14 +2841,15 @@ function hook_install() { * compatibility. * * Examples: - * - mymodule_update_1000(): This is the required update for mymodule to run + * - my_module_update_1000(): This is the required update for my_module to run * with Backdrop core API 1.x when upgrading from Drupal core API 7.x. - * - mymodule_update_1100(): This is the first update to get the database/config - * ready to run mymodule 1.x-1.*. - * - mymodule_update_1200(): This is the first update to get the database/config - * ready to run mymodule 1.x-2.*. Users can directly update from Drupal 7.x to - * Backdrop 1.x-2.*, and they get all the 10xx and 12xx updates, but not the - * 11xx updates, because those reside in the 1.x-1.x branch only. + * - my_module_update_1100(): This is the first update to get the + * database/config ready to run my_module 1.x-1.*. + * - my_module_update_1200(): This is the first update to get the + * database/config ready to run my_module 1.x-2.*. Users can directly update + * from Drupal 7.x to Backdrop 1.x-2.*, and they get all the 10xx and 12xx + * updates, but not the 11xx updates, because those reside in the 1.x-1.x + * branch only. * * A good rule of thumb is to remove updates older than two major releases of * Backdrop. See hook_update_last_removed() to notify Backdrop about the @@ -2860,12 +2862,12 @@ function hook_install() { * * Module functions not in the install file cannot be counted on to be available * from within a hook_update_N() function. In order to call a function from your - * mymodule.module or an include file, you need to explicitly load that file + * my_module.module or an include file, you need to explicitly load that file * first. * * This is because if a module was previously enabled but is now disabled (and * has not been uninstalled), update hooks will still be called for that module - * during system updates, but the mymodule.module file (and any other files + * during system updates, but the my_module.module file (and any other files * loaded by that one, including, for example, autoload information) will not * have been loaded. * @@ -2905,20 +2907,21 @@ function hook_install() { * @see update_get_update_list() */ function hook_update_N(&$sandbox) { - // For non-multipass updates the signature can be `function hook_update_N() {` + // For non-multipass updates the signature can be: + // `function hook_update_N() {`. // Convert Drupal 7 variables to Backdrop config. Make sure these new config - // settings and their default values exist in `config/mymodule.settings.json`. - $config = config('mymodule.settings'); - $config->set('one', update_variable_get('mymodule_one', '1.11')); - $config->set('two', update_variable_get('mymodule_two', '2.22')); + // settings and their default values exist in config/my_module.settings.json. + $config = config('my_module.settings'); + $config->set('one', update_variable_get('my_module_one', '1.11')); + $config->set('two', update_variable_get('my_module_two', '2.22')); $config->save(); - update_variable_del('mymodule_one'); - update_variable_del('mymodule_two'); + update_variable_del('my_module_one'); + update_variable_del('my_module_two'); // Update existing config with a new setting. Make sure the new setting and - // its default value exists in `config/mymodule.settings.json`. - config_set('mymodule.settings', 'three', '3.33'); + // its default value exists in `config/my_module.settings.json`. + config_set('my_module.settings', 'three', '3.33'); // For most database updates, the following is sufficient. db_add_field('mytable1', 'newcol', array('type' => 'int', 'not null' => TRUE, 'description' => 'My new integer column.')); @@ -2970,8 +2973,8 @@ function hook_update_N(&$sandbox) { * system to determine the appropriate order in which updates should be run, as * well as to search for missing dependencies. * - * Implementations of this hook should be placed in a mymodule.install file in - * the same directory as mymodule.module. + * Implementations of this hook should be placed in a my_module.install file in + * the same directory as my_module.module. * * @return * A multidimensional array containing information about the module update @@ -2988,21 +2991,21 @@ function hook_update_N(&$sandbox) { * @see hook_update_N() */ function hook_update_dependencies() { - // Indicate that the mymodule_update_1000() function provided by this module + // Indicate that the my_module_update_1000() function provided by this module // must run after the another_module_update_1002() function provided by the // 'another_module' module. - $dependencies['mymodule'][1000] = array( + $dependencies['my_module'][1000] = array( 'another_module' => 1002, ); - // Indicate that the mymodule_update_1001() function provided by this module + // Indicate that the my_module_update_1001() function provided by this module // must run before the yet_another_module_update_1004() function provided by // the 'yet_another_module' module. (Note that declaring dependencies in this // direction should be done only in rare situations, since it can lead to the // following problem: If a site has already run the yet_another_module // module's database updates before it updates its codebase to pick up the - // newest mymodule code, then the dependency declared here will be ignored.) + // newest my_module code, then the dependency declared here will be ignored.) $dependencies['yet_another_module'][1004] = array( - 'mymodule' => 1001, + 'my_module' => 1001, ); return $dependencies; } @@ -3010,12 +3013,12 @@ function hook_update_dependencies() { /** * Return a number which is no longer available as hook_update_N(). * - * If you remove some update functions from your mymodule.install file, you + * If you remove some update functions from your my_module.install file, you * should notify Backdrop of those missing functions. This way, Backdrop can * ensure that no update is accidentally skipped. * - * Implementations of this hook should be placed in a mymodule.install file in - * the same directory as mymodule.module. + * Implementations of this hook should be placed in a my_module.install file in + * the same directory as my_module.module. * * If upgrading from a Drupal 7 module where the last removed update was a * update function numbering in the 7xxx values, that update number should still @@ -3025,14 +3028,14 @@ function hook_update_dependencies() { * * @return int * An integer, corresponding to hook_update_N() which has been removed from - * mymodule.install. + * my_module.install. * * @see hook_update_N() */ function hook_update_last_removed() { - // We've removed the 1.x-1.x version of mymodule, including database updates. + // We've removed the 1.x-1.x version of my_module, including database updates. // For the 1.x-2.x version of the module, the next update function would be - // mymodule_update_1200(). + // my_module_update_1200(). return 1103; } @@ -3080,7 +3083,7 @@ function hook_uninstall() { * @see hook_modules_enabled() */ function hook_enable() { - mymodule_cache_rebuild(); + my_module_cache_rebuild(); } /** @@ -3094,7 +3097,7 @@ function hook_enable() { * @see hook_modules_disabled() */ function hook_disable() { - mymodule_cache_rebuild(); + my_module_cache_rebuild(); } /** @@ -3347,7 +3350,7 @@ function hook_html_head_alter(&$head_elements) { foreach ($head_elements as $key => $element) { if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') { // I want a custom canonical URL. - $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url(); + $head_elements[$key]['#attributes']['href'] = my_module_canonical_url(); } } } @@ -4047,7 +4050,7 @@ function hook_filetransfer_info() { * @see hook_filetransfer_info() */ function hook_filetransfer_info_alter(&$filetransfer_info) { - if (config_get('mymodule.settings', 'paranoia')) { + if (config_get('my_module.settings', 'paranoia')) { // Remove the FTP option entirely. unset($filetransfer_info['ftp']); // Make sure the SSH option is listed first. @@ -4076,16 +4079,16 @@ function hook_filetransfer_info_alter(&$filetransfer_info) { * Instead, a simplified utility function should be used. If a utility version * of the API function you require does not already exist, then you should * create a new function. The new utility function should be named - * _update_N_mymodule_my_function(). N is the schema version the function acts + * _update_N_my_module_my_function(). N is the schema version the function acts * on (the schema version is the number N from the hook_update_N() * implementation where this schema was introduced, or a number following the - * same numbering scheme), and mymodule_my_function is the name of the original + * same numbering scheme), and my_module_my_function is the name of the original * API function including the module's name. * * Examples: - * - _update_6000_mymodule_save(): This function performs a save operation + * - _update_6000_my_module_save(): This function performs a save operation * without invoking any hooks using the 6.x schema. - * - _update_7000_mymodule_save(): This function performs the same save + * - _update_7000_my_module_save(): This function performs the same save * operation using the 7.x schema. * * The utility function should not invoke any hooks, and should perform database diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0a340732915..b37b5570797 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -4490,18 +4490,18 @@ function system_file_download($uri) { * submit function saves all the data in the form. * * If $form['#config'] is present in the form, the values will be saved to the - * named settings file (e.g., mymodule.settings). If sub-elements or groups of + * named settings file (e.g., my_module.settings). If sub-elements or groups of * sub-elements have their own '#config' keys, then values of those elements and * their children will be saved to that settings file. * * For example, consider the form: * * @code - * $primary_config = config('mymodule.settings'); - * $secondary_config = config('mymodule.second'); - * $tertiary_config = config('mymodule.third'); + * $primary_config = config('my_module.settings'); + * $secondary_config = config('my_module.second'); + * $tertiary_config = config('my_module.third'); * $form = array( - * '#config' => 'mymodule.settings', + * '#config' => 'my_module.settings', * 'first_setting' => array( * '#type' => 'textfield', * '#title' => t('First Setting'), @@ -4512,7 +4512,7 @@ function system_file_download($uri) { * 'bonus_fieldset' => array( * '#type' => 'fieldset', * '#title' => t('Secondary Settings'), - * '#config' => 'mymodule.second', + * '#config' => 'my_module.second', * * 'bonus_one' => array( ... ), * 'bonus_two' => array( ... ), @@ -4520,22 +4520,23 @@ function system_file_download($uri) { * 'bonus_three' => array( * '#type' => 'textfield', * '#default_value' => $tertiary_config->get('bonus_three'), - * '#config' => 'mymodule.third', + * '#config' => 'my_module.third', * ), * ), * ); * @endcode * - * The top-level '#config' is "mymodule.settings". The values of 'first_setting' - * and 'second_setting' will both be saved to "mymodule.settings". + * The top-level '#config' is "my_module.settings". The values of + * 'first_setting' and 'second_setting' will both be saved to + * "my_module.settings". * - * The 'bonus_fieldset' has its own '#config' setting, "mymodule.second", which + * The 'bonus_fieldset' has its own '#config' setting, "my_module.second", which * overrides the top-level '#config' setting, so 'bonus_one' and 'bonus_two' - * will be saved to "mymodule.second". + * will be saved to "my_module.second". * - * The 'bonus_three' has its own '#config' setting, "mymodule.third", which + * The 'bonus_three' has its own '#config' setting, "my_module.third", which * overrides the one from the fieldset. The value of 'bonus_three' will be - * saved to the "mymodule.third". + * saved to the "my_module.third". * * Modules that implement hook_form_alter() can use the '#config' settings to * save their data to their own settings file by setting the '#config' parameter diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 38464ba929b..29b303daa2b 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -170,7 +170,7 @@ function hook_preprocess_HOOK(&$variables) { */ function hook_themes_enabled($theme_list) { foreach ($theme_list as $theme) { - mymodule_prepare_theme($theme); + my_module_prepare_theme($theme); } } diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php index 6968809ae1e..e86d97f5730 100644 --- a/core/modules/taxonomy/taxonomy.api.php +++ b/core/modules/taxonomy/taxonomy.api.php @@ -239,7 +239,7 @@ function hook_taxonomy_term_view($term, $view_mode, $langcode) { $term->content['my_additional_field'] = array( '#markup' => $additional_field, '#weight' => 10, - '#theme' => 'mymodule_my_additional_field', + '#theme' => 'my_module_my_additional_field', ); } diff --git a/core/modules/telemetry/telemetry.api.php b/core/modules/telemetry/telemetry.api.php index 81af8e6fd47..072608c221c 100644 --- a/core/modules/telemetry/telemetry.api.php +++ b/core/modules/telemetry/telemetry.api.php @@ -24,16 +24,16 @@ * the module name, or if the project contains multiple modules. */ function hook_telemetry_info() { - // If this were in mymodule.module, "project" would assume to be "mymodule". - $info['mymodule_setting_1'] = array( + // If this were in my_module.module, "project" would assume to be "my_module". + $info['my_module_setting_1'] = array( 'label' => t('My module setting 1'), 'description' => t('Some information about what setting 1 is.'), ); // If this were in submodule.module, specify the project name explicitly. - $info['mymodule_submodule_setting_2'] = array( + $info['my_module_submodule_setting_2'] = array( 'label' => t('Submodule setting 2'), 'description' => t('A description describing this setting of a sub-module.'), - 'project' => 'mymodule', + 'project' => 'my_module', ); return $info; } @@ -53,7 +53,7 @@ function hook_telemetry_info_alter(array &$info) { // Prevent one particular module from reporting anything. foreach ($info as $info_key => $info_data) { - if ($info_data['module'] === 'mymodule') { + if ($info_data['module'] === 'my_module') { unset($info[$info_key]); } } @@ -82,8 +82,8 @@ function hook_telemetry_data($telemetry_key) { switch ($telemetry_key) { case 'php_version': return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION; - case 'mymodule_setting_1': - return config_get('mymodule.settings', 'setting_1'); + case 'my_module_setting_1': + return config_get('my_module.settings', 'setting_1'); } } @@ -101,8 +101,8 @@ function hook_telemetry_data($telemetry_key) { * @param array $telemetry_data */ function hook_telemetry_data_alter(array $telemetry_data) { - if (isset($telemetry_data['mymodule_setting_1'])) { - $telemetry_data['mymodule_setting_1'] = 'some_different_value'; + if (isset($telemetry_data['my_module_setting_1'])) { + $telemetry_data['my_module_setting_1'] = 'some_different_value'; } } diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 4e2005c653f..13370078736 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -163,7 +163,7 @@ function hook_user_cancel_methods_alter(&$methods) { unset($methods['user_cancel_reassign']); // Add a custom zero-out method. - $methods['mymodule_zero_out'] = array( + $methods['my_module_zero_out'] = array( 'title' => t('Delete the account and remove all content.'), 'description' => t('All your content will be replaced by empty strings.'), // access should be used for administrative methods only. @@ -210,10 +210,10 @@ function hook_user_format_name_alter(&$name, $account) { * @see hook_user_update() */ function hook_user_presave($account) { - // Make sure that our form value 'mymodule_foo' is stored as - // 'mymodule_bar' in the 'data' (serialized) column. - if (isset($account->mymodule_foo)) { - $account->data['mymodule_bar'] = $account->mymodule_foo; + // Make sure that our form value 'my_module_foo' is stored as + // 'my_module_bar' in the 'data' (serialized) column. + if (isset($account->my_module_foo)) { + $account->data['my_module_bar'] = $account->my_module_foo; } } diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index a40f84cd1ba..69f8fca63a8 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -964,7 +964,7 @@ function hook_views_ajax_data_alter(&$commands, $view) { * @see views_invalidate_cache() */ function hook_views_invalidate_cache() { - cache('mymodule')->deletePrefix('views:'); + cache('my_module')->deletePrefix('views:'); } /** From 5430d0a5ad9858d4caa76275764e66de2daeb3b9 Mon Sep 17 00:00:00 2001 From: quicksketch Date: Thu, 15 Feb 2024 14:21:27 -0800 Subject: [PATCH 02/10] Removing accidental .DS_STORE file. --- core/modules/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 core/modules/.DS_Store diff --git a/core/modules/.DS_Store b/core/modules/.DS_Store deleted file mode 100644 index 39bca42f2d55679709f8da527f2e9bb77e66b337..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ8r`;3?);e2++l2MqME{5RBvmzCeqnNQS@#Tr{(%oU2Fc<7aW*Zs`&{0@RZz zJ_&k*X^Mz;pNFkTD9)u6G%7#^?mz+iJ`}iNO`HP#(}BTT0APc#8|L0i z0E-2HHE{|=1g1d+2351g(4Zq;GOs31fk79|=0o#l%??HVcAQ^4U9<*rqyki6uE0Yq zTdV(j_#gfMoWvCspaOTLfHu2+*WpQ7TNjVBT3g`HaLf6En_=!03|@|bUXHP_a=h`R b$SXF-eodSLosPKEf&3XTU1(I`zZLiffUy;b From 7f93e61a2c27507e208de21cd80a7ec831bf1db4 Mon Sep 17 00:00:00 2001 From: indigoxela Date: Thu, 7 Mar 2024 20:41:35 +0100 Subject: [PATCH 03/10] Issue #6384: Make alignment of linked captioned images work regardless of filter order. By @indigoxela, @herbdool, and @olafgrabienski. --- core/modules/filter/filter.module | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 8e463599413..94dce3c8b0f 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -2670,6 +2670,11 @@ function _filter_image_align($text) { if ($parent && $parent->nodeName === 'figure') { $target = $parent; } + // Consider more deeply nested structures. A link wrapped around a + // captioned image. + elseif ($parent && $parent->nodeName === 'a' && $parent->parentNode && $parent->parentNode->nodeName === 'figure') { + $target = $parent->parentNode; + } else { $target = $node; } From 3860f5ac4468f24eb44698a7e30d5c3e4012843f Mon Sep 17 00:00:00 2001 From: Herb Date: Thu, 7 Mar 2024 19:10:55 -0500 Subject: [PATCH 04/10] Issue #6103: Hide revision by default if revisions disabled, and clarify description. By @herbdool, @kswan, @klonos, @izmeez, and @yorkshire-pudding. --- core/modules/node/node.types.inc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/node/node.types.inc b/core/modules/node/node.types.inc index 5ac78dd4ce7..07922dc8ef7 100644 --- a/core/modules/node/node.types.inc +++ b/core/modules/node/node.types.inc @@ -418,7 +418,7 @@ function node_type_form($form, &$form_state, $type = NULL) { ); $form['revision']['revision']['revision_enabled'] = array( '#type' => 'checkbox', - '#title' => t('Show option to create new revisions'), + '#title' => t('Enable option to create revisions'), '#default_value' => $type->settings['revision_enabled'], '#parents' => array('revision_enabled'), '#description' => t('Revisions allow content editors to view changes over time and revert changes if needed.'), @@ -426,8 +426,17 @@ function node_type_form($form, &$form_state, $type = NULL) { $form['revision']['revision']['revision_default'] = array( '#type' => 'checkbox', '#title' => t('Create new revision by default'), + '#description' => t('If enabled, revisions to content will be created by default. People with the "Administer content" permission will see an option to create a revision.'), '#default_value' => $type->settings['revision_default'], '#parents' => array('revision_default'), + '#states' => array( + 'visible' => array( + 'input[name="revision_enabled"]' => array('checked' => TRUE), + ), + 'enabled' => array( + 'input[name="revision_enabled"]' => array('checked' => TRUE), + ), + ), ); // Menu settings. From 414ca7c1133112694d94743aeb8b2432ad1f0488 Mon Sep 17 00:00:00 2001 From: Alejandro Cremaschi Date: Thu, 7 Mar 2024 17:13:50 -0700 Subject: [PATCH 05/10] Issue #6410: Add node/%/translate as a contextual link. By @argiepiano, @olafgrabienski, and @indigoxela. --- core/modules/translation/translation.module | 1 + 1 file changed, 1 insertion(+) diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index b6b04d03029..16a22a59b03 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -35,6 +35,7 @@ function translation_menu() { 'access callback' => '_translation_tab_access', 'access arguments' => array(1), 'type' => MENU_LOCAL_TASK, + 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, 'weight' => 2, 'file' => 'translation.pages.inc', ); From 9490ad323b8d4815a9238eb013ca01ef574e17f3 Mon Sep 17 00:00:00 2001 From: Alejandro Cremaschi Date: Thu, 7 Mar 2024 17:28:52 -0700 Subject: [PATCH 06/10] Issue #3166: Retain field focus after autosubmit replaces a form element. By @argiepiano, @klonos, @antijingoist, @yorkshire-pudding, @indigoxela, and @quicksketch. --- core/misc/autosubmit.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/core/misc/autosubmit.js b/core/misc/autosubmit.js index c91cc20743f..4b978316757 100644 --- a/core/misc/autosubmit.js +++ b/core/misc/autosubmit.js @@ -37,12 +37,37 @@ Backdrop.behaviors.autosubmit = { attach: function(context) { // 'this' references the form element - function triggerSubmit (e) { + function triggerSubmit (element) { var $this = $(this); + + // Variable "element" will have a value only when text fields trigger + // this. If element is undefined, then remove the data to prevent + // potential focus on a previously processed element. + if (element === undefined) { + $('body').removeData('autosubmit-last-focus-id'); + } + else { + $('body').data('autosubmit-last-focus-id', $(element).attr('id')); + } + + // Submit the form. $this.find('.autosubmit-click').trigger('click'); } - // the change event bubbles so we only need to bind it to the outer form + // Listener to ajaxStop will re-focus on the text field as needed. + $(document).off('ajaxStop.autosubmit').on('ajaxStop.autosubmit', function () { + let id = $('body').data('autosubmit-last-focus-id'); + if (id === undefined) { + return; + } + let $textInput = $('#' + id); + let pos = $textInput.val().length; + $textInput.focus(); + $textInput[0].setSelectionRange(pos, pos); + $('body').removeData('autosubmit-last-focus-id'); + }); + + // The change event bubbles so we only need to bind it to the outer form. $('form.autosubmit-full-form', context) .add('.autosubmit', context) .filter('form, select, input:not(:text, :submit)') @@ -86,12 +111,14 @@ Backdrop.behaviors.autosubmit = { }) .on('keyup', function(e) { if ($.inArray(e.keyCode, discardKeyCode) === -1) { - timeoutID = setTimeout($.proxy(triggerSubmit, this.form), 500); + // Provide the target element to triggerSubmit. + timeoutID = setTimeout($.proxy(triggerSubmit, this.form, e.target), 500); } }) .on('change', function (e) { if ($.inArray(e.keyCode, discardKeyCode) === -1) { - timeoutID = setTimeout($.proxy(triggerSubmit, this.form), 500); + // Provide the target element to triggerSubmit. + timeoutID = setTimeout($.proxy(triggerSubmit, this.form, e.target), 500); } }); }); From 8c4da23c5f10f727f24fa4f2e9684b565ebb0fe1 Mon Sep 17 00:00:00 2001 From: Jen Lampton Date: Mon, 15 Jan 2024 17:11:50 -0800 Subject: [PATCH 07/10] Issue #6417: Security hardening for jQuery form library. By @jenlampton, @klonos, @olafgrabienski, and @quicksketch. With code by Drupal.org users effulgentsia and pandaski. --- core/misc/ajax.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 46d4785adc3..e06098afab1 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -367,6 +367,20 @@ Backdrop.ajax.prototype.beforeSerialize = function (element, options) { if (this.form) { var settings = this.settings || Backdrop.settings; Backdrop.detachBehaviors(this.form, settings, 'serialize'); + + // Ensure Backdrop isn't vulnerable to the bugs disclosed in the unmerged + // pull request: https://github.com/jquery-form/form/pull/586. + // - Under normal circumstances, the first if statement doesn't evaluate + // to true, because options.dataType is initialized in the Drupal.ajax() + // constructor. + // - Under normal circumstances, the second if statement doesn't evaluate + // to true, because $.parseJSON is initialized by jQuery. + if (!options.dataType && options.target) { + delete options.target; + } + if (!$.parseJSON) { + $.parseJSON = JSON.parse; + } } // Prevent duplicate HTML ids in the returned markup. From 134398376e67399c0eff1576a83859a76f934056 Mon Sep 17 00:00:00 2001 From: Nate Lampton Date: Fri, 8 Mar 2024 06:38:22 -0800 Subject: [PATCH 08/10] Issue #6293: Prevent dashboard loading before layout module in upgrades. by @quicksketch, @kiamlaluno, @indigoxela, @klonos, and @argiepiano. --- core/modules/dashboard/dashboard.info | 1 + 1 file changed, 1 insertion(+) diff --git a/core/modules/dashboard/dashboard.info b/core/modules/dashboard/dashboard.info index 9b2dd1f5e15..d5fedee5e64 100644 --- a/core/modules/dashboard/dashboard.info +++ b/core/modules/dashboard/dashboard.info @@ -5,3 +5,4 @@ version = BACKDROP_VERSION type = module backdrop = 1.x configure = admin/dashboard/settings +dependencies[] = layout From 57022005efcd78dca62b5ca92c0b27a487e41b7e Mon Sep 17 00:00:00 2001 From: Laryn Date: Wed, 13 Mar 2024 13:22:12 -0500 Subject: [PATCH 09/10] Issue #6419: Remove attempt to add non-existent html5shiv. By @laryn and @herbdool. --- core/includes/common.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index ca9d694216f..cbfd64bf166 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4702,7 +4702,6 @@ function backdrop_add_js($data = NULL, $options = NULL) { // Register all required libraries. backdrop_add_library('system', 'jquery', TRUE); backdrop_add_library('system', 'jquery.once', TRUE); - backdrop_add_library('system', 'html5shiv', TRUE); } switch ($options['type']) { From 266a5018c5e675ee88e51dd6e732da3ec464a696 Mon Sep 17 00:00:00 2001 From: AlexH <94841742+AlexHoebart-ICPDR@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:41:12 +0100 Subject: [PATCH 10/10] Issue #6412: Fix wrong display of some float values in Views. By @AlexHoebart-ICPDR, @indigoxela, and @bugfolder. --- .../handlers/views_handler_field_math.inc | 31 +- .../handlers/views_handler_field_numeric.inc | 30 +- .../handlers/views_handler_field_math.test | 45 ++- .../config/views.view.floatval_check.json | 348 ++++++++++++++++++ 4 files changed, 428 insertions(+), 26 deletions(-) create mode 100644 core/modules/views/tests/views_test/config/views.view.floatval_check.json diff --git a/core/modules/views/handlers/views_handler_field_math.inc b/core/modules/views/handlers/views_handler_field_math.inc index 3d524b25db4..99a5462c0e4 100644 --- a/core/modules/views/handlers/views_handler_field_math.inc +++ b/core/modules/views/handlers/views_handler_field_math.inc @@ -53,24 +53,31 @@ class views_handler_field_math extends views_handler_field_numeric { // The rest is directly from views_handler_field_numeric but because it // does not allow the value to be passed in, it is copied. - if (!empty($this->options['set_precision'])) { - $value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']); - } - else { - $remainder = abs($value) - intval(abs($value)); - $value = $value > 0 ? floor($value) : ceil($value); - $value = number_format($value, 0, '', $this->options['separator']); - if ($remainder) { - // The substr may not be locale safe. - $value .= $this->options['decimal'] . substr($remainder, 2); - } - } // Check to see if hiding should happen before adding prefix and suffix. if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) { return ''; } + if (!empty($this->options['set_precision'])) { + $precision = $this->options['precision']; + } + elseif ($decimal_position = strpos($value, '.')) { + $precision = strlen(rtrim($value, '0')) - $decimal_position - 1; + } + else { + $precision = 0; + } + + // Use round first to avoid negative zeros. + $value = round($value, $precision); + // Test against both integer zero and float zero. + if ($this->options['empty_zero'] && ($value === 0 || $value === 0.0)) { + return ''; + } + + $value = number_format($value, $precision, $this->options['decimal'], $this->options['separator']); + // Should we format as a plural. if (!empty($this->options['format_plural']) && ($value != 0 || !$this->options['empty_zero'])) { $value = format_plural($value, $this->options['format_plural_singular'], $this->options['format_plural_plural']); diff --git a/core/modules/views/handlers/views_handler_field_numeric.inc b/core/modules/views/handlers/views_handler_field_numeric.inc index 34bc5e3b5be..1c9dfb4c8fd 100644 --- a/core/modules/views/handlers/views_handler_field_numeric.inc +++ b/core/modules/views/handlers/views_handler_field_numeric.inc @@ -124,23 +124,29 @@ class views_handler_field_numeric extends views_handler_field { return ''; } + // Check to see if hiding should happen before adding prefix and suffix. + if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) { + return ''; + } + if (!empty($this->options['set_precision'])) { - $value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']); + $precision = $this->options['precision']; + } + elseif ($decimal_position = strpos($value, '.')) { + $precision = strlen(rtrim($value, '0')) - $decimal_position - 1; } else { - $remainder = abs($value) - intval(abs($value)); - $value = $value > 0 ? floor($value) : ceil($value); - $value = number_format($value, 0, '', $this->options['separator']); - if ($remainder) { - // The substr may not be locale safe. - $value .= $this->options['decimal'] . substr($remainder, 2); - } + $precision = 0; } - // Check to see if hiding should happen before adding prefix and suffix. - if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) { - return ''; - } + // Use round first to avoid negative zeros. + $value = round($value, $precision); + // Test against both integer zero and float zero. + if ($this->options['empty_zero'] && ($value === 0 || $value === 0.0)) { + return ''; + } + + $value = number_format($value, $precision, $this->options['decimal'], $this->options['separator']); // Should we format as a plural. if (!empty($this->options['format_plural'])) { diff --git a/core/modules/views/tests/handlers/views_handler_field_math.test b/core/modules/views/tests/handlers/views_handler_field_math.test index 16f401ae30f..2b0ddf6fee1 100644 --- a/core/modules/views/tests/handlers/views_handler_field_math.test +++ b/core/modules/views/tests/handlers/views_handler_field_math.test @@ -10,12 +10,24 @@ require_once BACKDROP_ROOT . '/core/modules/views/tests/views_query.test'; * Tests the core views_handler_field_math handler. */ class ViewsHandlerFieldMath extends ViewsSqlTest { - function viewsData() { + + /** + * {@inheritdoc} + */ + protected $profile = 'testing'; + + /** + * {@inheritdoc} + */ + protected function viewsData() { $data = parent::viewsData(); return $data; } - public function testFieldCustom() { + /** + * Test basic field functionality. + */ + protected function testFieldCustom() { $view = $this->getBasicView(); // Alter the text of the field to a random string. @@ -35,4 +47,33 @@ class ViewsHandlerFieldMath extends ViewsSqlTest { $this->assertEqual($rand1 + $rand2, $view->style_plugin->get_field(0, 'expression')); } + + /** + * Test rendering of float values in "Global: Math expression" fields. + */ + protected function testMathFloatRender() { + // We need one dummy node of any type for our node based views query. + $type = $this->backdropCreateContentType(); + $this->backdropCreateNode(array( + 'type' => $type->type, + )); + $view = views_get_view('floatval_check'); + $this->executeView($view); + $result = $view->result[0]; + + foreach ($view->field as $name => $view_field) { + if ($name == 'nid') { + continue; + } + // In the view we set the label value to the raw input value (floats), to + // compare rendered output here. + $label = $view->field[$name]->label(); + $render = $view->field[$name]->advanced_render($result); + $this->assertIdentical($label, $render, format_string('Expected rendered output to be %label, got %render', array( + '%label' => $label, + '%render' => $render, + ))); + } + } + } diff --git a/core/modules/views/tests/views_test/config/views.view.floatval_check.json b/core/modules/views/tests/views_test/config/views.view.floatval_check.json new file mode 100644 index 00000000000..299c1c4d461 --- /dev/null +++ b/core/modules/views/tests/views_test/config/views.view.floatval_check.json @@ -0,0 +1,348 @@ +{ + "_config_name": "views.view.floatval_check", + "name": "floatval_check", + "description": "", + "tag": "", + "disabled": false, + "base_table": "node", + "human_name": "Test float value rendering", + "core": "1.28.x-dev", + "display": { + "default": { + "display_title": "Default", + "display_plugin": "default", + "display_options": { + "query": { + "type": "views_query", + "options": [] + }, + "access": { + "type": "none" + }, + "cache": { + "type": "none" + }, + "exposed_form": { + "type": "basic" + }, + "pager": { + "type": "some", + "options": { + "items_per_page": "1", + "offset": "0" + } + }, + "style_plugin": "default", + "row_plugin": "fields", + "fields": { + "nid": { + "id": "nid", + "table": "node", + "field": "nid", + "relationship": "none", + "group_type": "group", + "ui_name": "", + "label": "", + "exclude": 1, + "alter": { + "alter_text": 0, + "text": "", + "make_link": 0, + "path": "", + "absolute": 0, + "external": 0, + "replace_spaces": 0, + "path_case": "none", + "trim_whitespace": 0, + "alt": "", + "rel": "", + "link_class": "", + "prefix": "", + "suffix": "", + "target": "", + "nl2br": 0, + "max_length": "", + "word_boundary": 1, + "ellipsis": 1, + "more_link": 0, + "more_link_text": "", + "more_link_path": "", + "strip_tags": 0, + "trim": 0, + "preserve_tags": "", + "html": 0 + }, + "element_type": "", + "element_class": "", + "element_label_type": "", + "element_label_class": "", + "element_label_colon": false, + "element_wrapper_type": "", + "element_wrapper_class": "", + "element_default_classes": 1, + "empty": "", + "hide_empty": 0, + "empty_zero": 0, + "hide_alter_empty": 1, + "link_to_node": 0 + }, + "expression_2": { + "id": "expression_2", + "table": "views", + "field": "expression", + "relationship": "none", + "group_type": "group", + "ui_name": "", + "label": "-1234.01", + "exclude": 0, + "alter": { + "alter_text": 0, + "text": "", + "make_link": 0, + "path": "", + "absolute": 0, + "external": 0, + "replace_spaces": 0, + "path_case": "none", + "trim_whitespace": 0, + "alt": "", + "rel": "", + "link_class": "", + "prefix": "", + "suffix": "", + "target": "", + "nl2br": 0, + "max_length": "", + "word_boundary": 1, + "ellipsis": 1, + "more_link": 0, + "more_link_text": "", + "more_link_path": "", + "strip_tags": 0, + "trim": 0, + "preserve_tags": "", + "html": 0 + }, + "element_type": "", + "element_class": "", + "element_label_type": "", + "element_label_class": "", + "element_label_colon": 0, + "element_wrapper_type": "", + "element_wrapper_class": "", + "element_default_classes": 1, + "empty": "", + "hide_empty": 0, + "empty_zero": 0, + "hide_alter_empty": 1, + "set_precision": 0, + "precision": "0", + "decimal": ".", + "separator": "", + "format_plural": 0, + "format_plural_singular": "1", + "format_plural_plural": "@count", + "prefix": "", + "suffix": "", + "expression": "-1234.01" + }, + "expression_1": { + "id": "expression_1", + "table": "views", + "field": "expression", + "relationship": "none", + "group_type": "group", + "ui_name": "", + "label": "-0.5", + "exclude": 0, + "alter": { + "alter_text": 0, + "text": "", + "make_link": 0, + "path": "", + "absolute": 0, + "external": 0, + "replace_spaces": 0, + "path_case": "none", + "trim_whitespace": 0, + "alt": "", + "rel": "", + "link_class": "", + "prefix": "", + "suffix": "", + "target": "", + "nl2br": 0, + "max_length": "", + "word_boundary": 1, + "ellipsis": 1, + "more_link": 0, + "more_link_text": "", + "more_link_path": "", + "strip_tags": 0, + "trim": 0, + "preserve_tags": "", + "html": 0 + }, + "element_type": "", + "element_class": "", + "element_label_type": "", + "element_label_class": "", + "element_label_colon": 0, + "element_wrapper_type": "", + "element_wrapper_class": "", + "element_default_classes": 1, + "empty": "", + "hide_empty": 0, + "empty_zero": 0, + "hide_alter_empty": 1, + "set_precision": 0, + "precision": "0", + "decimal": ".", + "separator": "", + "format_plural": 0, + "format_plural_singular": "1", + "format_plural_plural": "@count", + "prefix": "", + "suffix": "", + "expression": "-0.5" + }, + "expression_4": { + "id": "expression_4", + "table": "views", + "field": "expression", + "relationship": "none", + "group_type": "group", + "ui_name": "", + "label": "17.0029", + "exclude": 0, + "alter": { + "alter_text": 0, + "text": "", + "make_link": 0, + "path": "", + "absolute": 0, + "external": 0, + "replace_spaces": 0, + "path_case": "none", + "trim_whitespace": 0, + "alt": "", + "rel": "", + "link_class": "", + "prefix": "", + "suffix": "", + "target": "", + "nl2br": 0, + "max_length": "", + "word_boundary": 1, + "ellipsis": 1, + "more_link": 0, + "more_link_text": "", + "more_link_path": "", + "strip_tags": 0, + "trim": 0, + "preserve_tags": "", + "html": 0 + }, + "element_type": "", + "element_class": "", + "element_label_type": "", + "element_label_class": "", + "element_label_colon": 0, + "element_wrapper_type": "", + "element_wrapper_class": "", + "element_default_classes": 1, + "empty": "", + "hide_empty": 0, + "empty_zero": 0, + "hide_alter_empty": 1, + "set_precision": 0, + "precision": "0", + "decimal": ".", + "separator": "", + "format_plural": 0, + "format_plural_singular": "1", + "format_plural_plural": "@count", + "prefix": "", + "suffix": "", + "expression": "17.0029" + }, + "expression": { + "id": "expression", + "table": "views", + "field": "expression", + "relationship": "none", + "group_type": "group", + "ui_name": "", + "label": "67.93", + "exclude": 0, + "alter": { + "alter_text": 0, + "text": "", + "make_link": 0, + "path": "", + "absolute": 0, + "external": 0, + "replace_spaces": 0, + "path_case": "none", + "trim_whitespace": 0, + "alt": "", + "rel": "", + "link_class": "", + "prefix": "", + "suffix": "", + "target": "", + "nl2br": 0, + "max_length": "", + "word_boundary": 1, + "ellipsis": 1, + "more_link": 0, + "more_link_text": "", + "more_link_path": "", + "strip_tags": 0, + "trim": 0, + "preserve_tags": "", + "html": 0 + }, + "element_type": "", + "element_class": "", + "element_label_type": "", + "element_label_class": "", + "element_label_colon": 0, + "element_wrapper_type": "", + "element_wrapper_class": "", + "element_default_classes": 1, + "empty": "", + "hide_empty": 0, + "empty_zero": 0, + "hide_alter_empty": 1, + "set_precision": 0, + "precision": "0", + "decimal": ".", + "separator": "", + "format_plural": 0, + "format_plural_singular": "1", + "format_plural_plural": "@count", + "prefix": "", + "suffix": "", + "expression": "67.93" + } + }, + "filters": [], + "sorts": [], + "title": "", + "style_options": { + "grouping": [], + "row_class": "", + "default_row_class": 0, + "row_class_special": 0 + }, + "row_options": { + "default_field_elements": 1, + "inline": [], + "separator": "", + "hide_empty": 0 + } + } + } + } +}