hook_exit() takes some effort to avoid triggering the autoloader if no logging is going to happen, but only after the autoloader has already been triggered for the same class.

Attached patch just moves the check to the top.

Comments

catch’s picture

Status: Active » Needs review
StatusFileSize
new956 bytes

Here's the patch. On my local this takes about 8-10ms unpatched (not sure why, but better to not spend the time at all).

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Why not:)

klausi’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/rules.module
@@ -1326,11 +1326,14 @@ function rules_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+  // For performance avoid unnecessary auto-loading of the RulesLog class.
+  if (!class_exists('RulesLog', FALSE)) {
+    return;
+  }

this function should return a boolean, so return FALSE; would be correct here.

gturnbull’s picture

StatusFileSize
new1.08 KB

Hi Guys,
Here is an updated patch based on the comments provided by klausi.

Hope this helps.

Thanks,
Gordon

gturnbull’s picture

Status: Needs work » Needs review
joelpittet’s picture

Status: Needs review » Needs work

Thanks @gturnbull, could you set the indent to 2 spaces to match the existing code?

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new962 bytes

New patch that fixes #6.

tr’s picture

  • TR committed 1533bc2 on 7.x-2.x authored by catch
    Issue #2153651 by gturnbull, catch, TR, joelpittet, klausi: Autoloader...
tr’s picture

Status: Needs review » Fixed

Committed #7. Thanks all.

joelpittet’s picture

Status: Fixed » Reviewed & tested by the community

Thanks for the update @TR

tr’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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