Skip to content

Conversation

@simondw
Copy link

@simondw simondw commented Jun 1, 2021

Description of the Change

Replaced deprecated function insert_blog() with wp_insert_site().

When running wp mu-migration import all without passing a value for --blog_id, create_new_site() returned false . This update returns the ID of a newly created site and also creates the site.

Error received:

PHP Deprecated: insert_blog is <strong>deprecated</strong> since version 5.1.0! Use wp_insert_site() instead. in .../functions.php on line 4861

Benefits

This fix uses the WP replacement for wp_insert_site(), wp_insert_site() which also returns an int for the ID of the newly created site: https://developer.wordpress.org/reference/functions/wp_insert_site/ . This should simply replace a deprecated function (which is no longer working when testing with WP v5.7.2).

Possible Drawbacks

The array defined as $new_site_meta var includes predefined values for public, archived, mature, etc. These could present a problem if a migration originates from a multisite. My use test case was for a single site origin.

Verification Process

Manually running and local unit tests; have not pushed any new tests with this update.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

@simondw simondw changed the title returning false - replaced insert_blog with wp_insert_site blod_id returning false - replaced insert_blog with wp_insert_site Jun 1, 2021
@simondw simondw changed the title blod_id returning false - replaced insert_blog with wp_insert_site $blod_id returning false - replaced insert_blog with wp_insert_site Jun 1, 2021
@simondw simondw changed the title $blod_id returning false - replaced insert_blog with wp_insert_site create_new_site returning false - replaced insert_blog with wp_insert_site Jun 1, 2021
@jeffpaul jeffpaul added this to the 0.4.0 milestone Jun 1, 2021
@jeffpaul jeffpaul requested a review from nicholasio June 1, 2021 20:23
@jeffpaul
Copy link
Member

@simondw looks like there are a couple test failures, mind taking a look at those to see if your PR might need to account for something there?

Copy link
Member

@nicholasio nicholasio left a comment

Choose a reason for hiding this comment

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

This looks good, just left one small comment.

Did all the tests pass locally for you? There are two failing but they seem unrelated.

@jeffpaul
Copy link
Member

@simondw any thoughts on the questions above?

@elvismdev elvismdev mentioned this pull request Nov 10, 2022
4 tasks
Co-authored-by: Nícholas André <nicholasio.oliveira@gmail.com>
@jeffpaul jeffpaul requested a review from nicholasio February 15, 2024 20:58
@jeffpaul jeffpaul requested a review from tott April 2, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants