-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/compat is confusing. Let's document how the contributors can use it effectively. #41023
Comments
There should be a different mindset for this. We are trying to be always ahead of WordPress core, so we are adding the code that is not there or needs to be extended. When we decide that code goes in the given major release, then we add all the code that represents it's number, for example, Finally, we can safely remove the given compat folder when the WP version in its name is equal (or lower) to the minimum WP version supported by the plugin. It’s the moment when all logic in that compat folder is present in all supported WP versions. |
The below comments are based on my understanding and might be wrong about something, so please correct me if needed 😄
What would be a case for that?
A bug in 5.9 would be handled in core in a minor version, so it would need to be back ported to GB afterwards. If you need to update some functionality that exists in core and is intended to land in the next version, you move the code to the next version compat folder and we always need to be careful with this:
Because all these files make GB work for the supported WP versions(2). The contents of the files in previous versions are conditionally declared/called with |
For example a function that gets merged to core in WordPress 6.0 and should no longer run the code path from the plugin.
That sounds nice, cc @scruffian for the purposes of #40811
That's what I ended up suggesting in https://github.com/WordPress/gutenberg/pull/40811/files#r871221188 but it took some thinking. It's not a straightforward thought process but keep repeating it. An extended README section would be already a big relief.
@ntsekouras That's what I initially thought, too, but there are files like this one that don't appear to have that conditional logic: gutenberg/lib/compat/wordpress-5.9/edit-site-page.php Lines 236 to 249 in 140dfb8
|
That's when we introduce the checks for existence. Usually a new GB function has the For example a new function is
The above process is manual and things might have been missed to be renamed/safeguarded or even moved to the new compat folder. The project is huge and lot's of code is added frequently. Also there might be other nuances with filters etc.. like the example you shared. There might be some extensions by GB that do not introduce a new function but make use of a function that applies some filter like here. So the code inside that function is patched into the existing function in core and we don't need a new function. There are many nuances I might not be aware with all the complexity 😄 |
That's my point! 😆 I wonder how much this is about the specific structure of |
I had also a hard time wrapping my head around what WP versions mean in |
I think it's mostly about the unavoidable complexity. In the last two years that I was first involved with that process, I believe great progress has been made, but in general this is no easy task 😄
I agree with @gziolo 👍 |
Agree.
Agree.
I don't think anything we come up with can eliminate the need for a compat matrix like that because at the end of the day we'll always have different versions of WordPress and Gutenberg which can be installed in various combinations onto a single website. I think all we can do right now is better documentation. The Or, you know, merge Core and Gutenberg into a monorepo 😀 |
@noisysocks Hmm, I agree. There is also a chance that improving the documentation will help us notice patterns we don't see right now and ultimately lead to a simpler process. Until then, let's keep an eye on pull requests targeting the
I'd really like to see that happening! |
What problem does this issue aim to solve?
There's something off with the mental model of
lib/compat
. There's friction every time it comes up.For example, we have:
lib/compat/wordpress-5.9
lib/compat/wordpress-6.0
lib/compat/wordpress-6.1
Can you answer these questions?
lib/compat/wordpress-5.9
after WordPress 5.9 is released?If you had to stop for a minute and think really hard, that's what I mean by friction.
Importantly, these question keep coming up on GitHub and slack – perhaps that's why the compat folders are not used as much day to day. @gziolo had to move a bunch of code changes from other locations to these compat folders for the 6.0 release.
What solution does this issue propose?
Ideally, I'd be able to glance over these directories and know exactly what to do.
I'm not sure how to get there, though.
Anything that moves us away from having to think about compat matrices like the one below is a win:
Related
This bit of documentation lives in the README.md:
cc @gziolo @youknowriad @scruffian @getdave @draganescu @noisysocks @talldan @oandregal @ntsekouras @jsnajdr @dmsnell @peterwilsoncc @hellofromtonya @Mamaduka @paaljoachim
The text was updated successfully, but these errors were encountered: