Skip to content

Commit

Permalink
Move escaping function to global scope
Browse files Browse the repository at this point in the history
PHP is not python and doesn't have the concept of local functions.
Move the escaping function to the global scope so it isn't
redeclared upon every call to get_sql_contribution().
  • Loading branch information
cpeel committed Aug 1, 2017
1 parent c3cb2fc commit aa35f16
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/project_manager/projectmgr.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ function get_sql_contribution()
if ( in_array( '', $values ) ) return NULL;
}

function escape_callback($value)
{
return mysqli_real_escape_string(DPDatabase::get_connection(), $value);
}
$values = array_map("escape_callback", $values);
$values = array_map("escape_value", $values);

if ( $comparator == '=' )
{
Expand Down Expand Up @@ -1006,5 +1002,10 @@ function list_uber_projects( $can_see_all )
}
}

function escape_value($value)
{
return mysqli_real_escape_string(DPDatabase::get_connection(), $value);
}

// vim: sw=4 ts=4 expandtab
?>

0 comments on commit aa35f16

Please sign in to comment.