-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
Integrations API #2405
Integrations API #2405
Conversation
This switches from using the public, static CoAuthorsPlusIntegration::$prefer_gravatar variable to using a basic custom filter for this part of the API. This is more consistent with WP World in general.
@gchtr the image resize test that's failing now ( |
That was a missing I moved all WPML-related tests to a new tests file that matches other integration tests. But I guess some things could still be moved around. We could probably use a |
Couple quick thoughts -
|
@acobster Yeah, probably bootstrap.php is a better place. Since we don’t actually install WPML when testing, setting that constant should work fine and then we wouldn’t need the |
* define ICL_LANGUAGE_CODE in test bootstrap * inline WPML directory setup (only used once)
@gchtr thanks for taking a look and consolidating those tests! Still not sure why the meta tests are failing. Also, please take a look at the new comments in test-timber-user.php - the tests pass now but if I add those same filters in a |
🤔 It works for me if I use function setUp() {
parent::setUp();
$this->add_filter_temporarily('timber/user/classmap', function() {
return User::class;
});
} |
Oh, duh! I was forgetting to call |
🙈😅 Sometimes it’s that, sometimes it’s the order in which tests are called, sometimes it’s something else. No worries! |
I think 2.0 because we will need to refactor some of the ACF/meta stuff on top of this, and that stuff has at least one breaking change. |
I will get around to fixing those User tests soon and then I think this will be solid enough to merge in. The meta tests that are failing will probably need to be revisited anyway as we change the API/integration with ACF etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gchtr work came knocking for me too, sorry for falling off the face of the Earth!
Same here :)
I quickly checked and found two things that look like stray debugging code (in separate comments).
And what’s the status of the following "Left to do" list?
Left to do
* Document how to build a custom integration * Fix an image with image URLs in WPML integration * Fix potential issues in `test-timber-meta-deprecated.php` * Not sure what `Timber\Integrations\Command` is for - I haven't dug into that code yet. But it's not one of the ones that was previously initialized in `Integrations::__construct()`...
I think an Integration guide would be great. I’ll add it to my list of things to improve, but can’t guarantee when I can work on it 😅.
This is a little cleaner/more modular than static methods here.
@gchtr thanks for looking! Those have been cleaned up.
Guide added!
I think this had to do with that leftover debug statement and is now fixed.
Still running into issues where the tests expecting specific meta values are seeing
I looked and that's just the WP-CLI integration. It's not really an "integration" in the same sense (WP-CLI is not a plugin), although we could treat it as such: class WpCliIntegration implements IntegrationInterface {
public function should_init() {
return defined( 'WP_CLI' ) && WP_CLI;
}
public function init() {
WP_CLI::add_command( 'timber', TimberCommand::class );
}
} I feel like it's fine to consider this out of scope here though. |
I found the issue and fixed it in That’s why the filters of the ACF integration were probably set up with static classes in the first place. I reverted it to what it was before, because that seemed to be the easiest change to fix this. Another way to solve this would be to save the result of the initialized integrations in the
Cool! I looked over it and saw that you added it in the /docs/v1 folder. I moved it to the v2 folder :). And I added a note in the Upgrade Guide. |
# Conflicts: # lib/Integration/AcfIntegration.php # tests/test-timber-integration-acf.php
Hmmmm, it seems there's a failing test we'll need to resolve regarding how post meta data is stored/set ... 1) TestTimberMeta::testNonNullReturnInPreMetaFilterDisablesDatabaseFetch
Failed asserting that true matches expected false.
Error: /home/runner/work/timber/timber/tests/test-timber-meta.php:182 https://github.com/timber/timber/blob/feature/integrations-api/tests/test-timber-meta.php#L182 |
@jarednova I fixed the failing test in |
Ticket: #2402
Issue
New Integrations API!
Solution
Factory
andImage
, renamed the namespace toTimber\Integration
CoAuthorsPlus::$prefer_gravatar = true
which is awkward and non-idiomatic. Updated this to use a plain old filter instead.Left to do
test-timber-meta-deprecated.php
Timber\Integrations\Command
is for - I haven't dug into that code yet. But it's not one of the ones that was previously initialized inIntegrations::__construct()
...Impact
Cleaner internal code, easier external integrations.
Usage Changes
This wasn't an external API until now, so usage changes will be covered by the introduction of docs for this new API.
Considerations
Please look carefully at the WPML integration and how it's tested. I'm less confident in that than I am in the others, because WPML has a bigger scope.
Testing
Reworked tests to use the new API. Tests were mostly unaffected.