Make WordPress Core

Opened 5 years ago

Closed 2 years ago

#49143 closed defect (bug) (reported-upstream)

Deprecated constructor warning in Blogger Importer

Reported by: leemon's profile leemon Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3.2
Component: Import Keywords: has-patch needs-testing has-testing-info
Focuses: Cc:

Description

Running the Blogger Importer in PHP 7 throws the following warning:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Blogger_Importer has a deprecated constructor in /xxxxxx/wp-content/plugins/blogger-importer/blogger-importer.php on line 44

Change History (14)

#1 @dkarfa
5 years ago

  • Keywords close added

Hi @leemon,
I'm sorry to hear that you are having issues with your WordPress site.

Unfortunately, this is not the right place to post.

This Trac instance is for the development of the core WordPress software and not general user support.

For support, please open a ticket in the WordPress.org Support Forums.

Thank you
Debabrata Karfa

#2 @leemon
5 years ago

The Blogger Importer is the one that comes with core WordPress. This is not a third-party plugin.

#3 @desrosj
5 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

@leemon While the Blogger importer is mentioned on the Tools page shipped in WordPress Core, the importer itself is a plugin (https://wordpress.org/plugins/blogger-importer/). Please report the issue in the plugin's support forums.

#4 @SergeyBiryukov
5 years ago

  • Milestone set to WordPress.org
  • Resolution invalid deleted
  • Status changed from closed to reopened

Importer plugins are actually still supported here on Core Trac.

Per https://make.wordpress.org/core/handbook/contribute/trac/:

Tickets for core plugins, such as the importers, are managed under the Plugins or Import components, and current and former default themes are managed under the Bundled Theme component.

Per https://core.trac.wordpress.org/report/26:

The following components are tracked here:

  • Import: The core importers, now in the plugins repository
  • Themes: previously bundled themes (Kubrick, Classic), now in the themes repository

Thanks for the report, sorry for the confusion :)

This ticket was mentioned in Slack in #core by pbiron. View the logs.


5 years ago

#6 @Howdy_McGee
5 years ago

It looks like this issue also conflicts with other plugins such as Beaver Builder.

#7 @iandunn
4 years ago

  • Keywords php8 added
  • Priority changed from normal to high
  • Severity changed from normal to blocker

A similar error is now a fatal in PHP8.

Fatal error: Declaration of WP_SimplePie_Blog_Item::get_id($hash = false) must be compatible with SimplePie_Item::get_id($hash = false, $fn = 'md5') in plugins/blogger-importer/blogger-importer-blogitem.php on line 111

#8 follow-up: @jrf
4 years ago

  • Keywords php8 removed

A similar error is now a fatal in PHP8.

@iandunn Sorry, but that is a completely unrelated error and should have its own ticket.

A deprecated PHP 4 constructor method is (silently) treated like a normal method in PHP 8 and will not cause a fatal error.

This issue is talking about this code pattern:

<?php
class Blogger_Importer {
    function __construct() {}

    function Blogger_Importer() {
        self::__construct();
    }
}

If the class (still) does not contain a __construct() method, the Blogger_Importer() method should be renamed to __construct().

Otherwise, unless called directly, the Blogger_Importer() method will just be an unused method, which can be removed.

The fatal error mentioned by @iandunn is about one class extending another class and overloading an arbitrary method in that class using a different, incompatible function signature.
That will cause a fatal error in PHP 8, but is a completely different issue.

@SergeyBiryukov The base importer code seems to be maintained here: https://github.com/WordPress/wordpress-importer/ but that repo doesn't appear to contain the code for platform specific importers. Where is that code maintained ? In SVN ? Or are there git repos somewhere for these ?

#9 in reply to: ↑ 8 @SergeyBiryukov
4 years ago

Replying to jrf:

The base importer code seems to be maintained here: https://github.com/WordPress/wordpress-importer/ but that repo doesn't appear to contain the code for platform specific importers. Where is that code maintained ? In SVN ? Or are there git repos somewhere for these ?

Yes, as far as I know, only the WordPress Importer plugin has a GitHub repo, the others are still maintained in SVN on the Plugin Directory.

Would you like to be added as a committer to Blogger Importer or any of the other importers?

#10 @iandunn
4 years ago

  • Priority changed from high to normal
  • Severity changed from blocker to normal

Ah, you're right. I was thinking this one was elevated in PHP8 too, and it'd be easier to just fix them both in the same ticket. I'll open another ticket since this isn't an issue in 8.

#11 follow-up: @jrf
4 years ago

Yes, as far as I know, only the WordPress Importer plugin has a GitHub repo, the others are still maintained in SVN on the Plugin Directory.

Would you like to be added as a committer to Blogger Importer or any of the other importers?

I'd be happy to scan the plugins for this and other incompatibilities and do a quick update round of anything I come across, but you know me, SVN is not my comfort zone.

Would it make sense to add a repo in the GH organization with each of the importers in a separate folder ? or to possibly add them to the existing WordPress Importer repo in a separate importers folder with a separate subfolder for each of the add-on plugins ?
This might make contributions now and in the future easier ?

I'd be happy enough to set that up via PRs.

/cc @ocean90

#12 in reply to: ↑ 11 @SergeyBiryukov
4 years ago

Replying to jrf:

Would it make sense to add a repo in the GH organization with each of the importers in a separate folder ? or to possibly add them to the existing WordPress Importer repo in a separate importers folder with a separate subfolder for each of the add-on plugins ?
This might make contributions now and in the future easier ?

Yes, I think it's a great idea that would make them easier to maintain. Created a Meta ticket: #meta5550.

#13 @ironprogrammer
2 years ago

  • Keywords has-patch needs-testing has-testing-info added

I've submitted blogger-importer PR #3 to resolve this PHP 7 deprecation. (This repo is separate from wordpress-develop so does not appear in #section-pr above.)

Background

Testing Instructions

Steps to Test

  1. Ensure site is running PHP 7, where this deprecation applies.
  2. In wp-config.php, make sure that debugging is enabled (e.g. define( 'WP_DEBUG', true ); and define( 'WP_DEBUG_LOG', true );).
  3. Install and activate the Blogger Importer plugin.
  4. 🐞 After activation, note the deprecation logged to wp-content/debug.log.
  5. Deactivate the plugin.
  6. 🩹 Apply the patch. Or as an alternative, you can replace the plugin's blogger-importer.php file with the one from the following zip: same-name-class-constructor.zip (this is the working branch for PR #3).
  7. Activate the updated plugin.
  8. ✅ Note that the deprecation notice is no longer logged.

Expected Results

  • ✅ The deprecation notice is not logged after patching.

(I'd like to give a hat tip to @SergeyBiryukov, @dd32, and @vishnugopal for moving the current importers into GitHub, which should help ease future maintenance efforts like this 🙌🏻)

#14 @ironprogrammer
2 years ago

  • Milestone WordPress.org deleted
  • Resolution set to reported-upstream
  • Status changed from reopened to closed

This issue has been addressed in PR #3 and committed upstream.

In 8769023:

  • Resolves a PHP 7 deprecation notice due to old style (PHP 4) constructor name.

Props leemon, SergeyBiryukov, iandunn, jrf, azaozz, ironprogrammer.

Note: See TracTickets for help on using tickets.