Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#40495 closed defect (bug) (invalid)

Check objects before getting it's value

Reported by: khushbu.padalia Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Upload Keywords:
Focuses: Cc:



I am working with media upload file and noticed one issue with the WordPress core files.

To upload media from folder,
I am using media_handle_sideload() function. But at the time of uploading media, I am getting error of non-object for $wp_rewrite global object in post.php file.

File Path:- \src\wp-includes\post.php file,
there is function wp_unique_post_slug() exists. In this function, feeds have been getting from global object $wp_rewrite.

For refrerence,
$feeds = $wp_rewrite->feeds;

Before getting feeds from global object, it should be checked if object is not empty and feeds are there.

Attachments (1)

40495.patch (443 bytes) - added by khushbu.padalia 4 years ago.

Download all attachments as: .zip

Change History (4)

#1 @dd32
4 years ago

  • Keywords reporter-feedback added

Hi @khushbu.padalia and welcome to Trac.

Sorry it took so long for someone to get back to you.

Can you clarify how you're running into this? Are you using your own upload script, or are you running the upload through one of WordPress's upload files?

$wp_rewrite should be setup and ready before the point at which uploads are processed, if you're processing them yourself I'd suggest ensuring you're waiting until at least init or admin_init to process them.

#2 @khushbu.padalia
4 years ago

hi @dd32,

Thank you for answering to my ticket and sorry for my late reply.

I have checked my code. Actually my code was running before initialization, no any WordPress bug.

Thank you for supporting.

#3 @dd32
4 years ago

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

Hey @khushbu.padalia,

Thanks for following up and letting us know!

Note: See TracTickets for help on using tickets.