Account created on 20 July 2009, almost 15 years ago
#

Recent comments

🇷🇺Russia Chi

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?

🇷🇺Russia Chi

@kim.pepper

Even if the extension is enabled the message `{"message":"Starting upload...","percentage":-1}` will still appear when no upload process is available.

🇷🇺Russia Chi

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)];
    }
  }
}
🇷🇺Russia Chi

Re #77
If we use event listeners instead of subscribers we could make use of PHP attributes as well.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

@smustgrave you've been given all permissions to this project. If you are interested in taking ownership please create an issue here .
Thank you.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

There is something wrong here. ExtensionList is marked as internal. We should not recommend using it in change records.

🇷🇺Russia Chi

I doubt that it possible. Pagination is handled outside of views.

🇷🇺Russia Chi

I don't know. By some reason your services container is not rebuilding. You need to figure it out.

🇷🇺Russia Chi

You might need to clear opcache or restart your server.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

I have a module that does support this feature. It's not currently actively maintained but still working. It might be used for inspiration.

🇷🇺Russia Chi

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);
}
🇷🇺Russia Chi

drupal_loads_json()

That would just duplicate source function from Twig core.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

Refactored a bit so when width or height attributes are given the image toolkit is not involved.

Thank you.

🇷🇺Russia Chi

Drupal\twig_tweak\TwigExtension->imageStyle(NULL, 'card_image_134x160')

It's expected behavior because you did not pass the image path.

🇷🇺Russia Chi

I think the duration needs to be rendered using time tag.

🇷🇺Russia Chi

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'] ?? '';
🇷🇺Russia Chi

Looks great. Thank you.

🇷🇺Russia Chi

Chi made their first commit to this issue’s fork.

🇷🇺Russia Chi

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 }}
🇷🇺Russia Chi

You can install whatever version of Twig Tweak compatible with your Drupal installation.

🇷🇺Russia Chi

I've added data_uri filter. It will be available in the next release. Thank you.

🇷🇺Russia Chi

it denies core upgrades to 10.1.x, 10.2.x

@e5sego, it does not. See note #2.

🇷🇺Russia Chi

Actually, the version contraint to ^10.0 ist still in the module composer.json file.

@e5sego What's wrong with using ^10.0?

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

Added support for collection permission.

🇷🇺Russia Chi

With these logos it will be so easy to find a list of installed contrib modules on any Drupal site.

🇷🇺Russia Chi

This function now accepts external URLs as well.

🇷🇺Russia Chi

Added an example of rendering block with context to Cheat Sheet.
Closing this issue as there is nothing doable here.

🇷🇺Russia Chi

People keep struggling with passing contexts. I pushed the example to Cheat Sheet.
Thank you.

🇷🇺Russia Chi

Given that the filter is just a few lines of code we could just copy it into Twig Tweak.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

I updated the documentation for drupal_field(). Thank you.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

@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. )

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

Chi made their first commit to this issue’s fork.

🇷🇺Russia Chi

Chi made their first commit to this issue’s fork.

🇷🇺Russia Chi

The patch contains lots of irrelevant changes. Also I think the code with intval and strval callbacks is much more readable.

🇷🇺Russia Chi

the time ago formatter limits the granularity to 6 by some reason

Created an issue. Increase max allowed granularity in Time ago formatter RTBC

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

"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.

🇷🇺Russia Chi

if datetime range permits that

The field requires both dates to be specified statically.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

It feels if we had fixed this issue in 2012 the Drupal Association could save tens of thousands of dollars on CI environments.

🇷🇺Russia Chi

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.

🇷🇺Russia Chi

drupal_url() accepts any URL, it doesn't really know if it an entity URL or something else like /admin/structure.

🇷🇺Russia Chi

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.

Production build 0.67.2 2024