<commit_before><?php

class FrontendEditing
{
    public static $ForceEditable   = false;
    public static $EditableClasses = array();

    /**
     * Remember the classname and the ID for the given $dbField
     * @param DBField $dbField
     * @param $value
     * @param null $record
     */
    public static function setValue(DBField $dbField, $value, $record = null)
    {
        $canEdit = (Controller::curr() instanceof Page_Controller && Controller::curr()->data()->canEdit());
        if (!$canEdit) {
            $canEdit = is_object($record) && in_array(get_class($record), self::$EditableClasses) && method_exists($record, 'canEdit') && $record->canEdit();
        }
        if ($canEdit && $record && is_object($record) && $dbField->getName()) {
            $dbField->makeEditable  = true;
            $dbField->editClassName = $record->ClassName;
            $dbField->editID        = $record->ID;
        }<commit_msg>Check we have a current controller before testing type<commit_after><?php

class FrontendEditing
{
    public static $ForceEditable   = false;
    public static $EditableClasses = array();

    /**
     * Remember the classname and the ID for the given $dbField
     * @param DBField $dbField
     * @param $value
     * @param null $record
     */
    public static function setValue(DBField $dbField, $value, $record = null)
    {
        $canEdit = Controller::has_curr() && (Controller::curr() instanceof Page_Controller && Controller::curr()->data()->canEdit());
        if (!$canEdit) {
            $canEdit = is_object($record) && in_array(get_class($record), self::$EditableClasses) && method_exists($record, 'canEdit') && $record->canEdit();
        }
        if ($canEdit && $record && is_object($record) && $dbField->getName()) {
            $dbField->makeEditable  = true;
            $dbField->editClassName = $record->ClassName;
            $dbField->editID        = $record->ID;
        }
{'fraction_non_alphanumeric': 0.14853017019082002, 'fraction_numerical': 0.0, 'mean_word_length': 2.8877755511022043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3076063', 'n_tokens_mistral': 548, 'n_tokens_neox': 550, 'n_words': 133}