Conversation
This is a preparation for using the new Less utils from `ipl\Web` to simplify the comparison of the old and new stylesheets.
This reverts commit 7c58b3c. Remove variable exports as they were never used in our modules or community modules, and using this feature is discouraged.
Replace the in-tree `Icinga\Less\` visitor layer with its equivalents from `ipl\Web\Less`, where the same color-variable and light-mode functionality is maintained as a shared library. `LessCompiler` is updated to delegate to `WikimediaLessCompiler`, assembling source via `@import (less)` directives and accepting a `$minify` flag directly on `render()` rather than through a separate `compress()` call.
Add missing PHP type declarations to properties and methods, replace long-form `array()` syntax with short `[]` syntax, tighten PHPDoc comments, and correct "LESS" to "Less".
ipl-webipl\Web\Less
| ); | ||
|
|
||
| if (in_array($path, $special)) { | ||
| putenv('ICINGAWEB_ENVIRONMENT=production'); |
There was a problem hiding this comment.
Please note that this must be removed before merging the PR.
|
I compared the minified CSS output between the
Here the
|
Are you sure about that?
Why do you think that's an issue?
That's interesting (since this results in
That's a good find, and it's been invalid CSS/Less since it was introduced. Now that you've brought it up, would you like to add a fix to this PR? |
Yes, looked again at the before and after CSS minified files and found that in most cases the leading zero has been removed, but in some places the change is applied as you mentioned above, and in others it remains unchanged. So we have three different behaviors, I think there should be consistency here. Removed leading zero:/*Before*/
.icinga-module.module-icingadb .item-layout.downtime .visual {
...
padding: 0.5em 0.25em;
/* The source file (`icingadb/downtime.less`) does not contain the leading zero, so I guess the LESS compiler was adding it before. */
}
/*After*/
.icinga-module.module-icingadb .item-layout.downtime .visual {
...
padding: .5em .25em;
}A zero is added: /*Before*/
.icinga-module.module-icingadb .row-item .performance-data {
...
margin-left: -.25em;
}
/*After*/
.icinga-module.module-icingadb .row-item .performance-data {
...
margin-left: -0.25em
}Remains the same in before and after cases:.icinga-module.module-icingadb .row-item .performance-data .inline-pie {
...
margin-left: .25em
}
Yes, it is not an issue, but I thought it could be an unwanted change since it was not mentioned in the changes table above. Or did you mention it as normalization noise?
Okey, i will push a commit. |
We have no control over how the Wikimedia Less parser minifies the CSS. Therefore, it only makes sense to compare the unminified versions.
Same as above. |
7c96160 to
0af9a40
Compare
|
Yes, you are right. That's the minifier which removes the leading zero and the semicolon. The non-minified file contains only the changes mentioned above. |
This is invalid since `wikimedia/less.php:v5.0.0` : https://gerrit.wikimedia.org/r/c/mediawiki/libs/less.php/+/1049149 Less only evaluates its own variables, escaping won't help here. Use a Less variable to evaluate the divison correctly, and remove the unnecessary escape characters.
nilmerg
left a comment
There was a problem hiding this comment.
Category Example Font shorthand explicit line-height 1em → 1em/1
That's not caused by normalization but by not evaluating it as division. But these variables don't seem to be used anyway, so that's why it wasn't an issue previously and the change won't be noticed now.
| if ($theme === null || (is_file($theme) && is_readable($theme))) { | ||
| $this->theme = $theme; |
There was a problem hiding this comment.
I wonder why we didn't use realpath here as we use it for other less files already. Now that you use @import, I think it's safer to use it for theme files as well.
| public function setThemeMode(string $themeMode): static | ||
| { | ||
| if (is_file($themeMode) && is_readable($themeMode)) { | ||
| $this->themeMode = $themeMode; |
There was a problem hiding this comment.
Same here, realpath won't hurt.
| LESS; | ||
| $compiler = new WikimediaLessCompiler([ | ||
| // Disable URL adjustment - Less.php tries to make URLs relative to the file path when using @import. | ||
| 'relativeUrls' => false, |
There was a problem hiding this comment.
What's the exact reason for this? I enabled it again but didn't spot an issue. And looking at wikimedia's implementation, I think it's safer to enable since it escapes certain characters it seems.
There was a problem hiding this comment.
You should see issues, e.g., fonts not loading, logo not loading.
There was a problem hiding this comment.
Right. Then the comment explaining it is misleading as it doesn't affect @import in any way. Even tried to import a realative path with this enabled and it worked fine.
The new version of the Wikimedia Less parser handles mathematical expressions differently, which is why we have to specify |
|
The upgrading docs need to mention the changes, especially those to mathematical expressions. |

Because the in-tree Less visitor requires
wikimedia/less.php, that dependency has to live inicinga-php-thirdparty.icinga-php-libraryalready carries Less-related code with the same dependency, so this PR consolidates everything intoicinga-php-libraryand removes the duplicate in-tree implementation.Icinga\Less\visitor layer in favor of the sharedipl\Web\Lesslibrary, which maintains modernized equivalent CSS var replacement and light-mode functionality.LessCompiler— the feature was never used by any our modules or community modules.LessCompilerto delegate toipl\Web\Less, assembling sources via@import (less)directives; pass the$minifyflag directly torender()instead of via a separatecompress()call.LessCompilerwith PHP type declarations, short array syntax, and tightened PHPDoc.For testing, use 7da4917 as the baseline, which adapts light mode rule evaluation order to match the new visitor.
Here is my test summary:
The stylesheets are nearly identical. All but one difference are cosmetic normalizations introduced by the new version of the wikimedia Less parser:
.5em→0.5em#dddddd→#ddd#ffffff→white,#ff0000→redtransparent→rgba(0,0,0,0)var()expressions.0stripped2.0em→2em,1.0→1calc()kept as fractionscalc(14.28571429%)→calc(100% / 7)1em→1em/1There is one functional difference: the light-mode background color gains an extra level of indirection via a new CSS var call (because it uses
@light-body-bg-color):The new CSS var replacement visitor from
ipl\Webruns independently from the light mode call visitor, and therefore also adds var overrides to such detached rulesets. Everything else is normalization noise.closes #5457
requires Icinga/icinga-php-thirdparty#115
requires Icinga/ipl-web#365