original_string: protected function update_from_expiry_info(\stdClass $expiryrecord) {
          if ($isanyexpired = $expiryrecord->info->is_any_expired()) {
              // The context is expired in some fashion.
              // Create or update as required.
              if ($expiryrecord->record->expiredctxid) {
                  $expiredcontext = new expired_context(null, expired_context::extract_record($expiryrecord->record, 'expiredctx'));
                  $expiredcontext->update_from_expiry_info($expiryrecord->info);
  
                  if ($expiredcontext->is_complete()) {
                      return null;
                  }
              } else {
                  $expiredcontext = expired_context::create_from_expiry_info($expiryrecord->context, $expiryrecord->info);
              }
  
              if ($expiryrecord->context instanceof \context_user) {
                  $userassignments = $this->get_role_users_for_expired_context($expiredcontext, $expiryrecord->context);
                  if (!empty($userassignments->unexpired)) {
                      $expiredcontext->delete();
  
                      return null;
                  }
              }
  
              return $expiredcontext;
          } else {
              // The context is not expired.
              if ($expiryrecord->record->expiredctxid) {
                  // There was previously an expired context record, but it is no longer relevant.
                  // Delete it to be on the safe side.
                  $expiredcontext = new expired_context(null, expired_context::extract_record($expiryrecord->record, 'expiredctx'));
                  $expiredcontext->delete();
              }
  
              return null;
          }
      }
code: protected function update_from_expiry_info(\stdClass $expiryrecord) {
          if ($isanyexpired = $expiryrecord->info->is_any_expired()) {
              // The context is expired in some fashion.
              // Create or update as required.
              if ($expiryrecord->record->expiredctxid) {
                  $expiredcontext = new expired_context(null, expired_context::extract_record($expiryrecord->record, 'expiredctx'));
                  $expiredcontext->update_from_expiry_info($expiryrecord->info);
  
                  if ($expiredcontext->is_complete()) {
                      return null;
                  }
              } else {
                  $expiredcontext = expired_context::create_from_expiry_info($expiryrecord->context, $expiryrecord->info);
              }
  
              if ($expiryrecord->context instanceof \context_user) {
                  $userassignments = $this->get_role_users_for_expired_context($expiredcontext, $expiryrecord->context);
                  if (!empty($userassignments->unexpired)) {
                      $expiredcontext->delete();
  
                      return null;
                  }
              }
  
              return $expiredcontext;
          } else {
              // The context is not expired.
              if ($expiryrecord->record->expiredctxid) {
                  // There was previously an expired context record, but it is no longer relevant.
                  // Delete it to be on the safe side.
                  $expiredcontext = new expired_context(null, expired_context::extract_record($expiryrecord->record, 'expiredctx'));
                  $expiredcontext->delete();
              }
  
              return null;
          }
      }
code_tokens: protected function update_from_expiry_info ( \ stdClass $ expiryrecord ) { if ( $ isanyexpired = $ expiryrecord -> info -> is_any_expired ( ) ) { // The context is expired in some fashion. // Create or update as required. if ( $ expiryrecord -> record -> expiredctxid ) { $ expiredcontext = new expired_context ( null , expired_context :: extract_record ( $ expiryrecord -> record , 'expiredctx' ) ) ; $ expiredcontext -> update_from_expiry_info ( $ expiryrecord -> info ) ; if ( $ expiredcontext -> is_complete ( ) ) { return null ; } } else { $ expiredcontext = expired_context :: create_from_expiry_info ( $ expiryrecord -> context , $ expiryrecord -> info ) ; } if ( $ expiryrecord -> context instanceof \ context_user ) { $ userassignments = $ this -> get_role_users_for_expired_context ( $ expiredcontext , $ expiryrecord -> context ) ; if ( ! empty ( $ userassignments -> unexpired ) ) { $ expiredcontext -> delete ( ) ; return null ; } } return $ expiredcontext ; } else { // The context is not expired. if ( $ expiryrecord -> record -> expiredctxid ) { // There was previously an expired context record, but it is no longer relevant. // Delete it to be on the safe side. $ expiredcontext = new expired_context ( null , expired_context :: extract_record ( $ expiryrecord -> record , 'expiredctx' ) ) ; $ expiredcontext -> delete ( ) ; } return null ; } }
docstring: Update or delete the expired_context from the expiry_info object.
  This function depends upon the data structure returned from get_nested_expiry_info.
  
  If the context is expired in any way, then an expired_context will be returned, otherwise null will be returned.
  
  @param   \stdClass   $expiryrecord
  @return  expired_context|null
docstring_tokens: Update or delete the expired_context from the expiry_info object . This function depends upon the data structure returned from get_nested_expiry_info .