Skip to content

[WebProfilerBundle ] Fixed an edge case on WDT loading #10773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function toolbarAction(Request $request, $token)
$this->profiler->disable();

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@
request = function(url, onSuccess, onError, payload, options) {
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
options = options || {};
options.maxTries = options.maxTries || 0;
xhr.open(options.method || 'GET', url, true);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
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);
} else if (4 === xhr.readyState && xhr.status != 200) {
} else {
(onError || noop)(xhr);
}
};
Expand Down Expand Up @@ -75,6 +89,7 @@
(onSuccess || noop)(xhr, el);
},
function(xhr) { (onError || noop)(xhr, el); },
'',
options
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
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 }) }}');
}
}
},
{'maxTries': 5}
);
})();
/*]]>*/</script>