Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-12097

The validate_data() function doesn't work with class method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.1.0-b3
    • 3.1.0-a3
    • Extensions
    • PHP 5.5.5, MySQL 5.5.16, Apache 2.4.4, Firefox 26

      With phpBB 3.1 extensions, from now on we use class and class method, so, when a form is submited and checks data, validate_data() is used and should accept class method, like this:

      		$data2 = array(
      			'back'			=>		array(
      				array(array($link, 'link_back'), true)),
      		);
      

      The validate_link_back function doesn't exist, but the $link class validate_link_back methode does, so, validate_data() should work with functions and methods.

      I edited this function like this:

      		foreach ($val_seq as $validate)
      		{
      			$function = array_shift($validate);
      			array_unshift($validate, $data[$var]);
       
      			if(is_array($function))
      			{
      				$result = call_user_func_array(array($function[0], 'validate_'.$function[1]), $validate);
      			}
      			else
      			{
      				$function_prefix = (function_exists('phpbb_validate_' . $function)) ? 'phpbb_validate_' : 'validate_';
      				$result = call_user_func_array($function_prefix . $function, $validate);
      			}
      			
      			if($result)
      			{
      				// Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
      				$error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
      			}
      		}
      

      it works in both cases, but it's just an idea of ​​how to do it

            nickvergessen Joas Schilling
            ErnadoO Erwan Nader
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: