[WebProfilerBundle ] Fixed an edge case on WDT loading
This commit is contained in:
parent
67be44737e
commit
9d885ed898
@ -239,7 +239,7 @@ class ProfilerController
|
|||||||
$this->profiler->disable();
|
$this->profiler->disable();
|
||||||
|
|
||||||
if (!$profile = $this->profiler->loadProfile($token)) {
|
if (!$profile = $this->profiler->loadProfile($token)) {
|
||||||
return new Response('', 200, array('Content-Type' => 'text/html'));
|
return new Response('', 404, array('Content-Type' => 'text/html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// the toolbar position (top, bottom, normal, or null -- use the configuration)
|
// the toolbar position (top, bottom, normal, or null -- use the configuration)
|
||||||
|
@ -9,12 +9,26 @@
|
|||||||
request = function(url, onSuccess, onError, payload, options) {
|
request = function(url, onSuccess, onError, payload, options) {
|
||||||
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
options.maxTries = options.maxTries || 0;
|
||||||
xhr.open(options.method || 'GET', url, true);
|
xhr.open(options.method || 'GET', url, true);
|
||||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||||
xhr.onreadystatechange = function(state) {
|
xhr.onreadystatechange = function(state) {
|
||||||
if (4 === xhr.readyState && 200 === xhr.status) {
|
if (4 !== xhr.readyState) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xhr.status == 404 && options.maxTries > 1) {
|
||||||
|
setTimeout(function(){
|
||||||
|
options.maxTries--;
|
||||||
|
request(url, onSuccess, onError, payload, options);
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (200 === xhr.status) {
|
||||||
(onSuccess || noop)(xhr);
|
(onSuccess || noop)(xhr);
|
||||||
} else if (4 === xhr.readyState && xhr.status != 200) {
|
} else {
|
||||||
(onError || noop)(xhr);
|
(onError || noop)(xhr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -75,6 +89,7 @@
|
|||||||
(onSuccess || noop)(xhr, el);
|
(onSuccess || noop)(xhr, el);
|
||||||
},
|
},
|
||||||
function(xhr) { (onError || noop)(xhr, el); },
|
function(xhr) { (onError || noop)(xhr, el); },
|
||||||
|
'',
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
if (xhr.status !== 0) {
|
if (xhr.status !== 0) {
|
||||||
confirm('An error occurred while loading the web debug toolbar (' + xhr.status + ': ' + xhr.statusText + ').\n\nDo you want to open the profiler?') && (window.location = '{{ path("_profiler", { "token": token }) }}');
|
confirm('An error occurred while loading the web debug toolbar (' + xhr.status + ': ' + xhr.statusText + ').\n\nDo you want to open the profiler?') && (window.location = '{{ path("_profiler", { "token": token }) }}');
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
{'maxTries': 5}
|
||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
/*]]>*/</script>
|
/*]]>*/</script>
|
||||||
|
Reference in New Issue
Block a user