I would be really nice to have a dialog box showing export progress in real time either in terms of percentage and maybe having some more detailed information like which step/table it is processing. Also, if we can break it down into phases then showing which phase it has completed and which it is currently on.
I'd like to use this progress bar: -
http://jqueryui.com/progressbar/
It sounds to me a fairly achievable task with ajax requests to display in real time the progress.
Your ajax requests would be targeted to what exactly?
To the export related files (like export.lib.php). Can i work on a small solution regarding this? I could paste the screenshot here.
Please do.
Hey Mark, The export bar looks something like this.
The critical part is getting the server responses, and the documentation mentions that every server response is fully buffered. In this case, how can we do real time stuff. Would you recommend using long polling. I happen to have done similar in the past with a stock market project. You can see its video here: - https://www.youtube.com/watch?v=ZJlR7msH7DE. If we can poll export.php, and get the progress it has reached, we could make a real time progress bar. Is there a better way?
I am not familiar with long polling.
Hey Mark, I have a solution with long polling, but there is also an option of using flush() and ob_flush(). However they conflict with the idea of server responses being fully buffered. Would you recommend using those?
We rely on responses being buffered, so the solution must not have an impact on this buffering.
Hey Mark,
I am posting the video link of the solution: - https://www.youtube.com/watch?v=OaDUGSEAaTo
I tried various methods to make the progress real - time. But there are many considerations. First, the download is being handled natively by the browser. Second, the responses are fully buffered, so using flush() and ob_flush() were causing a lot of issues.
Server - Sent events too use flush() and ob_flush() internally, so the issues propogate.
So now I am basically writing the phases the export.php has just finished to a text file. I am long-polling(making a long held ajax get request) another php file, progress.php to check if any changes happened. Everytime something changes in the text file, progress.php picks it up and sends the response. The response is populated in the progress dialog and the bar is changed using javascript.
There are however considerations: - this cycle has to be synchronized. Otherwise sometimes the export.php finishes execution even before the preceding phases are captured as response.
Also, to communicate the idea of "progress" and capture the messages correctly, sleep/usleep functions have been used.
How can this be made better? Is this solution acceptable?
Pranav,
writing to a text file is not ideal as the user needs to ensure that the chosen directory is writable by the web server; so it would require a separate directory for security considerations. Maybe using the session variables would be better?
Hey Mark,
I agree. Resorting to file solutions may not be ideal. Using techniques that work internally within php like session handling is better.
I have modified the solution to work with. I am now long polling a php file which simply echoes a session variable. This session variable is being modified in export.php repeatedly, carrying the various phases as value.
If we can discuss precisely the steps you would like to see in the bar, the solution can be improved. For now I am just displaying stuff like Building File, initializing variables. Precise Steps would communicate more to the user.
For future use, we can also integrate this in other operations.
Thanks
Last edit: Pranav Sharma 2015-03-14
IMO the steps are not that important; what is more important is to see the progression. You can use the "mysql employees sample database" to test a longer export.
I have made a pull request : - https://github.com/phpmyadmin/phpmyadmin/pull/1577