Permalink
Browse files

Avoid losing previous values on static variables

If we initialize each time the variable, we lose previous changes, so for
example cache variables are retrieved every call.
  • Loading branch information...
1 parent 1a753cd commit e847e491e527fd432845bc1e01addf6a9a5611c2 @marvil07 committed Jul 10, 2009
Showing with 15 additions and 3 deletions.
  1. +3 −0 versioncontrol-backend.inc
  2. +12 −3 versioncontrol.module
View
3 versioncontrol-backend.inc
@@ -161,6 +161,9 @@ function versioncontrol_get_access_errors() {
*/
function _versioncontrol_access_errors($new_messages = NULL) {
static $error_messages = array();
+ if (!isset($error_messages)) {
+ $error_messages = array();
+ }
if (isset($new_messages)) {
$error_messages = $new_messages;
View
15 versioncontrol.module
@@ -677,7 +677,10 @@ function versioncontrol_get_repository($repo_id) {
* an empty array is returned.
*/
function versioncontrol_get_repositories($constraints = array()) {
- static $repository_cache = array();
+ static $repository_cache;
+ if (!isset($repository_cache)) {
+ $repository_cache = array();
+ }
$backends = versioncontrol_get_backends();
$auth_methods = versioncontrol_get_authorization_methods();
@@ -1353,7 +1356,10 @@ function _versioncontrol_construct_operation_query(&$constraints, &$tables) {
* elements 'callback' and 'cardinality'.
*/
function _versioncontrol_operation_constraint_info() {
- static $constraint_info = array();
+ static $constraint_info;
+ if (!isset($constraint_info)) {
+ $constraint_info = array();
+ }
if (empty($constraint_info)) {
foreach (module_implements('versioncontrol_operation_constraint_info') as $module) {
@@ -3032,7 +3038,10 @@ function versioncontrol_get_url_tracker($repository, $issue_id) {
* - 'tracker': The issue/bug/case URL of the associated issue tracker.
*/
function _versioncontrol_get_repository_urls($repository) {
- static $urls_by_repository = array();
+ static $urls_by_repository;
+ if (!isset($urls_by_repository)) {
+ $urls_by_repository = array();
+ }
if (!isset($urls_by_repository[$repository['repo_id']])) {
$result = db_query('SELECT * FROM {versioncontrol_repository_urls}

0 comments on commit e847e49

Please sign in to comment.