Since twig/twig 3.9: Twig node "Drupal\Core\Template\TwigNodeTrans" is not marked as ready for using "yield" instead of "echo"; please make it ready and then flag it with the #[YieldReady] attribute.
Twig deprecations may break contrib tests. Can we backport this fix to Drupal 10.2?
@kim.pepper
Even if the extension is enabled the message `{"message":"Starting upload...","percentage":-1}` will still appear when no upload process is available.
The MR was apparently made for some other issue.
Re #9.
No need to check user input for each block category inside the loop. I think we could just wrap the entire loop into if statement.
if ($typed_category) {
foreach ($this->blockManager->getCategories() as $category) {
if (stripos($category, $typed_category) === 0) {
$matches[] = ['value' => $category, 'label' => Html::escape($category)];
}
}
}
@chanduvkp check out dblog after visiting that page.
Chi → created an issue.
Re #77
If we use event listeners instead of subscribers we could make use of PHP attributes as well.
AuthorFormatter might have save bug.
There are two points that need to be taken into considerations.
1. We live in epoch of "always green" browsers. Vendors continuously push new browser releases. It would be hard to manually evaluate available browsers each major release of Drupal.
2. There is a variety of chrome based browsers. We probably need to establish the support policy based on on the version of Chromium engine.
That was already mentioned in #7. I think the evaluation of browser adoption can be done through through browser list.
Patch #7 is not consistent with MySQL behavior as it uses zero as fallback value. I think if provided input value is not correct the SQL query should not return any results.
That attached patch fixes the issue for numeric filters. I think for numeric arguments it could be done same way.
There issue appears in many cases. The simplest way to reproduce is adding exposed filter to some int property (i.e. entity ID) and then try to submit it with a string value.
You need to pass additional data tot the drupal_token
function.
```
{{ drupal_token('node:title', {node}) }}
```
Make sure the node variable is available in your template.
@smustgrave you've been given all permissions to this project. If you are interested in taking ownership please create an issue
here →
.
Thank you.
The default value is 1
The default value may be set by Linux distributions or hosting providers. They don't know much about Drupal requirements.
If zend_assertions is set to prod mode, in php.ini this statement in .htaccess
+ php_value zend.assertions 0
causes the following warning in Apache error log
[php:warn] [pid 176] [client 172.29.0.254:50836] PHP Warning: zend.assertions may be completely enabled or disabled only in php.ini in Unknown on line
assert.active takes precedence over zend.assertions. Does it mean all tests running on Apache does not check for assertions? If so I would consider this as a bug.
As long as it has class level @internal
tag the whole class is considered as internal by static analyzers.
We might need to move the @internal
tag to particular methods in that class.
There is something wrong here. ExtensionList is marked as internal. We should not recommend using it in change records.
I doubt that it possible. Pagination is handled outside of views.
I don't know. By some reason your services container is not rebuilding. You need to figure it out.
You might need to clear opcache or restart your server.
Cache clear?
That needs steps to reproduce.
The change record recommends setting ini_set('zend.assertions', 1);
but that not gonna always work.
There is a note about that on php.net.
Note:
If a process is started in production mode, zend.assertions cannot be changed at runtime, since the code for assertions was not generated.
If a process is started in development mode, zend.assertions cannot be set to -1 at runtime.
Not sure what we can do here. Probably just recommend configuring it in php.ini file.
I have a module that does support this feature. It's not currently actively maintained but still working. It might be used for inspiration.
source()
just loads file content. It does not decode it. You need something like json_decode
.
See related issue for explanations.
For such case I would recommend loading data in preprocess hook. That should be trivial.
function example_preprocess(array $variables): void {
$json = \file_get_contents('public://test.json');
$variables['test'] = \json_decode($json);
}
drupal_loads_json()
That would just duplicate source
function from Twig core.
shows 75 requests/sec, with persistent connections enabled it shows 90 requests/sec
What Drupal does should be good enough
These two statements contradicts each other.
PostreSQL connection is relatively slow especially when SSL is enabled (that's done by default in many distributions). When page cache is enabled it may happened that ~80% of request time for anonymous visitors is spent on establishing DB connection.
I think it worth reopening.
Added formatting for boolean properties.
Thank you.
This needs a test to prove the issue.
Refactored a bit so when width or height attributes are given the image toolkit is not involved.
Thank you.
Drupal\twig_tweak\TwigExtension->imageStyle(NULL, 'card_image_134x160')
It's expected behavior because you did not pass the image path.
I think the duration needs to be rendered using time
tag.
alt is not required as it has default value which is empty string.
The alternative text could be easily set via attribute parameter.
{{ drupal_image('public://ocean.jpg', {alt: "The ocean"}) }}
If we add a dedicated parameter for alt
attribute then we have to do same for other attributes listed in image_theme()
- width
- height
- title
I think it's better just copy the values from attribute array to top level.
Something like this
$build['#alt'] = $attributes['alt'] ?? '';
Submitted a review. Thank you.
Looks great. Thank you.
The use case is kind of narrow. Only a few field types have support for prefix and suffix. Anyway I think it's a case for Twig Field Value → module as it seems more related to processing field values.
I guess it could be filters like this.
{{ content.field_name|field_prefix }}
{{ content.field_name|field_suffix }}
You can install whatever version of Twig Tweak compatible with your Drupal installation.
Looks good to me.
Chi → created an issue.
I've added data_uri
filter. It will be available in the next release. Thank you.
I wonder if this issue is specific to S3FS?
I think 🐛 drupal_image() needs #width / #height values for fully working image cache scale, lazy-loading and img attributes RTBC is not relevant as it has nothing to do with caching.
What's the point to call `drupalEntity` without entity ID?
it denies core upgrades to 10.1.x, 10.2.x
@e5sego, it does not. See note #2.
Actually, the version contraint to ^10.0 ist still in the module composer.json file.
@e5sego What's wrong with using ^10.0?
Use the option --with-all-dependencies (-W) to allow upgrades,
Have you tried this?
Composer is known for its pure description of dependency conflicts. Sometimes it's easier to just remove the package that you think is blocking update, then update what you need and install the package again.
Added support for collection permission.
With these logos it will be so easy to find a list of installed contrib modules on any Drupal site.
That project is not supported anymore.
This function now accepts external URLs as well.
Added an example of rendering block with context to Cheat Sheet.
Closing this issue as there is nothing doable here.
People keep struggling with passing contexts. I pushed the example to Cheat Sheet.
Thank you.
Given that the filter is just a few lines of code we could just copy it into Twig Tweak.
https://twig.symfony.com/doc/3.x/filters/data_uri.html
There is a data URI filter in Twig but it lives in a separate Twig extension. Twig Tweak could just register that extensions in Drupal.
I updated the documentation for drupal_field(). Thank you.
Tried to reproduce it locally. Everything worked as expected. The issue may happen with any module. You need to figure out why cache clear it not rebuilding service container on your Drupal instance.
Possible workaround is uninstalling Twig Tweak module just before running `composer update` command.
For EntityFormViewBuilder we have to add a $langcode parameter which would be a BC break. I postpone this change till the next major TT release.
Thank you.
@smustgrave, I think the parent issue is outdated. There was a big difference indeed in PHP 5 but in PHP 8 it works equally well.
Here is the script I used for testing.
const LIMIT = 10_000_000;
// -- (string)
$start = \microtime(true);
for($i = 0; $i < \LIMIT; $i++) {
$a = (string) $i;
}
$end = \microtime(true);
echo ' (string): ', \number_format(1_000 * ($end - $start), 2), ' ms', \PHP_EOL;
// -- strval
$start = \microtime(true);
for($i = 0; $i < \LIMIT; $i++) {
$b = \strval($i);
}
$end = \microtime(true);
echo ' strval: ', \number_format(1_000 * ($end - $start), 2), ' ms', \PHP_EOL;
// -- callback
$to_string = static fn ($value): string => (string) $value;
$start = \microtime(true);
for($i = 0; $i < \LIMIT; $i++) {
$c = $to_string($i);
}
$end = \microtime(true);
echo ' Callback: ', \number_format(1_000 * ($end - $start), 2), ' ms', \PHP_EOL;
Result (PHP 8.2):
(string): 190.62 ms
strval: 192.26 ms
Callback: 340.39 ms
The approach with custom caster works a way slower than strval
. But even if it would be faster, notice the absolute values. 179 milliseconds for 10 million iterations. It's not a micro-optimization nor even a nano-optimization. It's a pico-optimization. )
The access check parameter only applies to the entity being viewed. I this case it's a term from vocabulary B. It does not affect checking access for child entities (paragraphs). If it's not the case, please provide exact steps to reproduce. Preferably without involving contributed modules.
This is not a bug. The behavior is documented in Cheat Sheet and in \Drupal\twig_tweak\View\RegionViewBuilder::build(). Though I think switching to active theme as default value makes sense.
The remaining tasks.
1. Update documentation
2. Remove unused $configFactory dependency from RegionViewBuilder service.
The main concern here is BC break. We probably should postpone this change for the next major TT release.
Thank you.
Thank you.
Thank you.
The patch contains lots of irrelevant changes. Also I think the code with intval and strval callbacks is much more readable.
the time ago formatter limits the granularity to 6 by some reason
Created an issue. ✨ Increase max allowed granularity in Time ago formatter RTBC
The UI can be improved through formatter summary.
Have a look how it's done in "Time ago" formatter.
BTW, the time ago formatter limits the granularity to 6 by some reason.
Re #20. Seems so. BTW D7 Date module also offered a way to get duration.
https://git.drupalcode.org/project/date/-/blob/7.x-2.x/date.module?ref_t...
"Granularity" isn't super clear "How many different units to display in the range." doesn't help. This will need usability review probably got proper language.
That term is already used in "Time ago" formatter.
But I change the granularity to 7 and it didn't have any impact on the display.
The formatter output also depends on the range itself. If the difference between dates just a few seconds you will always see only one unit.
I think the more accurate label for this setting would be "Max granularity" but if we gonna use it same change needs to be applied to "Time ago" formatter.
if datetime range permits that
The field requires both dates to be specified statically.
KernelTestBase
needs deep refactoring anyway. I think it's worth to create a new base class for kernel tests. Also $runTestInSeparateProcess
needs to be disabled as it will case setUpBeforeClass
and tearDownAfterClass
hooks run after each test method.
It feels if we had fixed this issue in 2012 the Drupal Association could save tens of thousands of dollars on CI environments.
if you pass this string to drupal_url(), it will fail
The function accepts what in Drupal is called user input not URL or path. The user input could be a system path or query string. Event anchor is acceptable. The primary usage of Url::fromUserInput
is a UI where users can create some links, for example when configuring menus.
The function is named drupal_url
because it always returns a URL either relative or absolute.
{# Provide any valid (internal) path (like: "node/1", "taxonomy/term/1") #}
Twig Tweak prepend /
to the user input if it's missing. But I think the documentation should encourage users to provide paths in right way, with leading slashes (/node/1
, /taxonomy/term/1
, etc).
Patch is welcome.
drupal_url()
accepts any URL, it doesn't really know if it an entity URL or something else like /admin/structure
.
Re #6 that approach seems reasonable. I think services that provide reason should not translate it. And the reason should only answer "Why" question, not "What". That's literally what reason parameter is intended for.
In case of Entity Integrity Reference module it should look like follows.
the content item Example as it is being referenced by another entity.