Skip to content
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

2.x Cleanup todo in code #2757

Merged
merged 9 commits into from Jul 21, 2023
Merged

2.x Cleanup todo in code #2757

merged 9 commits into from Jul 21, 2023

Conversation

gchtr
Copy link
Member

@gchtr gchtr commented May 30, 2023

Related:

Issue

Source code contains a lot of todos.

Solution

I worked through the todos in code as well as some skipped tests. I left the todos that are only about documentation.

I will add separate comments with the changes.

Impact

Make sure we didn’t forget anything important for 2.x

Usage Changes

None.

Considerations

None.

Testing

Yes.

@gchtr gchtr added the 2.0 label May 30, 2023
@@ -564,7 +564,6 @@ protected function avatar_host($email_hash)

/**
* @internal
* @todo what if it's relative?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is an issue in the future, it will pop up as an issue.

@@ -145,7 +145,6 @@ protected function fetch_meta($field_name = '', $args = [], $apply_filters = tru
$args
);

// @todo Remove when deprecated filters will be gone
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove all apply_filters_deprecated() calls with the next major release.

@@ -86,7 +86,6 @@ protected function from_user_object($obj): CoreInterface
));
}

// @todo return a UserCollection instance?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment. We discussed somewhere that user collections or collections for other types of content are not needed at the moment (#1689). We can add it if we really need it.

@@ -587,7 +587,6 @@ public function clear_cache_twig()
$twig = $this->get_twig();

// Get the configured cache location.
// @todo What if this is a custom caching implementation?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will pop up as an issue in case it becomes a problem.

@@ -596,7 +595,6 @@ public function clear_cache_twig()
}

if (is_string($cache_location) && is_dir($cache_location)) {
// @todo What if not all files could be deleted?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be improved when we introduce better and streamlined error handling, see #2210.

@@ -47,7 +47,6 @@
* </div>
* </article>
* ```
* @todo implement JsonSerializable?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serialization can be added if needed. It’s documented in https://timber.github.io/docs/v2/guides/posts/#serialization.

@@ -35,7 +35,6 @@ public function current()
*/
$wp_post = parent::current();
// Lazily instantiate a Timber\Post instance exactly once.
// @todo maybe improve performance by caching the instantiated post.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance and caching is an area where we could improve in a lot of places. In case we want to improve post performance, we’ll find the right place to do it.

@@ -318,7 +313,6 @@ public static function get_attachment($query = false, $options = [])
{
$post = static::get_post($query, $options);

// @todo make this determination at the Factory level.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might improve this in the future. For the moment, it seems to work.

@@ -457,9 +450,6 @@ public static function get_posts($query = false, $options = [])
);
}

/**
* @todo Are there any more default options to support?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’ll figure them out if needed.

@@ -863,7 +853,7 @@ public static function get_term_by(string $field, $value, string $taxonomy = '')
public static function get_users(array $query = [], array $options = []): iterable
{
$factory = new UserFactory();
// TODO return a Collection type?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1689.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file didn’t really do anything.

@@ -178,25 +178,20 @@ public function testNextCategory()

public function testNextCustomTax()
{
$v = get_bloginfo('version');
if (version_compare($v, '3.8', '<')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t need to support WordPress < 3.8.

'post_title' => 'Timmy',
]);

update_option('show_on_front', 'page');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was missing to get the test working.

@@ -396,39 +390,6 @@ public function testGetPostWithClassMap()
$this->assertInstanceOf(TimberAlert::class, Timber::get_post($alert_id));
}



/* Terms API */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the coverage report, getting terms with different parameters is already covered in the factory tests.

/**
* @expectedDeprecated Timber\Timber::query_post()
*/
public function testQueryPost()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this somehow tests whether Timber::query_post() would change the post global so that get_the_ID() returns the queried post. This logic is not supported anymore.

{
// We don't actually test this directly in TestTimberPostGetter::testGettingWithFalse();
// that test directly instantiates a collection.
$this->markTestSkipped('@todo what should this be?');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the newest version, when using false with Timber::get_posts(), the default query will be used. This test would test a deprecated functionality then. That’s why I removed it.

@@ -901,48 +833,6 @@ public function testThePostHook()
$this->assertSame(3, $the_post_count);
}

public function testGetAttachment()
{
$this->markTestSkipped('@todo seems like a lot of what gets tested here is core WP file mgmt. Is that what we want?');
Copy link
Member Author

@gchtr gchtr May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a lot of what gets tested here is core WP file mgmt. Is that what we want?

I agree. Doesn’t seem to test anything worth testing that isn’t covered in other tests.

@gchtr gchtr marked this pull request as ready for review May 30, 2023 13:16
@gchtr gchtr added the Ready for Review Ready for a contrib to take a look at and review/merge label May 30, 2023
@gchtr gchtr requested a review from Levdbas May 30, 2023 13:17
Copy link
Member

@Levdbas Levdbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! That are a lot less todos!

@gchtr gchtr removed the Ready for Review Ready for a contrib to take a look at and review/merge label Jul 21, 2023
@gchtr gchtr merged commit 49e4598 into 2.x Jul 21, 2023
76 of 77 checks passed
@szepeviktor
Copy link
Contributor

I feel a fresh smell.
Thank you!!

@gchtr gchtr deleted the 2.x-todo branch July 21, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants