Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: live627 on June 10th, 2013, 09:20 AM

Title: Profile controllers cannot be classes
Post by: live627 on June 10th, 2013, 09:20 AM
The profile area (and all other areas) are limited by the old method of procedural function calls, checked by function_exists(). I'd like to ask for this to be changed to is_callable and call_user_func_array throughout.

I already made this change to the profile area like so:

Code: [Select]
@@ -529,7 +529,7 @@
  }
 
  // Make sure that the area function does exist!
- if (!isset($profile_include_data['function']) || !function_exists($profile_include_data['function']))
+ if (!isset($profile_include_data['function']) || !is_callable($profile_include_data['function']))
  {
  destroyMenu();
  fatal_lang_error('no_access', false);
@@ -696,7 +696,7 @@
  redirectexit('action=profile' . (we::$user['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
 
  // Call the appropriate subaction function.
- $profile_include_data['function']($memID);
+ call_user_func_array($profile_include_data['function'], array($memID));
 
  // Set the page title if it's not already set...
  if (!isset($context['page_title']))

Sample code to make use of this:

Code: [Select]
'function' => array('Awards\Profile', 'showAwards'),
Title: Re: Profile controllers cannot be classes
Post by: Arantor on June 10th, 2013, 03:39 PM
Yeah, it's bugged me for a while - r2162 fixes that (and replicates the function to scheduled tasks)
Title: Re: Profile controllers cannot be classes
Post by: live627 on June 11th, 2013, 08:05 AM
Are you also going to fix up any other area, such as admin?
Title: Re: Profile controllers cannot be classes
Post by: Arantor on June 11th, 2013, 04:27 PM
Yeah, don't see why not.
Title: Re: Profile controllers cannot be classes
Post by: live627 on June 11th, 2013, 06:22 PM
Thank you.
Title: Re: Profile controllers cannot be classes
Post by: Arantor on June 11th, 2013, 06:23 PM
So, admin menu, moderate menu, what else?
Title: Re: Profile controllers cannot be classes
Post by: live627 on June 11th, 2013, 06:31 PM
Media menu