CBPAllWorkflowPersister::RetrieveWorkflow: Bitrix method

      
<?php 
//  CBPAllWorkflowPersister :: RetrieveWorkflow()
//  /dist/bitrix/modules/bizproc/classes/general/workflowpersister.php:41

    
protected function RetrieveWorkflow($instanceId$silent false)
    {
        global 
$DB;

        
$queryCondition $this->getLockerQueryCondition();

        
$buffer "";
        
$dbResult $DB->Query(
            
"SELECT WORKFLOW, IF (".$queryCondition.", 'Y', 'N') as UPDATEABLE ".
            
"FROM b_bp_workflow_instance ".
            
"WHERE ID = '".$DB->ForSql($instanceId)."' "
        
);
        if (
$arResult $dbResult->Fetch())
        {
            if (
$arResult["UPDATEABLE"] == "Y" && !$silent)
            {
                
$DB->Query(
                    
"UPDATE b_bp_workflow_instance SET ".
                    
"    OWNER_ID = '".$DB->ForSql($this->serviceInstanceId)."', ".
                    
"    OWNED_UNTIL = ".$DB->CharToDateFunction(date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $this->GetOwnershipTimeout()))." ".
                    
"WHERE ID = '".$DB->ForSql($instanceId)."'"
                
);
            }
            elseif (!
$silent)
            {
                throw new 
Exception(GetMessage("BPCGWP_WF_LOCKED"), \CBPRuntime::EXCEPTION_CODE_INSTANCE_LOCKED);
            }
            
$buffer $arResult["WORKFLOW"];
        }
        else
        {
            throw new 
Exception(GetMessage("BPCGWP_INVALID_WF"), \CBPRuntime::EXCEPTION_CODE_INSTANCE_NOT_FOUND);
        }

        return 
$buffer;
    }