Hi everybody,
We've released version 0.42.0 of the OOUI library* yesterday.
It's going to rollout with normal train next Tuesday, 24 August 2021.
Highlights in this release:
- Removal of code fragments for browsers, that were taken out of basic
support, most of those affected released before 2013! [0]. Removal
will directly results in a small performance gain for all other users.
This is nominally a breaking change. If you need to continue to
support those browsers in your environment, please stick with an
earlier version.
- Upgraded underlying libraries to jQuery v3.6.0, up from v3.5.1 and
OOjs to v6.0.0, up from v5.0.0. This goes hand-in-hand with similar
upgrade in MediaWiki core. Both updates above are considered breaking
changes. Please carefully test if they affect your code.
- Two new icons, 'share' and 'ocr' have become part of the library and
the WikimediaUI design system.
- Addition of RequiredElement mixin, already added in v0.41.1
Thanks especially to Thiemo Kreuz and volunteer DannyS712 on improving
the documentation and Umherirrender for continuous code improvement
patches.
You can find details on additional new features, code-level, styling
and interaction design amendments, and all improvements since v0.41.0
in the full changelog [1].
If you have any further queries or need help dealing with breaking
changes, please reach out to me.
As always, interactive demos [2] and library documentation is
available on mediawiki.org [3], there is comprehensive generated
code-level documentation and interactive demos and tutorials hosted on
doc.wikimedia.org [4].
Best,
Volker
* Obligatory to say, no, this is not the answer to Everything. That
will probably be v42 of the future Vue.js based user-interface
components library [5].
---
OOUI version: 0.42.0
MediaWiki version: 1.37.0-wmf.20
Date of deployment to production: Regular train, starting Tuesday 24 August
[0] - https://phabricator.wikimedia.org/T266866
[1] - https://gerrit.wikimedia.org/g/oojs/ui/+/v0.42.0/History.md
[2] - https://doc.wikimedia.org/oojs-ui/master/demos/#widgets-mediawiki-vector-ltr
[3] - https://www.mediawiki.org/wiki/OOUI
[4] - https://doc.wikimedia.org/oojs-ui/master/
[5] - https://phabricator.wikimedia.org/T288980
[Moving to wikitech-l; mediawiki-l is a little off-topic.]
On Mon, 26 Jul 2021 at 21:27, Yaron Koren <yaron57(a)gmail.com> wrote:
> Hi,
>
> I've been trying to get rid of the ESLint warnings for the JavaScript code
> in some of my extensions, when they go through Jenkins validation. One
> warning that appears fairly often is this one:
>
> Where possible, maintain application state in JS to avoid slower DOM
> queries
> no-jquery/no-class-state
>
>
> I'm not sure if this is a warning that's specific to Wikimedia code, but
> doing a web search on it brings up this Wikimedia help page as the only
> real result:
>
>
> https://github.com/wikimedia/eslint-plugin-no-jquery/blob/master/docs/rules…
>
Yes, we forked the dead "jquery" upstream eslint plugin and have expanded
it significantly. In general, the plugin's purpose
<https://www.npmjs.com/package/eslint-plugin-no-jquery> is to discourage
use of jQuery functions, especially where the functions are deprecated or
have faster native equivalents. (Almost all uses of jQuery are no longer
necessary given that the vast majority of the Web only runs on
modern-enough browsers.)
This page is rather confusing. It says that the warning comes when calling
> either hasClass() or toggleClass() on a jQuery element. That part makes
> sense, but then the suggested alternatives are strange. The page says that
> the following are some examples of bad code:
>
> $( 'div' ).hasClass();
> $div.hasClass();
>
> In their place, it suggests the following:
>
> hasClass();
> [].hasClass();
> div.hasClass();
>
No, it doesn't. It says that our code is clever enough to not think that
these false positives are issues that you need to fix. It's not saying you
should use a method called hasClass(); it's saying that you should maintain
state inside JS; this is principally a performance/code smell test.
If your code is triggered from a non-JS DOM (e.g. painted from PHP), the
first time you grab state from the DOM is unavoidable (and so you'd use an
inline disable), but thereafter you should keep track of such details in
JS. An example of this is in the initialisation code for Notifications
("Echo"), where it has to grab the state from the DOM
<https://gerrit.wikimedia.org/g/mediawiki/extensions/Echo/+/HEAD/modules/ext…>
for a couple of items, but does so only once.
Sorry that this is confusing! We could put together a narrow JS tips and
tricks page and link to that from the linter, but most of these have been
fixed over the years since we introduced this in Wikimedia production code
so there's not been much call.
J.
--
*James D. Forrester* (he/him <http://pronoun.is/he> or they/themself
<http://pronoun.is/they/.../themself>)
Wikimedia Foundation <https://wikimediafoundation.org/>
Hello all,
Next week we will remove the following methods without deprecation:
- Article::delete()
- Article::confirmDelete()
- ImagePage::delete()
This is part of an ongoing refactoring of deletion-related code. The
methods above are currently bloated: beyond deleting an article, they're
responsible for building the UI, checking permissions, handling errors etc.
The relevant UI-related code is being moved to DeleteAction, so use that if
you need to do something with the UI.
Maintaining BC in the old methods is challenging, due to how many things
this code does, and how much code is being moved around. According to
codesearch, these methods are only used by a test in WikibaseLexeme (which
has been temporarily disabled). Thus, we decided to remove them without
deprecation after this week's train.
Please reply to this email if you're affected by this and don't know how to
fix.
Best regards,
--
https://meta.wikimedia.org/wiki/User:Daimona_Eaytoy
"Daimona" is not my real name -- he/him
This email is a summary of the Wikimedia production deployment of
1.37.0-wmf.18.
- Conductor: Jeena Huneidi
- Backup: Mukunda Modell
- Blocker task: T281159 <https://phabricator.wikimedia.org/T281159>
- Status: Live on all wikis <https://versions.toolforge.org/>
*📊Stats*
- 244 patches ▁▄█▅▄
- 1 rollback ▁▁███
- 1 day of delay (going to group0) ██▁▁█
- 6 blockers ▄▁▁▆█
🚂🌈
Big WikiLove to the folks who helped out:
- Timo Tijhof
- James D. Forrester
- Tacsipacsi
- Lucas Werkmeister
- Jon Robson
- RhinosF1
- KartikMistry
- abi_
- Zabe
Until the next train,
– Your local WikiMotive congregants
Could someone help me with something related to <b>gerrit.wikimedia.org</b>? My <b><a href="https://gerrit.wikimedia.org/r/dashboard/self">dashboard</a></b> has <b>6 changes</b> that need code review, which is important because they are requests from Phabricator . So could someone experienced review the code for my requested changes? Thank you in advance!
For performance sensitive tight loops, such as parsing and HTML
construction, to get the best performance it's necessary to think
about what PHP is doing on an opcode by opcode basis.
Certain flow control patterns cannot be implemented efficiently in PHP
without using "goto". The current example in Gerrit 708880
<https://gerrit.wikimedia.org/r/c/mediawiki/core/+/708880/5/includes/Html.ph…>
comes down to:
if ( $x == 1 ) {
action1();
} else {
action_not_1();
}
if ( $x == 2 ) {
action2();
} else {
action_not_2();
}
If $x==1 is true, we know that the $x==2 comparison is unnecessary and
is a waste of a couple of VM operations.
It's not feasible to just duplicate the actions, they are not as
simple as portrayed here and splitting them out to a separate function
would incur a function call overhead exceeding the proposed benefit.
I am proposing
if ( $x == 1 ) {
action1();
goto not_2; // avoid unnecessary comparison $x == 2
} else {
action_not_1();
}
if ( $x == 2 ) {
action2();
} else {
not_2:
action_not_2();
}
I'm familiar with the cultivated distaste for goto. Some people are
just parotting the textbook or their preferred authority, and others
are scarred by experience with other languages such as old BASIC
dialects. But I don't think either rationale really holds up to scrutiny.
I think goto is often easier to read than workarounds for the lack of
goto. For example, maybe you could do the current example with break:
do {
do {
if ( $x === 1 ) {
action1();
break;
} else {
action_not_1();
}
if ( $x === 2 ) {
action2();
break 2;
}
} while ( false );
action_not_2();
} while ( false );
But I don't think that's an improvement for readability.
You can certainly use goto in a way that makes things unreadable, but
that goes for a lot of things.
I am requesting that goto be considered acceptable for micro-optimisation.
When performance is not a concern, abstractions can be introduced
which restructure the code so that it flows in a more conventional
way. I understand that you might do a double-take when you see "goto"
in a function. Unfamiliarity slows down comprehension. That's why I'm
suggesting that it only be used when there is a performance justification.
-- Tim Starling