Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-12097

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

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-a3
    • Fix Version/s: 3.1.0-b3
    • Component/s: Extensions
    • Labels:
    • Environment:
      PHP 5.5.5, MySQL 5.5.16, Apache 2.4.4, Firefox 26

      Description

      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

        Activity

        Hide
        ErnadoO Erwan Nader added a comment -

        Will be fixed before the 3.1 release?

        Show
        ErnadoO Erwan Nader added a comment - Will be fixed before the 3.1 release?
        Hide
        nickvergessen Joas Schilling added a comment -

        I think so

        Show
        nickvergessen Joas Schilling added a comment - I think so

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development