Quantcast
Viewing all 296340 articles
Browse latest View live

Allow the table mapping to be initialized from outside the storage

Problem/Motivation

Field storage and entity type CRUD operations (e.g. install a new field in an update function, delete an entity type in an update function, etc.) need the ability to initialize a table mapping "on demand", mostly because they need to work with the last installed definitions instead of the ones living in code.

This is currently done by switching the entity type definition in the storage itself just for the duration of the CRUD operation, which is a "documented hack" with tons of @todos saying "fix this in #2274017: Make SqlContentEntityStorage table mapping agnostic ".

Proposed resolution

- Move the table mapping initialization code from \Drupal\Core\Entity\Sql\SqlContentEntityStorage::getTableMapping to the table mapping itself.

- Make the table mapping aware of the entity table names, and also generate default table names if the entity type doesn't provide them, just like the storage does.

Remaining tasks

Review.

User interface changes

Nope.

API changes

Nope.

Data model changes

Nope.


Unexpected quote in workflow exception

I just noticed that the exception thrown in WorkflowTypeBase has a strange quote added to its end:

throw new \InvalidArgumentException("The state '$state_id' does not exist in workflow.'");

Seems like an artifact from changing from single quotes to double quotes.

Patch coming up

Not able to add MigrateSkipProcessException message

Properly deprecate SafeMarkup::format()

Problem/Motivation

The SafeMarkup::format() method has been deprecated since 8.0.0 but we didn't have deprecation testing then or a policy to add @trigger_error()

Proposed resolution

Add @trigger_error() and improve the tests to test this and remove core usages.

Script to do the majority of the work

# Replace the FQDN occurrences in comments.
find ./core -type f -not -path "./core/node_modules/*" -not -path "./core/assets/*" -not -path "./core/misc" -exec sed -i -r 's/\\Drupal\\Component\\Utility\\SafeMarkup::format(\(\))?/\\Drupal\\Component\\Render\\FormattableMarkup/g;' {} \;

# Replace the occurrences in code.
find ./core -type f -not -path "./core/node_modules/*" -not -path "./core/assets/*" -not -path "./core/misc" -exec sed -i -r 's/SafeMarkup::format\(/new FormattableMarkup\(/g;' {} \;

# Revert unnecessary changes
git co core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php

# Replace use statements in affected files.
git ls-files -m | xargs sed -i -r 's/use Drupal\\Component\\Utility\\SafeMarkup/use Drupal\\Component\\Render\\FormattableMarkup/g;'

# Apply the smaller post script issue patch from https://www.drupal.org/project/drupal/issues/2958429

Remaining tasks

User interface changes

None

API changes

None - this is already documented at https://www.drupal.org/node/2549395

Data model changes

None

Replace all remaining superglobals ($_GET, $_POST, $_REQUEST and $_FILES) with Symfony Request object

Problem/Motivation

Drupal should not be accessing $_GET, $_POST, $_REQUEST and $_FILES.

Proposed resolution

Use the Symfony request object. This is a follow up from #1998638: Replace almost all remaining superglobals ($_GET, $_POST, etc.) with Symfony Request object.
It will also add the rule added by #2958175: Add rule to prevent direct usage of $_GET, $_POST, $_REQUEST and $_FILES in Drupal 8 to our coding standards.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Relative URLs in cached feeds should be converted to absolute ones

Issue #88183: Relative URLs in feeds should be converted to absolute ones added a response subscriber (RssResponseRelativeUrlFilter) that converts relative URLs to absolute ones. It does this for any response that has the 'application/rss' Content-Type HTTP header.

However, that Content-Type HTTP header for feeds coming from views is set way down in template_preprocess_views_view_rss(), which means that information is not cached. Once such a feed (with its relative URLs) is in the render cache, that preprocess hook will not be called for subsequent requests, and so the default Content-Type header will be used, of 'text/html'. This is both wrong, and stops that RssResponseRelativeUrlFilter service from changing the URLs.

Patch on the way...

Define project dependencies in core module .info files

Problem/Motivation

The dependencies in *.info.yml files as a best practice should have the project specified https://www.drupal.org/node/2299747.

Currently Drupal core has a dependency on the Link project. This is because it specifies the link module as a dependency and projects with the same name as the module are preferred.

Currently the automated testing infrastructure (Project Dependency) assumes that Drupal core has no dependencies so the erroneous dependency on the Link project is ignored.

Image may be NSFW.
Clik here to view.

It is important for Drupal core to use best practices because contributed projects will follow the example set by core and specifying dependencies in an ambiguous manner may cause problems with automated testing. Also, if in the future Drupal core uses external dependencies it may not always be the case that Drupal core does not have dependencies.

Proposed resolution

Replace all dependencies that are not namespaced with their namespaced versions.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Taxonomy pages crash with layout_builder enabled

When the layout_builder module is enabled, trying to view a term page crashes with:

Drupal\Component\Plugin\Exception\ContextException: Assigned contexts were not satisfied: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 101 of /var/www/html/web/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).

Steps to reproduce

  1. Activate layout_builder
  2. Create a vocabulary and term
  3. View the term page

Use range for a numeric field

There is not yet a field formatter of type 'Range' as discussed on: https://www.drupal.org/project/drupal/issues/2332833

So I used hook_form_alter to add the 'Range' type, as instructed on Range API: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...

The field is rendered correctly as a slider. However, when I hit save, it returns this error:

Fatal error: Cannot unset string offsets in /core/lib/Drupal/Core/Field/WidgetBase.php on line 367

As the Range class is from Drupal core, I guess it should work seemlessly, isn't it?

display: block for details/summary hides drop arrows in Firefox (normalize.css update)

Problem/Motivation

In older versions of Firefox, details elements in the Seven theme in Drupal 8.x, such as on admin/config/system/site-information , looked like this screenshot -- the summary line (which is a link to open/close the details area) showed up in blue, with a little triangle open/close icon next to it:
Image may be NSFW.
Clik here to view.
Old screenshot of details element on admin/config/system/site-information

With current versions of Firefox, however, it isn't so nice. The summary line is black, and the open/close icon is missing:
Image may be NSFW.
Clik here to view.
New screenshot of details element on admin/config/system/site-information

This is a big usability problem. It's not obvious without the little arrow or the blue color that this is a link to open/close the box, at least to me.

Proposed resolution

After some debugging, the problem was traced to the normalize.css file [see original issue summary in first comment for details]. We are currently using a 3.x version of the Normalize library, and it has "summary" elements with display: block;. The current version of the Normalize library uses display: list-item; instead.

So, we need to either:
a) Update to the current version of normalize. This option was rejected by the core maintainers in comment #13, and has been moved to its own issue: #2821525: Update normalize.css to 7.0.0

b) Add a small bit of CSS to our normalize library to override display: block for summary elements. That is what is in the current patch.

Remaining tasks

a) [done] Figure out what to do [Make a small patch to add CSS to override that one piece of the normalize library].
b) [done] Make a patch.
c) Test the patch on multiple browsers:
- Firefox - works - tested in comment #20
- Chrome - works - tested in comment #22
- Safari - works - tested in comment #25

Novice task:

- Apply the patch on a local Drupal site. It doesn't really matter which version of Drupal you are using.
- Clear the cache.
- Visit a page like admin/config/system/site-information , using the current version of a browser that has not yet been tested (see Proposed Resolution section, above this in the issue summary).
- See if the summary lines on details elements are formatted correctly (with the drop-arrow) or not.
- Make a screenshot similar to the ones in comments #20 and #22.
- Add a comment telling which browser you tested, and upload your screenshot in the Files section.

User interface changes

Details elements on admin pages will again have the drop-down arrow applied to them in current versions of Firefox. Right now they don't and it's rather confusing UI.

API changes

None.

Data model changes

None.

Log message if skip_on_empty plugin skips on empty

Log message if migration_lookup skips on empty

Problem/Motivation

Continuing from https://www.drupal.org/project/drupal/issues/2951715#comment-12559059
Log message if migration_lookup skips on empty

core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php:248:      
throw new MigrateSkipProcessException();

And we have a blocker for this is
https://www.drupal.org/project/drupal/issues/2959125

Proposed resolution

Log a message to MigrateSkipRowException to clearly explain why the row is skipped.

Remaining tasks

User interface changes

API changes

Data model changes

Enable PHPCS for info.yml file

Problem/Motivation

Drupal's coder project has rules for .info.yml files but atm we can't use them because we're not scanning them. Let's fix that.

This will allow us to scan for #2798891: Define project dependencies in core module .info files.

Proposed resolution

Enable scanning of info.yml files.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Argument 1 passed to Drupal\Core\Config\Entity\ConfigEntityBase::calculatePluginDependencies() must implement interface Drupal\Component\Plugin\PluginInspectionInterface, null given, called in core/lib/Drupal/C

When creating a new custom field type, extend the class fileItem for the new custom field type.

Go to content type add custom field type created and save, the website encounters an error

TypeError: Argument 1 passed to Drupal\Core\Config\Entity\ConfigEntityBase::calculatePluginDependencies() must implement interface Drupal\Component\Plugin\PluginInspectionInterface, null given, called in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php on line 388 in core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php on line 27

Lock Sections in Layout Builder

Problem/Motivation

It would be nice to be able to a lock a section which means it cannot be deleted, rearranged or make any changes to its components(?)

Proposed resolution

Implement it somehow :)

Remaining tasks

Write a patch and review it.

User interface changes

Yes. Some way to lock and unlock sections.

API changes

Data model changes

Add a locked property to the Section class?


Installation profiles do not support project:module format for dependencies

In #2205271: Project namespace for dependencies support was added to allow modules to list dependencies by prefixing their names with their project name, thus solving the age-old problem of module names and project names being different (*cough* CCK *cough*). This API improvement was included in v7.40.

In #2844504: Testbot failing for Metatag-D7 =) it was identified that some of Metatag's tests were failing because the testci system was unable to download certain dependencies, specifically one submodule depending upon another submodule would fail if the dependency was listed in the old [module] syntax, it had to be listed in the newer [project:module] syntax.

It was reported in #2853699: Out-of-date dependency processing in panopoly_core by asacolips that this conflicts with installation profiles, which do not support the [project:module] syntax.

A simple example is the following:

  • Download the latest Panopoly distribution release.
  • Set it up somewhere so it can be installed.
  • Download Metatag into the directory structure somewhere, e.g. sites/all/modules.
  • Edit the panopoly.info file to list Metatag as a dependency, e.g.:
    diff --git a/panopoly.info b/panopoly.info
    index 2ee445e..2752de7 100644
    --- a/panopoly.info
    +++ b/panopoly.info
    @@ -21,6 +21,8 @@ dependencies[] = file
     dependencies[] = dblog
     dependencies[] = update
     
    +dependencies[] = metatag
    +
     ; Panopoly Foundation
     dependencies[] = panopoly_core
     dependencies[] = panopoly_images
    
  • Hook up the codebase to the local web server and try to run the installer.
  • The following requirements error will be reported:

    Required modules - Required modules not found.
    The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as sites/all/modules. Missing modules: Drupal:system, Ctools:ctools, Token:token

  • Further, if the dependency line in panopoly.info is changed to "dependencies[] = metatag:metatag" then the error becomes the following:

    Required modules - Required modules not found.
    The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as sites/all/modules. Missing modules: Metatag:metatag

It seems like the dependency logic does not properly handle the [project:module] logic for modules available in the current codebase.

Warning: file_get_contents(): Filename cannot be empty in _locale_parse_js_file() includes/locale.inc)

Warning: file_get_contents(): Filename cannot be empty in _locale_parse_js_file() includes/locale.inc)

backtrace:

file_get_contents('') locale.inc:1502
_locale_parse_js_file('https://maps.googleapis.com/maps/api/js?sensor=true') locale.module:917
locale_js_alter(Array, NULL, NULL, NULL) module.inc:1109
drupal_alter('js', Array) common.inc:4271
drupal_get_js('footer') theme.inc:2631
template_process_html(Array, 'html') theme.inc:1122
theme('html', Array) common.inc:5930
drupal_render(Array) common.inc:5777

Looking at the code I am not sure what is done with external js files like this.

the locale.inc file is:

function _locale_parse_js_file($filepath) {
  global $language;

  // The file path might contain a query string, so make sure we only use the
  // actual file.
  $parsed_url = drupal_parse_url($filepath);
  $filepath = drupal_realpath($parsed_url['path']);
  // Load the JavaScript file.

  $file = file_get_contents($filepath);

At https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_... api.drupal.org on drupal.parse.url states:
This function should only be used for URLs that have been generated by the system, such as via url(). It should not be used for URLs that come from external sources, or URLs that link to external resources.

Allow SystemMenuBlock tree manipulators to be altered

Problem/Motivation

At the moment every contrib module that needs to add/alter tree manipulators require to override Drupal\system\Plugin\Block\SystemMenuBlock (or implement their own).

The only possible solution for contrib now is to override block class via hook_block_alter() but when more then one module installed only last override wins.
This collisions affects following contrib modules:
- https://www.drupal.org/project/superfish
- https://www.drupal.org/project/menu_multilingual
- https://www.drupal.org/project/menu_block
- https://www.drupal.org/project/domain_entity to incorporate https://github.com/skilld-labs/domain_menu_access
- https://www.drupal.org/project/menu_per_role
- https://www.drupal.org/project/menu_item_visibility

Proposed resolution

Implement a new hook that allows menu tree manipulators to be altered.

Remaining tasks

- Decide on hook name - hook_system_menu_tree_manipulators_alter()
- File change record
- Commit

User interface changes

No

API additions

Adds hook_system_menu_tree_manipulators_alter to alter manipulators used in menu blocks

Data model changes

No

Fix \Drupal\Component\Utility\Unicode() because of the Symfony mbstring polyfill

Problem/Motivation

Drupal 8 includes Symfony's mbstring polyfill which means that core's Unicode library never using this the non mbstring code path. This makes the static set in Unicode::check() complete redundant and its default value wrong. This impacts unit and kernel testing as this then uses the non mbstring code path when no real site ever uses it.

Proposed resolution

  • Remove the status static from Unicode
  • Remove the non-mbstring code path from Unicode - it is never used
  • Remove the need to call Unicode::check to set anything
  • Fix bootstrap.php to normalise unit and kernel test environments
  • Fix Unicode::check() so that unicode_requirements() can actually recommend installing the mbstring extension

How to generate most of the patch

# Apply the smaller not tested issue patch from https://www.drupal.org/project/drupal/issues/2849669

# Replace the occurrances including FQDN. Check core/lib/Drupal/Core/Mail/MailFormatHelper.php.
find ./core -type f -not -path "./core/node_modules/*" -not -path "./core/assets/*" -not -path "./core/misc" -exec sed -i -r 's/\\?(Drupal\\Component\\Utility\\)?Unicode::(substr|strlen|strtoupper|strtolower|strpos)/mb_\2/g;' {} \;

# Revert unnecessary changes
git co core/lib/Drupal/Component/Utility/Unicode.php
git co core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php

# Fix unused uses
composer run-script phpcbf -- --sniffs=Drupal.Classes.UnusedUseStatement,PSR2.Namespaces.NamespaceDeclaration

# Apply the smaller not tested post script issue patch from https://www.drupal.org/project/drupal/issues/2849669

Remaining tasks

doit

User interface changes

none

API changes

Deprecate Unicode::setStatus() since this existed for testing purposes only and the static it sets is removed.

Data model changes

none

Original issue summary

Problem/Motivation

KernelTestBase does not provide an environment consistent with a booted DrupalKernel since the locale is not set and by default the use of mb string functions is disabled.

This has been manually worked around in some tests like \Drupal\Tests\token\Kernel\FieldTest::testTokenViewMode()

This was causing unexpected test fails for me when writing new core kernel tests that depend on Drupal correctly lowercasing unicode characters.

Proposed resolution

Copy this code from \Drupal\Core\DrupalKernel::bootEnvironment()
and add it to \Drupal\KernelTests\KernelTestBase::bootEnvironment()

    // Set sane locale settings, to ensure consistent string, dates, times and
    // numbers handling.
    setlocale(LC_ALL, 'C');

    // Detect string handling method.
    Unicode::check();

Non-translatable fields error when using: Content Moderation + Content Translation + Comments

Steps to reproduce:
1. Install Drupal 8.5.x (8.5.1 in this case, was working fine before 8.5)
2. enable Language, Content Translation, Content Moderation, and Workflows modules
3. add another language, like French
3. enable content translation on Basic Pages
4. add Default Comment field to Basic Pages (not via "Existing Fields")
5. add the Editorial workflow to Basic Pages
5. create an English Basic Page
6. translate that Basic Page and try to save

Expected behavior:
The node saves.

Current behavior:

You get an error saying "Non-translatable fields can only be changed when updating the original language."

Current Work-around:

Edit Baic Page Comment field and check the "Users may translate this field" checkbox. Now your Translation will save.

Issues:
* The error is not very clear and if your dealing with more than a few fields (like 50) this can take quite a while to debug
* Doing the above steps in a different order (say adding the comment field first, then enabling translation, or adding the existing Comment field) will not trigger the error as the checkbox get automatically ticked when following this order

Proposed Solutions:
(a) remove the "Users may translate this field requirement" for comment fields. After all, what does it mean that users can translate this field? It is not the ability to translate comments, or field meta-data like title and description. This field merely binds a type of comment to a type of node, right?
(b) Have a better error message telling users what field is the offender in the error message (or in Drupal logs)

Viewing all 296340 articles
Browse latest View live


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