[wp-trac] [WordPress Trac] #15601: Cannot overwrite wp_set_password in pluggable.php

WordPress Trac wp-trac at lists.automattic.com
Sun Nov 28 14:43:23 UTC 2010


#15601: Cannot overwrite wp_set_password in pluggable.php
--------------------------+-------------------------------------------------
 Reporter:  layotte       |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:  3.0.1          
 Severity:  trivial       |    Keywords:                 
--------------------------+-------------------------------------------------
 I was trying to force lowercase passwords (for a client), so I created a
 plugin called (CIP - Case Insensitive Passwords) that overwrote
 wp_set_password to force the password string to lowercase. But
 wp_set_password wouldn't overwrite... I have a test site with 0 plugins
 activated and the default 2010 theme activated. I also didn't see any
 other place where the wp_set_password function was being set:

 {{{
 $ cd latest.phrugal.com/
 $ grep -R wp_set_password *
 wp-content/plugins/CIP/case-insensitive-passwords.php:if (
 !function_exists('wp_set_password') ) {
 wp-content/plugins/CIP/case-insensitive-passwords.php:  function
 wp_set_password( $password, $user_id ) {
 wp-includes/pluggable.php:                      wp_set_password($password,
 $user_id);
 wp-includes/pluggable.php:if ( !function_exists('wp_set_password') ) :
 wp-includes/pluggable.php:function wp_set_password( $password, $user_id )
 {
 wp-login.php:   wp_set_password($new_pass, $user->ID);
 }}}

 In the plugin, without the function_exists check I get this error, "Plugin
 could not be activated because it triggered a fatal error.

 Fatal error: Cannot redeclare wp_set_password() (previously declared in
 /homepages/3/d238924033/htdocs/latest.phrugal.com/wp-
 includes/pluggable.php:1577) in
 /homepages/3/d238924033/htdocs/latest.phrugal.com/wp-content/plugins/CIP
 /case-insensitive-passwords.php on line 23"

 {{{
 function wp_set_password( $password, $user_id ) {
         global $wpdb;
         $password = strtolower( $password );

         $hash = wp_hash_password($password);
         $wpdb->update($wpdb->users, array('user_pass' => $hash,
 'user_activation_key' => ''), array('ID' => $user_id) );

         wp_cache_delete($user_id, 'users');
 }
 }}}

 I am able to achieve what I want by setting the password to lowercase when
 I overwrite wp_hash_password so the issue I'm facing is trivial, but I
 don't understand why I'm having this trouble when trying to overwrite
 wp_set_password.

 This is the actual plugin code - http://wordpress.pastebin.com/su4bBxi2

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15601>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list