Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

enables bad autoloaders to be used. #35

Closed
wants to merge 1 commit into from

4 participants

@qzio

when a bootstrap with a bad autoloader is included in a job,
that bootstrap needs to require all the jobs.
this commit makes it possible.

without this fix. all jobs needs to have dedicated workers.


Let me know if you want me to create a zip with examples of how stuff breaks without this fix.

@qzio qzio enables bad autoloaders to be used.
when an autoloader is included in a job,
that bootstrap needs to require all the jobs.

this makes it possible.
229f69e
@qzio qzio referenced this pull request
Closed

Load objects fix #33

@till

Can you explain the 'bad autoloader' part?

I don't understand why a workaround is necessary in upstream when the autoloader is bad. Maybe fix the autoloader to be good? :-)

@qzio

Well, true :)

But there might be others who also have somewhat "bad" auto loaders. And (as far as I know...) the fix shouldn't break anything.

The reason this fix was needed for us is because the autoloader we are using throws an exception if the (potential) file for that class isn't found.

I just thought it would be nice to share the fix we had to implement to get around our particular edge case.
If it doesn't belong in upstream please go ahead and close this pull request. :)

@rhowardiv rhowardiv referenced this pull request in SnapInteractive/GearmanManager
Merged

Separate worker obj instantiation from exists check #5

@rhowardiv

Helped me out, thanks. I was looking to rewrite that section of code in order to separate out the worker object creation from the class_exists check, and saw that you did it first--nice work.

@brianlmoon brianlmoon closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2012
  1. @qzio

    enables bad autoloaders to be used.

    qzio authored
    when an autoloader is included in a job,
    that bootstrap needs to require all the jobs.
    
    this makes it possible.
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 21 deletions.
  1. +15 −21 pecl-manager.php
View
36 pecl-manager.php
@@ -105,26 +105,23 @@ public function do_job($job) {
$func = $job_name;
}
- if(empty($objects[$job_name]) && !function_exists($func) && !class_exists($func)){
-
- if(!isset($this->functions[$job_name])){
- $this->log("Function $func is not a registered job name");
- return;
+ if(!isset($this->functions[$job_name])){
+ $this->log("Function $func is not a registered job name");
+ return;
+ }
+ if (empty($objects[$job_name])) {
+ if (!function_exists($func) && !class_exists($func)){
+ require_once $this->functions[$job_name]["path"];
}
-
- require_once $this->functions[$job_name]["path"];
-
- if(class_exists($func) && method_exists($func, "run")){
-
- $this->log("Creating a $func object", GearmanManager::LOG_LEVEL_WORKER_INFO);
- $objects[$job_name] = new $func();
-
- } elseif(!function_exists($func)) {
-
- $this->log("Function $func not found");
- return;
+ if (!function_exists($func)){
+ if (class_exists($func) && method_exists($func, "run")){
+ $this->log("Creating a $func object", GearmanManager::LOG_LEVEL_WORKER_INFO);
+ $objects[$job_name] = new $func();
+ } else {
+ $this->log("function $job_name could not be loaded");
+ return;
+ }
}
-
}
$this->log("($h) Starting Job: $job_name", GearmanManager::LOG_LEVEL_WORKER_INFO);
@@ -217,6 +214,3 @@ protected function validate_lib_workers() {
}
$mgr = new GearmanPeclManager();
-
-?>
-
Something went wrong with that request. Please try again.