Download & Extend

Add parameters to clear static variables in functions

Project:FCKeditor - WYSIWYG HTML editor
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:minor
Assigned:Jorrit
Status:closed (fixed)

Issue Summary

When programatically adjusting fckeditor profiles (for example when using install profiles, or scripting site updates) it is often necessary to save and load fckeditor profiles through code.

Consider this scenario :

1. update hook 1 updates the fckeditor profile to add something to it, it first loads the profile with fckeditor_load_profile.
2. the same hook makes its changes and saves the profile with fckeditor_save_profile
3. A different hook then wishes to update the profile again. It loads the profile with fckeditor_load_profile BUT because this function maintains a static variable (cache) the origional profile is returned (the same profile returned in step1 and not the updated profile we saved in step2).

Suggested solution - add the ability to "reset" the static variable in the profile_load function, and then call this reset in the profile_save function.

Comments

#1

Assigned to:Anonymous» Artur Formella

#2

Status:active» needs review

After patching some functions will have a new parameter:

function fckeditor_profile_load($name='', $clear = FALSE);
function fckeditor_user_get_profile($user, $clear = FALSE);
function fckeditor_sorted_roles($clear = FALSE);

Idea of this patch:

$profiles = fckeditor_profile_load();
/*
save some profile
*/
$profiles1 = fckeditor_profile_load(); // $profiles1=$profiles
$profiles2 = fckeditor_profile_load('', FALSE); // $profiles2=$profiles
$profiles3 = fckeditor_profile_load('', TRUE); // now $profiles3 is correct

AttachmentSize
clearstatic.patch 2.06 KB

#3

Looks good to me

#4

Title:No way of clearing static variable in the profile_load function» Add parameters to clear static variables in functions
Category:bug report» feature request
Assigned to:Artur Formella» Jorrit
Status:needs review» fixed

Fixed in 5.x-2.x, 6.x-1.x and 6.x-2.x.

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here