<commit_before><?php
class User extends ActiveRecord implements ILinkable {

  protected $hasMany = array('Post' => array('thisKey' => 'user_id'),
    'Comment' => array('thisKey' => 'user_id'),
  );

  protected $belongsTo = array('Group' => array('otherKey' => 'group_id'),);

  protected $validate = array(
    'username' => array('presence' => true,),
    'password' => array('presence' => true,),
    'email' => array('presence' => true, 'email' => true),
    'confirm_password' => array('presence' => true,
      'ruleConfirm' => array('callback' => 'confirmPassword',
        'message' => 'The two passwords are not identical'
      ),
    ),
  );

  protected $fields = array('username' => 'Username', 'email' => 'Email',
    'password' => 'Password', 'confirm_password' => '<PASSWORD>',
  );

  protected $defaults = array('cookie' => '', 'session' => '', 'ip' => '',
    'group_id' => 0,
  );

  public function getRoute() {
    return array('controller' => 'Users', 'action' => 'view',
      'parameters' => array($this->username)
    );
  }

  public function hasPermission($key) {
    return $this->getGroup()
      ->hasPermission($key);
  }

  protected function confirmPassword($value) {
    return $value == $this->password;
  }
}<commit_msg>Fix silent crash when checking permissions<commit_after><?php
class User extends ActiveRecord implements ILinkable {

  protected $hasMany = array('Post' => array('thisKey' => 'user_id'),
    'Comment' => array('thisKey' => 'user_id'),
  );

  protected $belongsTo = array('Group' => array('otherKey' => 'group_id'),);

  protected $validate = array(
    'username' => array('presence' => true,),
    'password' => array('presence' => true,),
    'email' => array('presence' => true, 'email' => true),
    'confirm_password' => array('presence' => true,
      'ruleConfirm' => array('callback' => 'confirmPassword',
        'message' => 'The two passwords are not identical'
      ),
    ),
  );

  protected $fields = array('username' => 'Username', 'email' => 'Email',
    'password' => 'Password', 'confirm_password' => '<PASSWORD>',
  );

  protected $defaults = array('cookie' => '', 'session' => '', 'ip' => '',
    'group_id' => 0,
  );

  public function getRoute() {
    return array('controller' => 'Users', 'action' => 'view',
      'parameters' => array($this->username)
    );
  }

  public function hasPermission($key) {
    return $group AND $group->hasPermission($key);
  }

  protected function confirmPassword($value) {
    return $value == $this->password;
  }
}
{'fraction_non_alphanumeric': 0.2011811023622047, 'fraction_numerical': 0.0007874015748031496, 'mean_word_length': 3.8865384615384615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 70, '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': '613887', 'n_tokens_mistral': 781, 'n_tokens_neox': 763, 'n_words': 178}