Exemplo n.º 1
0
 /**
  *
  * @param unknown_type $rs
  */
 private static function &_getObject(Resultset $rs, array $options = array())
 {
     isset($options['loadUsers']) ?: ($options['loadUsers'] = true);
     $ret = new Project();
     $ret->setAvatar($rs->getAvatar());
     $ret->setScmConnectorType($rs->getScmConnectorType());
     $ret->setScmRemoteRepository($rs->getScmRemoteRepository());
     $ret->setScmUsername($rs->getScmUsername());
     $ret->setScmPassword($rs->getScmPassword());
     $ret->setScmCheckChangesTimeout($rs->getScmCheckChangesTimeout());
     $ret->setWorkDir($rs->getWorkDir());
     $ret->setReleaseLabel($rs->getReleaseLabel());
     $ret->setDateCreation($rs->getDateCreation());
     $ret->setDateCheckedForChanges($rs->getDateCheckedForChanges());
     $ret->setDescription($rs->getDescription());
     $ret->setId($rs->getId());
     $specialTasks = @unserialize($rs->getSpecialTasks());
     if ($specialTasks === false) {
         $specialTasks = array();
     }
     $ret->setSpecialTasks($specialTasks);
     $ret->setStatsNumBuilds($rs->getStatsNumBuilds());
     $ret->setStatus($rs->getStatus());
     $ret->setTitle($rs->getTitle());
     $ret->setVisits($rs->getVisits());
     $ret->setOptionReleasePackage($rs->getOptionReleasePackage());
     $ret->setScmEnvVars($rs->getScmEnvVars());
     //
     // Builders
     //
     //
     // The following is a workaround on the fact that the translation of this
     // serialized object to the database gets all broken, due to the fact of PHP
     // introducing NULL bytes around the '*' that is prepended before protected
     // variable members, in the serialized mode. This method replaces those
     // problematic NULL bytes with an identifier string '~~NULL_BYTE~~',
     // rendering serialization and unserialization of these specific kinds of
     // object safe. Credits to travis@travishegner.com on:
     // http://pt.php.net/manual/en/function.serialize.php#96504
     //
     $unsafeSerializedIntegrationBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getIntegrationBuilder());
     if (($integrationBuilder = unserialize($unsafeSerializedIntegrationBuilder)) === false) {
         SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize integration builder for this project [PID={$ret->getId()}]");
         $integrationBuilder = new Build_BuilderElement_Project();
     }
     $ret->setIntegrationBuilder($integrationBuilder);
     $unsafeSerializedDeploymentBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getDeploymentBuilder());
     if (($deploymentBuilder = unserialize($unsafeSerializedDeploymentBuilder)) === false) {
         SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize deployment builder for this project [PID={$ret->getId()}]");
         $deploymentBuilder = new Build_BuilderElement_Project();
     }
     $ret->setDeploymentBuilder($deploymentBuilder);
     if ($options['loadUsers']) {
         $ret->loadUsers();
     }
     $ret->resetSignature();
     return $ret;
 }