Quantcast
Channel: Issues for Drupal core
Viewing all 300222 articles
Browse latest View live

Unicode requirements should check *_encoding for 5.6+

$
0
0

Problem/Motivation

Mixing encodings is a bad idea, as it can lead to bugs, garbled input/output, storing bad data and security issues, so we want to use UTF-8 everywhere and check for this in the Unicode requirements check.

Over in #2332295: Unicode requirements check not working with PHP 5.6 we added support for http_input and http_output for < 5.6 in Unicode::check() be we also want to add support for the newly added internal_encoding, input_encoding and output_encoding for 5.6+.

Per the RFC the precedence of settings for the mb_*, iconv_*, htmlentities functions is:
default_charset < php.* < mbstring.*/iconv.* < encoding specified by functions

So the values must be set as follows:

PHP <5.6

  • mbstring.http_input = pass (set in our .htaccess)
  • mbstring.http_output = pass (set in our .htaccess)
  • mbstring.internal_encoding = irrelevant, we set it ourselves
  • iconv.internal_encoding = empty (default) or utf-8
  • iconv.output_encoding = empty (default) or utf-8

PHP >=5.6

Same as before, except now mbstring.* and iconv.* are deprecated so they may also be empty. Newly introduced variables:

  • input_encoding (misnamed in PHP 5.6/7, the RFC says php.input_encoding) = empty or utf-8
  • internal_encoding (misnamed in PHP 5.6/7, the RFC says php.input_encoding) = empty or utf-8
  • output_encoding (misnamed in PHP 5.6/7, the RFC says php.input_encoding) = empty or utf-8

@see

  1. https://wiki.php.net/rfc/default_encoding
  2. http://php.net/manual/en/mbstring.configuration.php#ini.mbstring.interna...

Proposed resolution

Update Unicode::check() to also test for the newly introduced *_encoding options in PHP 5.6+

Remaining tasks

Review patch

User interface changes

n/a

API changes

n/a


Notice: Undefined index: #type in drupal_process_states()

$
0
0

Problem/Motivation

Problem

  • When #states is attached to a form element that contains #markup the following notice occurs:

    Notice: Undefined index: #type in drupal_process_states() (line 583 of core/includes/common.inc).

Cause

  • This happens because a #markup element does not require the #type to be set.

Proposed resolution

  1. Fix the PHP notice.
  2. Add a regression (kernel) test to ensure that this bug does not reappear in the future.

Notes

  • There are no PHP/backend tests for #states right now, because the "functionality" on the PHP side is in essence just a json_encode(), so nothing worth to test.

Remaining tasks

  • Make sure patch applies to 8.5.x and 8.6.x as well.
  • Write an unit (kernel) test to ensure that the bug does not reappear in the future.

User interface changes

No.

API changes

No.

Data model changes

No

Replace all calls to db_query, which is deprecated

$
0
0

Postponed on:

See #2848161: [meta] Replace calls to deprecated db_*() wrappers.

Replace all usages of db_query in core, except in code that is testing db_query.

Steps to create scripted patch:

  • Script to do the majority of the work
    # Replace the occurrences in code.
    find ./core/lib -type f -exec sed -i -r 's/db_query\(/Database::getConnection\()->query\(/g;' {} \;
    find ./core/tests -type f -not -path "./core/tests/Drupal/KernelTests/Core/Database/*" -exec sed -i -r 's/db_query\(/Database::getConnection\()->query\(/g;' {} \;
    find ./core/tests/Drupal/KernelTests/Core/Database -type f -not -path "./core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php" -not -path "./core/tests/Drupal/KernelTests/Core/Database/QueryTest.php" -exec sed -i -r 's/db_query\(/$this->connection->query\(/g;' {} \;
    find ./core/modules -type f -exec sed -i -r 's/db_query\(/Database::getConnection\()->query\(/g;' {} \;
    find ./core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php -type f -exec sed -i -r "s/call_user_func_array\('db_query'/call_user_func_array\([\$this->connection, 'query']/g;" {} \;
    find ./core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php -type f -exec sed -i -r 's/db_query\(/Database::getConnection\()->query\(/g;' {} \;
    find ./core/includes/form.inc -type f -exec sed -i -r 's/db_query\(/Database::getConnection\()->query\(/g;' {} \;
    find ./core/scripts/ -type f -exec sed -i -r 's/db_query\(/\\Drupal::database\()->query\(/g;' {} \;
    # Start using \Drupal::database() or inject service
    find ./core/modules/tracker -type f -exec sed -i -r 's/Database::getConnection\(/\\Drupal::database\(/g;' {} \;
    
  • The files that requires to manually add use Drupal\Core\Database\Database; row. See interdiff at #26
  • Fix the replacements in the comments. See interdiff #27

Allow Tours to be taken by users that cannot access the Toolbar (e.g. anonymous users)

$
0
0

Problem/Motivation

Anonymous users cannot start Tours. Currently Tours can only be started by clicking a button in the toolbar, and typically anonymous users have no permission to access the toolbar.

Proposed resolution

Provide a block with a button to start a Tour. This block can then be freely placed anywhere in the website.

How to test

  1. Grant permission to access tours and the views UI (lol) to the authenticated and/or anonymous user role.
  2. Place the block in the sidebar.
  3. Log in as a test user and visit admin/structure/views.
  4. Click on a view to access it.
  5. Click the tour button in the sidebar.
  6. Or visit ie http://drupal.d8/admin/structure/views/view/frontpage?tour=1 (as both authenticated or anonymous

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Original report by clemens.tolboom

As the tour icon is only available on the Toolbar anonymous users must get access to the Tour icon.

Without the 'Use the administration toolbar' the tour code is not loaded on the page so even an auto start like http://drupal.d8/?tour=1 fails.

Having the toolbar enabled the user get an access denied for the 'Menu' button.

Failure with media_library during core update from 8.6.15 to 8.7.0/1 failed

$
0
0

HI,

Sorry if I don't report the right way, I do this for the first time!

Since the 8.7 release, I tried to update my site from 8.6.15 to 8.7.0 and now to 8.7.1 : both failed with this error message:

module media_library
Mise à jour #8701

Échec : Drupal\Core\Entity\EntityStorageException : 'image_style' entity with ID 'media_library' already exists. dans Drupal\Core\Entity\EntityStorageBase->doPreSave() (ligne 481 de D:\Site\d8_sc\core\lib\Drupal\Core\Entity\EntityStorageBase.php).

And the report log has two update type error messages:

LogicException : Getting the base fields is not supported for entity type Style d'image. dans Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() (ligne 209 de D:\Site\d8_sc\core\lib\Drupal\Core\Entity\EntityFieldManager.php).
Importance Erreur

Drupal\Core\Entity\EntityStorageException : 'image_style' entity with ID 'media_library' already exists. dans Drupal\Core\Entity\EntityStorageBase->doPreSave() (ligne 481 de D:\Site\d8_sc\core\lib\Drupal\Core\Entity\EntityStorageBase.php).

Note that I do have an image style named media_library, but even if I rename its machine name as media_library_custom, when I run the update it doesn't work better.

My site is not broken and the core is marked as updated, but some features (as media widget) don't work as they should, and when I try to re-run …/update.php, it appears that 16 core module updates are waiting to be executed:

16 mises à jour en attente
system module

Initialize 'expand_all_items' values to system_menu_block.
Clear the menu cache. @see https:www.drupal.orgprojectdrupalissues3044364
Clear the library cache and ensure aggregate files are regenerated.

media_library module

8701 - Create the 'media_library' image style.
8702 - Updates the media library view widget display (contextual) filters.
Create and configure Media Library form and view displays for media types.
Add a table display to the media library view and link gridtable displays.

comment module

Add comment settings.

layout_discovery module

Recalculate dependencies for the entity_form_display entity.
Recalculate dependencies for the entity_view_display entity.

media module

Keep media items viewable at media{id}.

menu_link_content module

Update custom menu links to be revisionable.

taxonomy module

Update taxonomy terms to be revisionable.
Remove the 'hierarchy' property from vocabularies.

views module

Update exposed filter blocks label display to be disabled.
Rebuild cache to allow placeholder texts to be translatable.

My site is installed locally with Acquia Dev Desktop. I use drush but not Composer.
I'm no coder AT ALL, so I haven't a clue about what can be done to fix this, but it's been a while since I get repeatedly the first error message (LogicException : Getting the base fields is not supported for entity type) anytime I make a change on a field (changes are generally made despite the message though), so clearly something has been corrupted in the code (or the database?) but I was unable to determine where this was coming from since I don't mess with code and only use those community modules:

D:\Site\d8_sc>drush pm-list
 Package              Name                                                         Type    Status         Version       
 Administration       Admin Toolbar (admin_toolbar)                                Module  Enabled        8.x-1.26      
 Administration       Admin Toolbar Extra Tools (admin_toolbar_tools)              Module  Not installed  8.x-1.26      
 Administration       Admin Toolbar Links Access Filter                            Module  Not installed  8.x-1.26      
                      (admin_toolbar_links_access_filter)                                                               
 Administration       Adminimal Admin Toolbar (adminimal_admin_toolbar)            Module  Enabled        8.x-1.9       
 Administration       Module Missing Message Fixer (module_missing_message_fixer)  Module  Not installed  8.x-1.0-alpha 
                                                                                                          3             
 Bootstrap            Bootstrap Library (bootstrap_library)                        Module  Enabled        8.x-1.11      
 Chaos tool suite     Chaos Tools (ctools)                                         Module  Enabled        8.x-3.2       
 Chaos tool suite     Chaos Tools Blocks (ctools_block)                            Module  Not installed  8.x-3.2       
 (Experimental)                                                                                                         
 Chaos tool suite     Chaos Tools Views (ctools_views)                             Module  Not installed  8.x-3.2       
 (Experimental)                                                                                                         
 CKEditor             CKEditor CodeMirror (ckeditor_codemirror)                    Module  Enabled        8.x-2.2       
 CKEditor             CKEditor InsertHTML (ckeditor_inserthtml)                    Module  Not installed  8.x-1.0       
 CKEditor             CKEditor Non-breaking space Plugin (nbsp)                    Module  Enabled        8.x-1.2       
 Content Type Clone   Content Type Clone (content_type_clone)                      Module  Enabled        8.x-1.x-dev   
 Core                 Actions (action)                                             Module  Not installed  8.7.1         
 Core                 Activity Tracker (tracker)                                   Module  Not installed  8.7.1         
 Core                 Aggregator (aggregator)                                      Module  Not installed  8.7.1         
 Core                 Automated Cron (automated_cron)                              Module  Enabled        8.7.1         
 Core                 Ban (ban)                                                    Module  Not installed  8.7.1         
 Core                 BigPipe (big_pipe)                                           Module  Enabled        8.7.1         
 Core                 Block (block)                                                Module  Enabled        8.7.1         
 Core                 Book (book)                                                  Module  Enabled        8.7.1         
 Core                 Breakpoint (breakpoint)                                      Module  Enabled        8.7.1         
 Core                 CKEditor (ckeditor)                                          Module  Enabled        8.7.1         
 Core                 Color (color)                                                Module  Enabled        8.7.1         
 Core                 Comment (comment)                                            Module  Enabled        8.7.1         
 Core                 Configuration Manager (config)                               Module  Enabled        8.7.1         
 Core                 Contact (contact)                                            Module  Enabled        8.7.1         
 Core                 Content Moderation (content_moderation)                      Module  Not installed  8.7.1         
 Core                 Contextual Links (contextual)                                Module  Enabled        8.7.1         
 Core                 Custom Block (block_content)                                 Module  Enabled        8.7.1         
 Core                 Custom Menu Links (menu_link_content)                        Module  Enabled        8.7.1         
 Core                 Database Logging (dblog)                                     Module  Enabled        8.7.1         
 Core                 Field (field)                                                Module  Enabled        8.7.1         
 Core                 Field UI (field_ui)                                          Module  Enabled        8.7.1         
 Core                 Filter (filter)                                              Module  Enabled        8.7.1         
 Core                 Forum (forum)                                                Module  Not installed  8.7.1         
 Core                 Help (help)                                                  Module  Enabled        8.7.1         
 Core                 History (history)                                            Module  Enabled        8.7.1         
 Core                 Inline Form Errors (inline_form_errors)                      Module  Not installed  8.7.1         
 Core                 Internal Dynamic Page Cache (dynamic_page_cache)             Module  Enabled        8.7.1         
 Core                 Internal Page Cache (page_cache)                             Module  Enabled        8.7.1         
 Core                 Layout Builder (layout_builder)                              Module  Not installed  8.7.1         
 Core                 Layout Discovery (layout_discovery)                          Module  Enabled        8.7.1         
 Core                 Media (media)                                                Module  Enabled        8.7.1         
 Core                 Menu UI (menu_ui)                                            Module  Enabled        8.7.1         
 Core                 Node (node)                                                  Module  Enabled        8.7.1         
 Core                 Path (path)                                                  Module  Enabled        8.7.1         
 Core                 Quick Edit (quickedit)                                       Module  Enabled        8.7.1         
 Core                 RDF (rdf)                                                    Module  Enabled        8.7.1         
 Core                 Responsive Image (responsive_image)                          Module  Enabled        8.7.1         
 Core                 Search (search)                                              Module  Enabled        8.7.1         
 Core                 Settings Tray (settings_tray)                                Module  Enabled        8.7.1         
 Core                 Shortcut (shortcut)                                          Module  Enabled        8.7.1         
 Core                 Statistics (statistics)                                      Module  Not installed  8.7.1         
 Core                 Syslog (syslog)                                              Module  Enabled        8.7.1         
 Core                 System (system)                                              Module  Enabled        8.7.1         
 Core                 Taxonomy (taxonomy)                                          Module  Enabled        8.7.1         
 Core                 Testing (simpletest)                                         Module  Not installed  8.7.1         
 Core                 Text Editor (editor)                                         Module  Enabled        8.7.1         
 Core                 Toolbar (toolbar)                                            Module  Enabled        8.7.1         
 Core                 Tour (tour)                                                  Module  Enabled        8.7.1         
 Core                 Update Manager (update)                                      Module  Enabled        8.7.1         
 Core                 User (user)                                                  Module  Enabled        8.7.1         
 Core                 Views (views)                                                Module  Enabled        8.7.1         
 Core                 Views UI (views_ui)                                          Module  Enabled        8.7.1         
 Core                 Workflows (workflows)                                        Module  Not installed  8.7.1         
 Core (Experimental)  Field Layout (field_layout)                                  Module  Not installed  8.7.1         
 Core (Experimental)  Media library (media_library)                                Module  Enabled        8.7.1         
 Core (Experimental)  Migrate Drupal Multilingual (migrate_drupal_multilingual)    Module  Not installed  8.7.1         
 Core (Experimental)  Workspaces (workspaces)                                      Module  Not installed  8.7.1         
 Custom               Linkit (linkit)                                              Module  Enabled        8.x-4.3       
 Date                 Year only (yearonly)                                         Module  Enabled        8.x-1.3       
 Date/Time            Calendar (calendar)                                          Module  Enabled        8.x-1.x-dev   
 Date/Time            Calendar Datetime (calendar_datetime)                        Module  Enabled        8.x-1.x-dev   
 Date/Time            Date range formatter (date_range_formatter)                  Module  Enabled        8.x-3.1       
 Development          Devel (devel)                                                Module  Enabled        8.x-2.1       
 Development          Devel Generate (devel_generate)                              Module  Enabled        8.x-2.1       
 Development          Devel Kint (kint)                                            Module  Enabled        8.x-2.1       
 Development          Web Profiler (webprofiler)                                   Module  Not installed  8.x-2.1       
 Display Suite        Display Suite (ds)                                           Module  Not installed  8.x-3.1       
 Display Suite        Display Suite Devel (ds_devel)                               Module  Not installed  8.x-3.1       
 Display Suite        Display Suite Extras (ds_extras)                             Module  Not installed  8.x-3.1       
 Display Suite        Display Suite Switch View Mode (ds_switch_view_mode)         Module  Not installed  8.x-3.1       
 Entity               Automatic Entity Labels (auto_entitylabel)                   Module  Enabled        8.x-2.1-beta1 
 Examples             Migrate Example (migrate_example)                            Module  Not installed  8.x-4.2       
 Examples             Migrate Example (Advanced) (migrate_example_advanced)        Module  Not installed  8.x-4.2       
 Examples             Migrate JSON Example (migrate_json_example)                  Module  Not installed  8.x-4.2       
 Examples             Views Bulk Operations example                                Module  Not installed  8.x-2.5       
                      (views_bulk_operations_example)                                                                   
 Feeds                Feeds (feeds)                                                Module  Enabled        8.x-3.0-alpha 
                                                                                                          5             
 Field Formatters     Field Formatter Class (field_formatter_class)                Module  Enabled        8.x-1.1       
 Field types          Date time day (date_time_day)                                Module  Not installed  8.x-1.4       
 Field types          Datetime (datetime)                                          Module  Enabled        8.7.1         
 Field types          Datetime Range (datetime_range)                              Module  Enabled        8.7.1         
 Field types          Entity Reference Display (entity_reference_display)          Module  Enabled        8.x-1.2       
 Field types          Entity Reference Revisions (entity_reference_revisions)      Module  Enabled        8.x-1.6       
 Field types          File (file)                                                  Module  Enabled        8.7.1         
 Field types          Image (image)                                                Module  Enabled        8.7.1         
 Field types          Link (link)                                                  Module  Enabled        8.7.1         
 Field types          Options (options)                                            Module  Enabled        8.7.1         
 Field types          Simple Google Maps (simple_gmap)                             Module  Enabled        8.x-1.4       
 Field types          Telephone (telephone)                                        Module  Enabled        8.7.1         
 Field types          Text (text)                                                  Module  Enabled        8.7.1         
 Field types          Time Field (time_field)                                      Module  Enabled        8.x-1.12      
 Field types          Time Range (time_range)                                      Module  Enabled        8.x-1.1       
 Fields               Element class formatter (element_class_formatter)            Module  Enabled        8.x-1.0       
 Fields               Field Group (field_group)                                    Module  Enabled        8.x-3.0-beta1 
 Fields               Heading (heading)                                            Module  Enabled        8.x-1.4       
 Fields               Inline Entity Form (inline_entity_form)                      Module  Enabled        8.x-1.0-rc1   
 Filters              Entity Embed (entity_embed)                                  Module  Enabled        8.x-1.0-beta3 
 Media                Crop API (crop)                                              Module  Enabled        8.x-1.5       
 Media                Entity Browser (entity_browser)                              Module  Enabled        8.x-2.1       
 Media                Entity Browser example (entity_browser_example)              Module  Not installed  8.x-2.1       
 Media                Entity Browser IEF (entity_browser_entity_form)              Module  Not installed  8.x-2.1       
 Media                ImageWidgetCrop (image_widget_crop)                          Module  Enabled        8.x-2.2       
 Media                ImageWidgetCrop examples (image_widget_crop_examples)        Module  Enabled        8.x-2.2       
 Migrate              Field Group Migrate (field_group_migrate)                    Module  Not installed  8.x-3.0-beta1 
 Migration            Migrate (migrate)                                            Module  Enabled        8.7.1         
 Migration            Migrate Drupal (migrate_drupal)                              Module  Not installed  8.7.1         
 Migration            Migrate Drupal UI (migrate_drupal_ui)                        Module  Not installed  8.7.1         
 Migration            Migrate Plus (migrate_plus)                                  Module  Enabled        8.x-4.2       
 Migration            Migrate Source CSV (migrate_source_csv)                      Module  Enabled        8.x-2.2       
 Migration            Migrate Tools (migrate_tools)                                Module  Enabled        8.x-4.1       
 Multilingual         Configuration Translation (config_translation)               Module  Not installed  8.7.1         
 Multilingual         Content Translation (content_translation)                    Module  Enabled        8.7.1         
 Multilingual         Interface Translation (locale)                               Module  Enabled        8.7.1         
 Multilingual         Language (language)                                          Module  Enabled        8.7.1         
 Other                Allowed Formats (allowed_formats)                            Module  Enabled        8.x-1.1       
 Other                Bootstrap DateTime Picker (bootstrap_datetime)               Module  Enabled        8.x-1.2       
 Other                Configuration Update Base (config_update)                    Module  Enabled        8.x-1.6       
 Other                Configuration Update Reports (config_update_ui)              Module  Enabled        8.x-1.6       
 Other                Content Import (contentimport)                               Module  Not installed  8.x-4.x-dev   
 Other                Embed (embed)                                                Module  Enabled        8.x-1.0       
 Other                Entity Mask (ctools_entity_mask)                             Module  Not installed  8.x-3.2       
 Other                Entity Type Clone (entity_type_clone)                        Module  Enabled        8.x-1.3       
 Other                Entity Usage (entity_usage)                                  Module  Enabled        8.x-2.0-alpha 
                                                                                                          8             
 Other                Libraries (libraries)                                        Module  Not installed  8.x-3.0-alpha 
                                                                                                          1             
 Other                Linked Field (linked_field)                                  Module  Enabled        8.x-1.1       
 Other                Menu Block (menu_block)                                      Module  Enabled        8.x-1.5       
 Other                Menu Trail By Path (menu_trail_by_path)                      Module  Enabled        8.x-1.1       
 Other                Meta position (meta_position)                                Module  Enabled        8.x-1.0       
 Other                Pathauto (pathauto)                                          Module  Enabled        8.x-1.4       
 Other                Publication Date (publication_date)                          Module  Enabled        8.x-2.0-beta1 
 Other                Simple timeline (simple_timeline)                            Module  Enabled        8.x-1.1       
 Other                Single Date Time Picker (single_datetime)                    Module  Not installed  8.x-1.6       
 Other                Taxonomy unique (taxonomy_unique)                            Module  Not installed  8.x-2.1       
 Other                Telephone Validation (telephone_validation)                  Module  Not installed  8.x-2.2       
 Other                Token (token)                                                Module  Enabled        8.x-1.5       
 Paragraphs           Bootstrap Paragraphs (bootstrap_paragraphs)                  Module  Enabled        8.x-2.0-beta6 
 Paragraphs           Bootstrap Paragraphs Contact Form (bp_contact)               Module  Not installed  8.x-2.0-beta6 
 Paragraphs           Bootstrap Paragraphs Webform (bp_webform)                    Module  Not installed  8.x-2.0-beta6 
 Paragraphs           Paragraphs (paragraphs)                                      Module  Enabled        8.x-1.8       
 Paragraphs           Paragraphs Demo (paragraphs_demo)                            Module  Not installed  8.x-1.8       
 Paragraphs           Paragraphs Library (paragraphs_library)                      Module  Enabled        8.x-1.8       
 Paragraphs           Paragraphs Type Permissions (paragraphs_type_permissions)    Module  Enabled        8.x-1.8       
 Search               Database Search (search_api_db)                              Module  Not installed  8.x-1.11      
 Search               Database Search Defaults (search_api_db_defaults)            Module  Not installed  8.x-1.11      
 Search               Search API (search_api)                                      Module  Not installed  8.x-1.11      
 User interface       Accordion Menus (accordion_menus)                            Module  Not installed  8.x-2.0       
 User interface       Superfish (superfish)                                        Module  Not installed  8.x-1.3       
 Views                Views Bootstrap (views_bootstrap)                            Module  Enabled        8.x-4.1       
 Views                Views Bulk Operations (views_bulk_operations)                Module  Enabled        8.x-2.5       
 Views                Views Reference Field (viewsreference)                       Module  Enabled        8.x-1.4       
 Views                Views Slideshow (views_slideshow)                            Module  Enabled        8.x-4.6       
 Views                Views Slideshow Cycle (views_slideshow_cycle)                Module  Enabled        8.x-4.6       
 Views                Views templates (views_templates)                            Module  Enabled        8.x-1.0-alpha 
                                                                                                          1             
 Views Bulk           Actions Permissions (actions_permissions)                    Module  Not installed  8.x-2.5       
 Operations                                                                                                             
 Views Bulk           Views Bulk Edit (views_bulk_edit)                            Module  Enabled        8.x-2.2       
 Operations                                                                                                             
 Web services         HAL (hal)                                                    Module  Not installed  8.7.1         
 Web services         HTTP Basic Authentication (basic_auth)                       Module  Not installed  8.7.1         
 Web services         JSON:API (jsonapi)                                           Module  Not installed  8.7.1         
 Web services         RESTful Web Services (rest)                                  Module  Enabled        8.7.1         
 Web services         Serialization (serialization)                                Module  Enabled        8.7.1         
 Webform              Webform (webform)                                            Module  Enabled        8.x-5.2       
 Webform              Webform Access (webform_access)                              Module  Not installed  8.x-5.2       
 Webform              Webform Attachment (webform_attachment)                      Module  Not installed  8.x-5.2       
 Webform              Webform Bootstrap (webform_bootstrap)                        Module  Not installed  8.x-5.2       
 Webform              Webform Devel (webform_devel)                                Module  Not installed  8.x-5.2       
 Webform              Webform Image Select (webform_image_select)                  Module  Not installed  8.x-5.2       
 Webform              Webform Node (webform_node)                                  Module  Not installed  8.x-5.2       
 Webform              Webform Scheduled Email Handler (webform_scheduled_email)    Module  Not installed  8.x-5.2       
 Webform              Webform Shortcuts (webform_shortcuts)                        Module  Not installed  8.x-5.2       
 Webform              Webform Submission Export/Import [EXPERIMENTAL]              Module  Not installed  8.x-5.2       
                      (webform_submission_export_import)                                                                
 Webform              Webform Submission Log (webform_submission_log)              Module  Not installed  8.x-5.2       
 Webform              Webform Templates (webform_templates)                        Module  Not installed  8.x-5.2       
 Webform              Webform UI (webform_ui)                                      Module  Enabled        8.x-5.2       
 Webform Demo         Webform Demo: Application/Evaluation System                  Module  Not installed  8.x-5.2       
                      (webform_demo_application_evaluation)                                                             
 Webform Demo         Webform Demo: Event Registration System                      Module  Not installed  8.x-5.2       
                      (webform_demo_event_registration)                                                                 
 Webform Demo         Webform Demo: Region Contact System                          Module  Not installed  8.x-5.2       
                      (webform_demo_region_contact)                                                                     
 Webform example      Webform Element Example (webform_example_element)            Module  Not installed  8.x-5.2       
 Webform example      Webform Example Composite (webform_example_composite)        Module  Not installed  8.x-5.2       
 Webform example      Webform Examples (webform_examples)                          Module  Not installed  8.x-5.2       
 Webform example      Webform Examples Accessibility                               Module  Not installed  8.x-5.2       
                      (webform_examples_accessibility)                                                                  
 Webform example      Webform Handler Example (webform_example_handler)            Module  Not installed  8.x-5.2       
 Webform example      Webform Remote Post Example (webform_example_remote_post)    Module  Not installed  8.x-5.2       
 Autre                Adminimal (adminimal_theme)                                  Theme   Enabled        8.x-1.4       
 Autre                Bootstrap Barrio (bootstrap_barrio)                          Theme   Enabled        8.x-4.17      
 Autre                Bootstrap Barrio SASS SC Subtheme (bootstrap_sass_sc)        Theme   Disabled       8.x-1.6       
 Autre                Bootstrap Barrio SC Custom Subtheme (barrio_sc)              Theme   Enabled        8.x-4.17      

Thanks for your help.

PATCH 405 for untranslatable conent entities with different default language than English

$
0
0

Hi, folks look like I having problems since #3038308: Avoid translations DELETE data loss and unintended changes with PATCH and test all methods against entity route parameter translation upcasting.

I can't PATCH my custom content entity since I updated module 2.3.0 => 2.4.0.

I have a custom content entity type, which is not translatable. The site is installed on different from the English language.

For example I send this request:

{
   "data":{
      "attributes":{
         "due_date":"2019-03-02"
      },
      "id":"d38dc101-4c91-4522-a0c6-56e86a660802",
      "type":"scrm-issue--scrm-issue"
   }
}

And got this response:

{
   "jsonapi":{
      "version":"1.0",
      "meta":{
         "links":{
            "self":{
               "href":"http:\/\/jsonapi.org\/format\/1.0\/"
            }
         }
      }
   },
   "errors":[
      {
         "title":"Method Not Allowed",
         "status":"405",
         "detail":"The requested translation of the resource object does not exist, instead modify one of the translations that do exist: und.",
         "links":{
            "via":{
               "href":"http:\/\/scrm.localhost\/jsonapi\/scrm_issue\/scrm_issue\/d38dc101-4c91-4522-a0c6-56e86a660802"
            },
            "info":{
               "href":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.4.6"
            }
         },
         "source":{
            "file":"\/var\/www\/html\/web\/modules\/contrib\/jsonapi\/src\/ParamConverter\/EntityUuidConverter.php",
            "line":78
         },
         "meta":{
            "exception":"Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException: The requested translation of the resource object does not exist, instead modify one of the translations that do exist: und. in \/var\/www\/html\/web\/modules\/contrib\/jsonapi\/src\/ParamConverter\/EntityUuidConverter.php:78\nStack trace:\n#0 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/ParamConverter\/ParamConverterManager.php(100): Drupal\\jsonapi\\ParamConverter\\EntityUuidConverter-\u003Econvert(\u0027d38dc101-4c91-4...\u0027, Array, \u0027entity\u0027, Array)\n#1 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Enhancer\/ParamConversionEnhancer.php(45): Drupal\\Core\\ParamConverter\\ParamConverterManager-\u003Econvert(Array)\n#2 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Router.php(260): Drupal\\Core\\Routing\\Enhancer\\ParamConversionEnhancer-\u003Eenhance(Array, Object(Symfony\\Component\\HttpFoundation\\Request))\n#3 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Router.php(131): Drupal\\Core\\Routing\\Router-\u003EapplyRouteEnhancers(Array, Object(Symfony\\Component\\HttpFoundation\\Request))\n#4 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/AccessAwareRouter.php(92): Drupal\\Core\\Routing\\Router-\u003EmatchRequest(Object(Symfony\\Component\\HttpFoundation\\Request))\n#5 \/var\/www\/html\/vendor\/symfony\/http-kernel\/EventListener\/RouterListener.php(115): Drupal\\Core\\Routing\\AccessAwareRouter-\u003EmatchRequest(Object(Symfony\\Component\\HttpFoundation\\Request))\n#6 [internal function]: Symfony\\Component\\HttpKernel\\EventListener\\RouterListener-\u003EonKernelRequest(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent), \u0027kernel.request\u0027, Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#7 \/var\/www\/html\/web\/core\/lib\/Drupal\/Component\/EventDispatcher\/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent), \u0027kernel.request\u0027, Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#8 \/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php(127): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher-\u003Edispatch(\u0027kernel.request\u0027, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))\n#9 \/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel-\u003EhandleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#10 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#11 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#12 \/var\/www\/html\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(99): Drupal\\Core\\StackMiddleware\\KernelPreHandle-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#13 \/var\/www\/html\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(78): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Epass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#14 \/var\/www\/html\/web\/modules\/contrib\/jsonapi\/src\/StackMiddleware\/FormatSetter.php(45): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#15 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/ReverseProxyMiddleware.php(47): Drupal\\jsonapi\\StackMiddleware\\FormatSetter-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#16 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#17 \/var\/www\/html\/vendor\/stack\/builder\/src\/Stack\/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#18 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/DrupalKernel.php(693): Stack\\StackedHttpKernel-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#19 \/var\/www\/html\/web\/index.php(19): Drupal\\Core\\DrupalKernel-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#20 {main}",
            "trace":[
               {
                  "file":"\/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/ParamConverter\/ParamConverterManager.php",
                  "line":100,
                  "function":"convert",
                  "class":"Drupal\\jsonapi\\ParamConverter\\EntityUuidConverter",
                  "type":"-\u003E",
                  "args":[
                     "d38dc101-4c91-4522-a0c6-56e86a660802",
                     {
                        "type":"entity:scrm_issue",
                        "converter":"paramconverter.jsonapi.entity_uuid"
                     },
                     "entity",
                     {
                        "_controller":"jsonapi.entity_resource:patchIndividual",
                        "resource_type":"scrm_issue--scrm_issue",
                        "_is_jsonapi":true,
                        "entity":"d38dc101-4c91-4522-a0c6-56e86a660802",
                        "_route":"jsonapi.scrm_issue--scrm_issue.individual.patch",
                        "_route_object":{

                        },
                        "_raw_variables":{

                        }
                     }
                  ]
               },
               {
                  "file":"\/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Enhancer\/ParamConversionEnhancer.php",
                  "line":45,
                  "function":"convert",
                  "class":"Drupal\\Core\\ParamConverter\\ParamConverterManager",
                  "type":"-\u003E",
                  "args":[
                     {
                        "_controller":"jsonapi.entity_resource:patchIndividual",
                        "resource_type":"scrm_issue--scrm_issue",
                        "_is_jsonapi":true,
                        "entity":"d38dc101-4c91-4522-a0c6-56e86a660802",
                        "_route":"jsonapi.scrm_issue--scrm_issue.individual.patch",
                        "_route_object":{

                        },
                        "_raw_variables":{

                        }
                     }
                  ]
               },
…

Sorry for this big response code, but I want to provide full information.

All entities created via JSON:API or Drupal UI get und(?) langcode in JSON:API, but in fact, the default langcode for site is ru.

And I don't understand how to patch it correctly for now. Trying to add prefix /und/ and /ru/ to the URL of JSON:API, and they throw 404 error.

Incorrect data type for the expected parameter

$
0
0

Problem/Motivation

Incorrect data type for the $expected parameter.

 * @dataProvider providerFilterAttributes
 *
 * @param string $html
 *   Input HTML.
 * @param array $expected
 *   The expected output string.
 */
public function testfilterAttributes($html, $expected) {
  $this->assertSame($expected, $this->filter->filterAttributes($html));
}

/**
 * Provides data for testfilterAttributes.
 *
 * @return array
 *   An array of test data.
 */
public function providerFilterAttributes() {
  return [
    ['<a href="/blog" title="Blog">Blog</a>', '<a href="/blog">Blog</a>'],
    ['<p dir="rtl" />', '<p dir="rtl"></p>'],
    ['<p dir="bogus" />', '<p></p>'],

Proposed resolution

Should be a string.

Make DatabaseQueue::claimItem() easier to read

$
0
0

claimItem()'s docs say:

   *   On success we return an item object. If the queue is unable to claim an
   *   item it returns false. This implies a best effort to retrieve an item
   *   and either the queue is empty or there is some other non-recoverable
   *   problem.

However, it's possible to return NULL here:

    while (TRUE) {
      try {
        $item = $this->connection->queryRange('SELECT data, created, item_id FROM {' . static::TABLE_NAME . '} q WHERE expire = 0 AND name = :name ORDER BY created, item_id ASC', 0, 1, [':name' => $this->name])->fetchObject();
      }
      catch (\Exception $e) {
        $this->catchException($e);
        // If the table does not exist there are no items currently available to
        // claim.
        return FALSE;
      }
      if ($item) {
        *** get an item ***

        // Try to update the item. Only one thread can succeed in UPDATEing the
        // same row. We cannot rely on REQUEST_TIME because items might be
        // claimed by a single consumer which runs longer than 1 second. If we
        // continue to use REQUEST_TIME instead of the current time(), we steal
        // time from the lease, and will tend to reset items before the lease
        // should really expire.
        $update = $this->connection->update(static::TABLE_NAME)
          ->fields([
            'expire' => time() + $lease_time,
          ])
          ->condition('item_id', $item->item_id)
          ->condition('expire', 0);
        // If there are affected rows, this update succeeded.
        if ($update->execute()) {
          $item->data = unserialize($item->data);
          return $item;
        }

        *** fail to run the update query ***
      }
      else {
        // No items currently available to claim.
        return FALSE;
      }

     *** fall out of the if() block and end up here ***
     *** end of method returns NULL ***
    }

Therefore, there should be an else for the if ($update->execute()) block that returns FALSE.


REST views: pagination information and total count result

$
0
0

Problem/Motivation

Currently Views Rest Export does not add pagination information such as current page, total items, total pages and items per page.

A custom serializer could be easily created, but shouldn't the core serializer include this information?

I'm not sure if this should be a bug or feature request.

Proposed resolution

Include current page, total items, total pages and items per page to Views Rest Export.

Thanks.

Links to twig.sensiolabs.org are redirects: replace with its destination URLs 1.x version

$
0
0

Problem/Motivation

In #3050448: @see link in TwigNodeTrans docs is a 404 a link to twig.sensiolabs.org was replaced because it returned a 404. All URLs to twig.sensiolabs.org are currently redirects so so they could break at any time.

Proposed resolution

Replace links to twig.sensiolabs.org with its destination URL.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

Links to twig.sensiolabs.org are replaced with its destination URL.

API changes

None.

Data model changes

None.

Bartik has inconsistent .field__label styling, with unique attributes for .field--type-entity-reference and .field--name-field-tags only

$
0
0

Problem

Bartik sets a .field__label class only for .field--type-entity-reference and .field--name-field-tags. Instead it should inherit Classy's styling for those selectors as they are. (Currently on the field label of only these two fields, Bartik overrides the font-weight, lateral padding and font-size).

Steps to reproduce the problem

  1. On a Standard install profile content type (e.g. Article), create an entity reference field.
  2. Preserve the existing body field.
  3. Under Manage display of a Content type, set both field labels to display the same way, either Above or Inline.
  4. Create a node and add one word of content to each field.
  5. View the node and note the field labels display different styling.

Expected behavior

All field label(s) use the same styling.

Proposed fix

Remove all calls to the .field__label class from the Bartik css, allowing Bartik to inherit Classy styling on each field label.

Support for Paragraphs' ability to negate the entity reference selection

$
0
0

When using paragraphs or similar modules you have the possibility to negate the allowed entity reference bundles.

This is incompatible with jsonapi as it raised "field_xxx" is not a valid include".

It would be great if at least an error would be thrown as it took me 4 hours to find out why it fails :(

Screenshot attached of the entity reference settings.

Undefined index: region

$
0
0

I have and PHP Notice every time I open node (not bundle) layout settings.

Notice: Undefined index: region in Drupal\field_layout\FieldLayoutBuilder->buildForm() (line 109 of core/modules/field_layout/src/FieldLayoutBuilder.php).

And stackstrace:

Drupal\field_layout\FieldLayoutBuilder->buildForm(Array, Object) (Line: 64)
field_layout_form_alter(Array, Object, 'node_page_layout_builder_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_page_layout_builder_form') (Line: 835)
Drupal\Core\Form\FormBuilder->prepareForm('node_page_layout_builder_form', Array, Object) (Line: 29)
Drupal\webprofiler\Form\FormBuilderWrapper->prepareForm('node_page_layout_builder_form', Array, Object) (Line: 277)
Drupal\Core\Form\FormBuilder->buildForm('node_page_layout_builder_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
require('/var/www/drupal/app/index.php') (Line: 4)

I just created new node type and enable layout builder for it. Then I created a node with layout override.

My env:

Installation profile: Minimal (minimal-8.7.1)
Database updates: Up to date
Entity/field definitions: Up to date
PHP: 7.2.13
It's not clean drupal setup.

Disable responses validation if "zend.assertions !== 1"

$
0
0

The manual at https://www.drupal.org/node/2492225 instructs us that we have to skip some logic when assertions are disabled (ini_get('zend.assertions') < 0). Right now JSON:API validates every response because assert_options(ASSERT_ACTIVE) returns TRUE by default (https://www.php.net/manual/en/function.assert-options.php) and default settings.php does not have assert_options(ASSERT_ACTIVE, FALSE);.

Also, since Drupal 8.7.x is no longer support PHP 5 I propose to delete the PHP_MAJOR_VERSION >= 7 condition.

Unable to create page with "/media-library/some-path" path alias

$
0
0

Problem/Motivation

  1. Enable Media-library experimental module
  2. Create node type Page with path alias "/media-library/some-path"
  3. PHP Error appear

Proposed resolution

Seems when you have a path with many parts the Breadcrumb builder trying to check access for each part, but fails 'cause /media-library route requires additional query params on it. Right now route "media_library.ui" can't be used without query params, but instead of denying access on checking access by breadcrumb builder it throws an exception.

Remaining tasks

Check for query params before creating instance of \Drupal\media_library\MediaLibraryState in \Drupal\media_library\MediaLibraryState::fromRequest method. So probably we need to add exception to fromRequest() method

User interface changes

No interface changes.

API changes

Add an InvalidArgumentsException to \Drupal\media_library\MediaLibraryState::fromRequest()


Convert local absolute menu links to relative to enable access checking & site portability

$
0
0

Problem

As it stands, the menu system checks all menu paths pointing to internal links (ie, node/add or user/logout) upon submission to verify:

  1. The path exists in the menu system.
  2. The user has the proper permissions to access that path.

Furthermore, when a menu is being rendered, paths that the current user does not have access to are not rendered in the menu.

The problem begins when the user creates a menu item using an absolute URL pointing to an internal system path. For example, with Clean URLs, the user could create a menu item using the path 'http://www.example.com/admin'.

This avoids all the access checks that are made when the path is entered as an internal path.

The other problem is that the site is no longer portable as links will break when migrated between Dev, Staging and Prod environments (or the domain is changed entirely).

This has happened on several client's sites when they add menu items by surfing to the page they want to add, copying the URL from the address bar, then pasting into the menu form.

Proposed solution

I would suggest that when the menu system parses absolute URLs, it should check:

  1. Does the domain in the URL match the domain of the site?
  2. If so, is the path in the Drupal menu system?
  3. Convert the absolute URL to a relative one.
  4. If so, apply all access checks and controls similar to if the URL was entered as an internal path. This shouldn't be necessary because core now treats the URL as relative.

I am putting this on my list of 'bugs to fix'. However, I can't guarantee I will get around to it soon. If someone wants to take a crack at it, please, take ownership and tackle it. Chances are you are more familiar with the menu system than I am anyways!

Convert VocabularyCrudTest test to kernel test

$
0
0

Problem/Motivation

VocabularyCrudTest inherited from TaxonomyTestBase that involved in UI testing, but actually it testing CRUD so should be optimized.

Proposed resolution

Re-do on top of KernelTestBase

Remaining tasks

tbd

User interface changes

no

API changes

no

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue categoryBug because slows down testing for no reason
Issue priorityMajor because affects a whole core testing
Prioritized changesThe main goal of this issue is performance of core

Ajax replace does not refocus element if inside a dialog

$
0
0

Problem/Motivation

Drupal.Ajax.success attempts to set focus to the element that triggered the ajax request.

You can stop by adding the attribute data-disable-refocus to the element if another InvokeCommand is returned that sets focus.

This functionality is not actually tested anywhere and it does not work if the element is inside a dialog.
In #2995689: Allow reordering blocks without a pointer device it would be great if this worked because we are using an ajax element in dialog.

Proposed resolution

Make it work!

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Add bundle css class to custom block types

$
0
0

Problem/Motivation

For themers it is really important to distinguish the different block types.

Proposed resolution

Add a css class to blocks, which indicates which type is used.
For example: If you have a block type "Banner" then a css class "block--type-banner". I don't know the drupal css guidelines, so the classname is just a proposal.

Remaining tasks

[ ] Implement this

User interface changes

None

API changes

None

Data model changes

None

Should be a small fix with no breaking changes.

Not possible to change weight of node form field widget in hook_form_alter()

$
0
0

In a hook_form_alter() I have set the weight of one of the form fields:

$form['field_my_field']['#weight'] = 54;

And it was having no effect. I spent ages trying to debug this and eventually debugged the entire form build process and discovered that the weight was reverting back to the value set in in the CMS.

The culprit is /core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php

/**
 * Process callback: assigns weights and hides extra fields.
 *
 * @see \Drupal\Core\Entity\Entity\EntityFormDisplay::buildForm()
 */
public function processForm($element, FormStateInterface $form_state, $form) {
  // Assign the weights configured in the form display.
  foreach ($this->getComponents() as $name => $options) {
    if (isset($element[$name])) {
      $element[$name]['#weight'] = $options['weight'];
    }
  }

  // Hide extra fields.
  $extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle);
  $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : [];
  foreach ($extra_fields as $extra_field => $info) {
    if (!$this->getComponent($extra_field)) {
      $element[$extra_field]['#access'] = FALSE;
    }
  }
  return $element;
}

It resets all of the weights to the ones in the options.

This seems like a bug to me. Surely the process stage is the wrong time to be resetting all the weights. It means you overwrite anything that people do by altering the form. It's also very misleading because there are a huge amount of resources on the internet saying that you can change it there when you actually can't.

Or perhaps it should only set the weight if it hasn't already been set.

You can get around this by adding an #after_build and changing the weights there.

Viewing all 300222 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>