Commit 90faebf0 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #286 in ZP/z-push from...

Merge pull request #286 in ZP/z-push from bugfix/ZP-962-problem-with-autoloader-searching to develop

* commit 'c8a22a2c':
  ZP-962 Only unregister ZPush::IncludeBackend if it was previously registered.
  ZP-962 Only unregister ZPush::IncludeBackend if it was previously registered.
  ZP-962 Problem with autoloader searching for non-existing backend.
parents 2bad7648 c8a22a2c
...@@ -577,6 +577,8 @@ class ZPush { ...@@ -577,6 +577,8 @@ class ZPush {
static public function GetBackend() { static public function GetBackend() {
// if the backend is not yet loaded, load backend drivers and instantiate it // if the backend is not yet loaded, load backend drivers and instantiate it
if (!isset(ZPush::$backend)) { if (!isset(ZPush::$backend)) {
$isIbar = false;
// Initialize our backend // Initialize our backend
$ourBackend = @constant('BACKEND_PROVIDER'); $ourBackend = @constant('BACKEND_PROVIDER');
...@@ -594,12 +596,19 @@ class ZPush { ...@@ -594,12 +596,19 @@ class ZPush {
} }
elseif (!class_exists($ourBackend)) { elseif (!class_exists($ourBackend)) {
spl_autoload_register('\ZPush::IncludeBackend'); spl_autoload_register('\ZPush::IncludeBackend');
$isIbar = true;
ZLog::Write(LOGLEVEL_DEBUG, "ZPush::GetBackend(): autoload register ZPush::IncludeBackend");
} }
if (class_exists($ourBackend)) if (class_exists($ourBackend))
ZPush::$backend = new $ourBackend(); ZPush::$backend = new $ourBackend();
else else
throw new FatalMisconfigurationException(sprintf("Backend provider '%s' can not be loaded. Check configuration!", $ourBackend)); throw new FatalMisconfigurationException(sprintf("Backend provider '%s' can not be loaded. Check configuration!", $ourBackend));
if ($isIbar) {
spl_autoload_unregister('\ZPush::IncludeBackend');
ZLog::Write(LOGLEVEL_DEBUG, "ZPush::GetBackend(): autoload unregister ZPush::IncludeBackend");
}
} }
return ZPush::$backend; return ZPush::$backend;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment