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.

#2 clearstatic.patch2.06 KBArtur Formella
Members fund testing for the Drupal project. Drupal Association Learn more


Artur Formella’s picture

Assigned: Unassigned » Artur Formella
Artur Formella’s picture

Status: Active » Needs review
2.06 KB

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

Jorrit’s picture

Looks good to me

Jorrit’s picture

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

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

Status: Fixed » Closed (fixed)

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