FriendsOfSymfony / FOSElasticaBundle

Elasticsearch PHP integration for your Symfony project using Elastica.
http://friendsofsymfony.github.io
MIT License
1.24k stars 795 forks source link

Fix console logger behaviour when populating multiple indexes #1891

Closed bobvandevijver closed 2 years ago

bobvandevijver commented 2 years ago

The existing console logger was broken when populating multiple indexes with a single command execution, as the listeners for the older progress bars were still being called. This caused the progress bar to behave quite interestingly, by not showing the actual progress for any index being populated after the first one.

This PR replaces the old callable by a stateful class, which can be marked as finished when the process is done. By finishing, the progress bar is finished in the output, a new line is written and further calls (from the still bound event handler) are being ignored. To further clean the populate process, the old event listeners are being removed now as well.

Why not keep the static function only and remove the event listeners? I needed something that was capable of closing the progress bar cleanly, and I believe this class is the best solution for this.

Old output

https://user-images.githubusercontent.com/1835343/202021907-6af4f44b-542c-4126-91b2-4cbbfb66ef89.mp4

New output

https://user-images.githubusercontent.com/1835343/202022563-561b2bfe-749f-487a-8b33-cf9af9d5863e.mp4

XWB commented 2 years ago

Looks good :+1: