original_string: public function poll_conversion(conversion $conversion) {
          $format = $conversion->get('targetformat');
          $file = $conversion->get_sourcefile();
  
          if ($conversion->get('status') == conversion::STATUS_IN_PROGRESS) {
              // The current conversion is in progress.
              // Check for updates.
              if ($instance = $conversion->get_converter_instance()) {
                  $instance->poll_conversion_status($conversion);
              } else {
                  // Unable to fetch the converter instance.
                  // Reset the status back to PENDING so that it may be picked up again.
                  $conversion->set('status', conversion::STATUS_PENDING);
              }
              $conversion->update();
          }
  
          // Refresh the status.
          $status = $conversion->get('status');
          if ($status === conversion::STATUS_PENDING || $status === conversion::STATUS_FAILED) {
              // The current status is either pending or failed.
              // Attempt to pick up a new converter and convert the document.
              $from = pathinfo($file->get_filename(), PATHINFO_EXTENSION);
              $converters = $this->get_document_converter_classes($from, $format);
              $currentconverter = $this->get_next_converter($converters, $conversion->get('converter'));
  
              if (!$currentconverter) {
                  // No more converters available.
                  $conversion->set('status', conversion::STATUS_FAILED);
                  $conversion->update();
                  return $this;
              }
  
              do {
                  $conversion
                      ->set('converter', $currentconverter)
                      ->set('status', conversion::STATUS_IN_PROGRESS)
                      ->update();
  
                  $instance = $conversion->get_converter_instance();
                  $instance->start_document_conversion($conversion);
                  $failed = $conversion->get('status') === conversion::STATUS_FAILED;
                  $currentconverter = $this->get_next_converter($converters, $currentconverter);
              } while ($failed && $currentconverter);
  
              $conversion->update();
          }
  
          return $this;
      }
code: public function poll_conversion(conversion $conversion) {
          $format = $conversion->get('targetformat');
          $file = $conversion->get_sourcefile();
  
          if ($conversion->get('status') == conversion::STATUS_IN_PROGRESS) {
              // The current conversion is in progress.
              // Check for updates.
              if ($instance = $conversion->get_converter_instance()) {
                  $instance->poll_conversion_status($conversion);
              } else {
                  // Unable to fetch the converter instance.
                  // Reset the status back to PENDING so that it may be picked up again.
                  $conversion->set('status', conversion::STATUS_PENDING);
              }
              $conversion->update();
          }
  
          // Refresh the status.
          $status = $conversion->get('status');
          if ($status === conversion::STATUS_PENDING || $status === conversion::STATUS_FAILED) {
              // The current status is either pending or failed.
              // Attempt to pick up a new converter and convert the document.
              $from = pathinfo($file->get_filename(), PATHINFO_EXTENSION);
              $converters = $this->get_document_converter_classes($from, $format);
              $currentconverter = $this->get_next_converter($converters, $conversion->get('converter'));
  
              if (!$currentconverter) {
                  // No more converters available.
                  $conversion->set('status', conversion::STATUS_FAILED);
                  $conversion->update();
                  return $this;
              }
  
              do {
                  $conversion
                      ->set('converter', $currentconverter)
                      ->set('status', conversion::STATUS_IN_PROGRESS)
                      ->update();
  
                  $instance = $conversion->get_converter_instance();
                  $instance->start_document_conversion($conversion);
                  $failed = $conversion->get('status') === conversion::STATUS_FAILED;
                  $currentconverter = $this->get_next_converter($converters, $currentconverter);
              } while ($failed && $currentconverter);
  
              $conversion->update();
          }
  
          return $this;
      }
code_tokens: public function poll_conversion ( conversion $ conversion ) { $ format = $ conversion -> get ( 'targetformat' ) ; $ file = $ conversion -> get_sourcefile ( ) ; if ( $ conversion -> get ( 'status' ) == conversion :: STATUS_IN_PROGRESS ) { // The current conversion is in progress. // Check for updates. if ( $ instance = $ conversion -> get_converter_instance ( ) ) { $ instance -> poll_conversion_status ( $ conversion ) ; } else { // Unable to fetch the converter instance. // Reset the status back to PENDING so that it may be picked up again. $ conversion -> set ( 'status' , conversion :: STATUS_PENDING ) ; } $ conversion -> update ( ) ; } // Refresh the status. $ status = $ conversion -> get ( 'status' ) ; if ( $ status === conversion :: STATUS_PENDING || $ status === conversion :: STATUS_FAILED ) { // The current status is either pending or failed. // Attempt to pick up a new converter and convert the document. $ from = pathinfo ( $ file -> get_filename ( ) , PATHINFO_EXTENSION ) ; $ converters = $ this -> get_document_converter_classes ( $ from , $ format ) ; $ currentconverter = $ this -> get_next_converter ( $ converters , $ conversion -> get ( 'converter' ) ) ; if ( ! $ currentconverter ) { // No more converters available. $ conversion -> set ( 'status' , conversion :: STATUS_FAILED ) ; $ conversion -> update ( ) ; return $ this ; } do { $ conversion -> set ( 'converter' , $ currentconverter ) -> set ( 'status' , conversion :: STATUS_IN_PROGRESS ) -> update ( ) ; $ instance = $ conversion -> get_converter_instance ( ) ; $ instance -> start_document_conversion ( $ conversion ) ; $ failed = $ conversion -> get ( 'status' ) === conversion :: STATUS_FAILED ; $ currentconverter = $ this -> get_next_converter ( $ converters , $ currentconverter ) ; } while ( $ failed && $ currentconverter ) ; $ conversion -> update ( ) ; } return $ this ; }
docstring: Poll for updates to the supplied conversion.
  
  @param   conversion $conversion The conversion in progress
  @return  $this
docstring_tokens: Poll for updates to the supplied conversion .