Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#34745 closed defect (bug) (invalid)

Call to undefined function wp_generate_password when using `wp_tempnam`

Reported by: migueluy Owned by: dd32
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Filesystem API Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Fatal error when calling wp_tempnam from within a plugin since: [35644]

PHP Fatal error:  Call to undefined function wp_generate_password() in /home/migueluy/public_html/wp-admin/includes/file.php on line 169

Change History (7)

#1 @obenland
5 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to dd32
  • Status changed from new to assigned

#2 @SergeyBiryukov
5 years ago

  • Description modified (diff)

#3 @dd32
5 years ago

In what world would wp-admin/includes/file.php be loaded, yet wp-includes/pluggable.php isn't? - A crazy world, that's what :)

@migueluy can you please post some more details, such as what plugin, and what it is doing?

The only way this can happen, is if upon plugin inclusion, a plugin is loading wp-admin/includes/file.php manually and calling wp_tempnam() immediately.. If so that plugin is doing two main things wrong, 1) Performing expensive operations on every pageload, 2) Not waiting until plugins_loaded (which literally fires after Cache & pluggables are loaded directly after plugins load) to do it's stufff.

I don't like the idea that this will fatal sites, but I don't care that a plugin doing the above would break.
I'm tempted to make wp_tempnam() return false if it's called that early.. the other option of course is less harsh and just not use a random folder..

Last edited 5 years ago by dd32 (previous) (diff)

#4 @juliobox
5 years ago

Since wp_generate_password() is a plugglable function and since pluggable functions are included before the plugins_loaded hook, you have to do your stuff on that first hook, not directly at your plugin's file root.
ps : @dd32 just posted the same, but i click on "submit" too ;)
ps : @migueluy is it on jetpack or what?

Last edited 5 years ago by juliobox (previous) (diff)

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

5 years ago

#6 @migueluy
5 years ago

  • Resolution set to invalid
  • Status changed from assigned to closed

@migueluy can you please post some more details, such as what plugin, and what it is doing?
@migueluy is it on jetpack or what?

It was on a really borked debug snippet that called wp_maybe_auto_update, as you both pointed during plugin inclusion, I thought it was being called on shutdown.

Sorry for the bothering, marking this as invalid.

Last edited 5 years ago by migueluy (previous) (diff)

#7 @SergeyBiryukov
5 years ago

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