WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 7 months ago

Last modified 6 months ago

#43357 closed enhancement (duplicate)

SimplePie deprecated calls modified

Reported by: arena Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Feeds Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

Since SimplePie has introduced SimplePie_Registry, some methods calling have been deprecated

http://simplepie.org/api/class-SimplePie.html

Attachments (6)

#.patch (1.0 KB) - added by arena 3 years ago.
fix
#43357 2020-04-26.patch (5.0 KB) - added by arena 7 months ago.
new patch 2020-04-26
#43357-2 2020-04-26.patch (4.9 KB) - added by arena 7 months ago.
with coding standards !
#43357-3 2020-04-26.patch (4.9 KB) - added by arena 7 months ago.
and without a typo in $location (?&lifetime becomes ?lifetime)
#43357-4 2020-04-30.patch (5.0 KB) - added by arena 7 months ago.
This one is another way to do it
#43357-5 2020-04-30.patch (5.0 KB) - added by arena 7 months ago.
WP_Feed_Cache instead of WP_SimplePie_Cache

Download all attachments as: .zip

Change History (18)

@arena
3 years ago

fix

#1 @arena
3 years ago

  • Component changed from External Libraries to Feeds
  • Keywords has-patch added

#2 follow-up: @SergeyBiryukov
3 years ago

Related: #29204

#3 in reply to: ↑ 2 @arena
3 years ago

Replying to SergeyBiryukov:

Related: #29204

hello, fyi

#43357 new enhancement (simplepie doc says there are deprecated functions)

#29204 reviewing defect (bug) (never had this bug in my DashPress plugin) and btw a 4 year old ticket !

regards

#4 @pento
23 months ago

  • Version trunk deleted

#6 follow-up: @desrosj
7 months ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Hi @arena,

Thanks for reporting this! My apologies it took a while for someone to get around to it.

It appears that the documentation linked above is out of date, but the initial premise of the ticket is still correct.

Updating the SimplePie library is being tackled in #36669, hopefully for 5.5. I am going to wait for that to be completed before making these changes so they can be verified and tested against the latest version in WordPress.

There also should be unit tests to ensure the WordPress specific classes are correctly registered in SimplePie using the new registry. If you are able to write those, that would help move this along.

#7 in reply to: ↑ 6 @arena
7 months ago

I am using simplepie within wordpress several times a day with my plugin dashpress.
Current version is 4.1, but since 3.9 (hereunder extract of readme.txt)

 3.9            2018/02/19 several improvements
   * new thumbnail search with extended SimplePie Item class
   * changing deprecated calls of SimplePie extended classes 

and here is my code in plugin :

<?php
if ( !class_exists( 'SimplePie', false ) ) require_once( ABSPATH . WPINC . '/class-simplepie.php' );

require_once( ABSPATH . WPINC . '/class-wp-feed-cache.php' );
require_once( ABSPATH . WPINC . '/class-wp-feed-cache-transient.php' );
require_once( ABSPATH . WPINC . '/class-wp-simplepie-file.php' );
require_once( ABSPATH . WPINC . '/class-wp-simplepie-sanitize-kses.php' );

$feed = new SimplePie();

$feed->set_cache_duration( $options['caching'] ?? 43200 );

$feed->registry->register( 'Cache', 'WP_Feed_Cache',     true );
$feed->registry->register( 'File',  'WP_SimplePie_File', true );

// this one is specific to plugin
$feed->registry->register( 'Item', 'DBP_SimplePie_Item', true );


and finally, there is a patch attached to this ticket

Replying to desrosj:

Hi @arena,

Thanks for reporting this! My apologies it took a while for someone to get around to it.

It appears that the documentation linked above is out of date, but the initial premise of the ticket is still correct.

Updating the SimplePie library is being tackled in #36669, hopefully for 5.5. I am going to wait for that to be completed before making these changes so they can be verified and tested against the latest version in WordPress.

There also should be unit tests to ensure the WordPress specific classes are correctly registered in SimplePie using the new registry. If you are able to write those, that would help move this along.

#8 @arena
7 months ago

@desroj

i digged into the SimplePie doc,
the method described above is not the good one.

Hereattached is a new patch that needs to be tested.

@arena
7 months ago

new patch 2020-04-26

@arena
7 months ago

with coding standards !

@arena
7 months ago

and without a typo in $location (?&lifetime becomes ?lifetime)

@arena
7 months ago

This one is another way to do it

#9 @arena
7 months ago

So last patch (#43357-4 2020-04-30.patch) might be the more conventional way to do it

Adding to WP_Feed_Cache :

  • setting handler 'wordpress' ($handlers)
  • get_handlers() function
  • create() function is annonced to be deprecated in 1.3.1 but when removed the code do not work as intended.

Adding to WP_Feed_Cache_Transient :

  • implements SimplePie_Cache_Base (required by SimplePie)
  • adding a function to parse $location (same as SimplePie/Cache.php)
  • $lifetime is a parameter of $location

Changing wp-includes/feed.php

  • Only one apply_filters 'wp_feed_cache_transient_lifetime' now
  • registering classes the new way
  • setting cache_location with defined handler

@arena
7 months ago

WP_Feed_Cache instead of WP_SimplePie_Cache

#10 @arena
7 months ago

oops ! WP_Feed_Cache instead of WP_SimplePie_Cache

$feed->registry->register( 'Cache', 'WP_Feed_Cache', true );

(may be we should change that as well !)

Last edited 7 months ago by arena (previous) (diff)

#11 @arena
7 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #50159.

simplepie upgraded in trunk to 1.5.5

closing this ticket and opening a new one with patch

#12 @SergeyBiryukov
6 months ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.