Opened 18 years ago
Closed 17 years ago
#1 closed defect (invalid)
svn -m 'missing s on backpress_cookie_settings(), allow db setup to be bypassed via $type=false' ci
| Reported by: | apokalyptik | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Keywords: | Cc: |
Description
I cant commit (no permissions), so here :D
Index: backpress.php
===================================================================
--- backpress.php (revision 2)
+++ backpress.php (working copy)
@@ -50,13 +50,14 @@
'write' => 1
);
- $db_args = wp_parse_args( $db_args, $db_defaults );
- extract( $db_args, EXTR_SKIP );
+ if ( false !== $type ) {
+ $db_args = wp_parse_args( $db_args, $db_defaults );
+ extract( $db_args, EXTR_SKIP );
- // Add to hyperdb's server list
- if ( !isset($db_servers[$dataset]) )
- add_db_server( $dataset, $partition, $datacenter, $read, $write, $host, $localhost, $name, $user, $password );
-
+ // Add to hyperdb's server list
+ if ( !isset($db_servers[$dataset]) )
+ add_db_server( $dataset, $partition, $datacenter, $read, $write, $host, $localhost, $name, $user, $password );
+ }
// Reference HyperDB and mirror it's useful properties here
$this->db =& $hyperdb;
foreach ( array('insert_id', 'last_query', 'num_queries', 'queries', 'last_result', 'func_call', 'rows_affected', 'result') as $prop )
@@ -83,7 +84,7 @@
$this->cookie = false;
$cookie_defaults = array( 'user' => 'backpress_user', 'pass' => 'backpress_pass', 'path' => '', 'sitepath' => '', 'domain' => '' );
- if ( $cookie || !backpress_cookie_setting( $this ) )
+ if ( $cookie || !backpress_cookie_settings( $this ) )
$this->cookie = wp_parse_args( $cookie, $cookie_defaults );
$GLOBALS['backpresses'][$this->id] =& $this;
Change History (2)
comment:1 Changed 18 years ago by
comment:2 Changed 17 years ago by
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
These files are long superseded I believe.
Note: See
TracTickets for help on using
tickets.

This is a better patch (after I started understanding some of the concepts)
=================================================================== --- pluggable.php (revision 2) +++ pluggable.php (working copy) @@ -129,4 +129,11 @@ } endif; +// Checks whether a value could possibly be an ID +if ( !function_exists('is_backpress_id') ) { + function is_backpress_id($data) { + return is_numeric($data); + } +} + ?> Index: backpress.php =================================================================== --- backpress.php (revision 2) +++ backpress.php (working copy) @@ -50,12 +50,14 @@ 'write' => 1 ); - $db_args = wp_parse_args( $db_args, $db_defaults ); - extract( $db_args, EXTR_SKIP ); + if ( NULL !== $db_args ) { + $db_args = wp_parse_args( $db_args, $db_defaults ); + extract( $db_args, EXTR_SKIP ); - // Add to hyperdb's server list - if ( !isset($db_servers[$dataset]) ) - add_db_server( $dataset, $partition, $datacenter, $read, $write, $host, $localhost, $name, $user, $password ); + // Add to hyperdb's server list + if ( !isset($db_servers[$dataset]) ) + add_db_server( $dataset, $partition, $datacenter, $read, $write, $host, $localhost, $name, $user, $password ); + } // Reference HyperDB and mirror it's useful properties here $this->db =& $hyperdb; @@ -83,7 +85,7 @@ $this->cookie = false; $cookie_defaults = array( 'user' => 'backpress_user', 'pass' => 'backpress_pass', 'path' => '', 'sitepath' => '', 'domain' => '' ); - if ( $cookie || !backpress_cookie_setting( $this ) ) + if ( $cookie || !backpress_cookie_settings( $this ) ) $this->cookie = wp_parse_args( $cookie, $cookie_defaults ); $GLOBALS['backpresses'][$this->id] =& $this; Index: user.php =================================================================== --- user.php (revision 2) +++ user.php (working copy) @@ -22,7 +22,9 @@ extract( $args, EXTR_SKIP ); - $ID = (int) $ID; + if ( !is_backpack_id($ID) ) + $ID = (int) $ID; + $user_login = backpress_sanitize_user( $user_login, true ); $user_nicename = backpress_sanitize_slug( $user_login ); if ( !$user_login || !$user_nicename ) @@ -50,23 +52,17 @@ if ( !$display_name ) $display_name = $user_login; - if ( $ID ) { - $db_return = $backpress->query( - $backpress->prepare( - "INSERT INTO $backpress->users ( user_login, user_nicename, user_email, user_url, user_pass, user_registered, display_name, user_status ) VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%d' )", - $user_login, $user_nicename, $user_email, $user_url, $user_pass, $user_registered, $display_name, $user_status - ) - ); - } else { - $db_return = $backpress->query( - $backpress->prepare( - "UPDATE $backpress->users SET user_login = '%s', user_nicename = '%s', user_email = '%s', user_url = '%s', user_pass = '%s', user_registered = '%s', display_name = '%s', user_status = '%d' WHERE ID = '%d'", - $user_login, $user_nicename, $user_email, $user_url, $user_pass, $user_registered, $display_name, $user_status, $ID - ) - ); - $ID = (int) $db_return; + $users_table = empty($backpress->db->users) ? $backpress->table_prefix . "users" : $backpress->db->users; + $db_return = NULL; + if ( $ID && NULL !== $backpress->db->get_var("SELECT ID FROM $users_table WHERE ID = '$ID'") ) { + unset($args['ID']); + unset($args['user_registered']); + $db_return = $backpress->db->update($users_table, $args, array("ID" => $ID)); } - + if ( $db_return === null ) { + $db_return = $backpress->db->insert($users_table, $args); + } + if ( !$db_return ) return new WP_Error( 'BackPress::query', __('Query failed') );