ryandao/silverstripe-payment

Config static calls and performance

Closed this issue · 2 comments

With people mentioning that calls to config incur a performance hit:
https://groups.google.com/forum/?fromgroups#!topic/silverstripe-dev/LLI2W7Tf6Z4

Perhaps we should change from using static calls for stuff like payment environment and authentication details:
https://github.com/ryandao/silverstripe-payment/blob/1.0/code/PaymentGateway.php#L46

to using instance methods and lazy loading? e.g:

  public function getConfig() {
    if (!$this->config) {
      $this->config = Config::inst()->get('PaystationGateway', self::get_environment());
    }
    return $this->config;
  }

This is not a complete example, still makes use of get_environment() but you get the idea. Any particular reason these types of functions are public static?

I assume they are static because that's just the way it used to work. I'm guessing the performance hit won't be particularly noticeable for payment processing/integration... it's not a feature that shows up on every page.

Agree with Jeremy, probably not a big deal.