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 |
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.

#1
#2
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
#3
Looks good to me
#4
Fixed in 5.x-2.x, 6.x-1.x and 6.x-2.x.
#5
Automatically closed -- issue fixed for 2 weeks with no activity.