+
+ /**
+ * @param string $section
+ * @return ScopedCallback|null
+ */
+ protected function scopedProfileSection( $section ) {
+ if ( $this->profiler ) {
+ call_user_func( [ $this->profiler, 'profileIn' ], $section );
+ return new ScopedCallback( [ $this->profiler, 'profileOut' ] );
+ }
+
+ return null;
+ }
+
+ protected function resetOutputBuffer() {
+ while ( ob_get_status() ) {
+ if ( !ob_end_clean() ) {
+ // Could not remove output buffer handler; abort now
+ // to avoid getting in some kind of infinite loop.
+ break;
+ }
+ }
+ }