This is a follow up to #587572: uc_price is undefined in uc_order_get_total() and sets out to standardise the use of require_once().

CommentFileSizeAuthor
#1 599572_require_once.patch5.63 KBfenstrat

Comments

fenstrat’s picture

Status: Active » Needs review
StatusFileSize
new5.63 KB
univate’s picture

Total agree, I think some consideration should also be taken as to whether those require_once at the top of files need to be there and if they can be loaded more dynamically?

I suspect they can't for the CA stuff, if that is the case then how about using the hook_init() instead to include those files? and then you can use the module_load_include() function instead.

This is what I have done in the uc_recurring module

/**
 * Implementation of hook_init().
 */
function uc_recurring_init() {
  module_load_include('inc', 'uc_recurring', 'uc_recurring.ca');
}

Taking this a step further it might be good to see CA handled similar to the way views works where you register views support via hook_views(), meaning the CA stuff could just be loaded when its actually required rather then on every page load.

e.g.

function hook_ca() {
  return array(
    ...
  );
}
tr’s picture

Status: Needs review » Postponed (maintainer needs more info)

I guess my question is, why do this? Drupal coding standards are mum on the subject, however Drupal core uniformly uses the form require_once './path/to/file.inc';, not even bothering with the parentheses. So is this just a matter of your style is different than what Ubercart uses, or is there another reason I don't know about?

I see the two places you changed to module_load_include(), and that's fine. I also think univate has a good point in #2, if someone wants to roll a patch to accomplish that.

tr’s picture

I committed the changes from require_once() to module_load_include(). I don't see the point of any of the other changes. I still think univate's suggestions as to dynamic loading make sense, so I'm going to leave the issue open.

univate’s picture

Priority: Normal » Minor

Since CA is being dropped for rules in ubercart-3.x it probably doesn't make sense to make large changes in CA.

fenstrat’s picture

Status: Postponed (maintainer needs more info) » Fixed

Can appreciate why there was no commit on the require_once changes, there appears to be no uniform standard anywhere.

module_load_include() is standard, glad to see it committed.

As for the CA changes I agree with univate, so marking as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.