#34745 closed defect (bug) (invalid)
Call to undefined function wp_generate_password when using `wp_tempnam`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.4 |
| Component: | Filesystem API | Keywords: | |
| Focuses: | Cc: |
Description (last modified by )
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
@
10 years ago
- Milestone changed from Awaiting Review to 4.4
- Owner set to dd32
- Status changed from new to assigned
#4
@
10 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.
thanks!
ps : @dd32 just posted the same, but i click on "submit" too ;)
ps : @migueluy is it on jetpack or what?
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
10 years ago
#6
@
10 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.
In what world would
wp-admin/includes/file.phpbe loaded, yetwp-includes/pluggable.phpisn'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.phpmanually and callingwp_tempnam()immediately.. If so that plugin is doing two main things wrong, 1) Performing expensive operations on every pageload, 2) Not waiting untilplugins_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 falseif it's called that early.. the other option of course is less harsh and just not use a random folder..