mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Fix tests
This commit is contained in:
@@ -144,7 +144,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
'pid' => $task->getPID(),
|
||||
'title' => $task->getTitle(),
|
||||
'last_exec_time' => $task->getLastExecTime() ? $task->getLastExecTime()->format(DATE_ATOM) : null,
|
||||
'auto_start' => ! ! $task->isActive(),
|
||||
'auto_start' => !!$task->isActive(),
|
||||
'runner' => $task->getRunner(),
|
||||
'crash_counter' => $task->getCrashCounter()
|
||||
);
|
||||
@@ -186,7 +186,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$taskManager = new \task_manager($app);
|
||||
|
||||
$task = $taskManager->getTask($taskId);
|
||||
if ( ! in_array($task->getState(), array(\task_abstract::STATE_TOSTART, \task_abstract::STATE_STARTED))) {
|
||||
if (!in_array($task->getState(), array(\task_abstract::STATE_TOSTART, \task_abstract::STATE_STARTED))) {
|
||||
$task->setState(\task_abstract::STATE_TOSTART);
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$taskManager = new \task_manager($app);
|
||||
|
||||
$task = $taskManager->getTask($taskId);
|
||||
if ( ! in_array($task->getState(), array(\task_abstract::STATE_TOSTOP, \task_abstract::STATE_STOPPED))) {
|
||||
if (!in_array($task->getState(), array(\task_abstract::STATE_TOSTOP, \task_abstract::STATE_STOPPED))) {
|
||||
$task->setState(\task_abstract::STATE_TOSTOP);
|
||||
}
|
||||
$result->set_datas(array('task' => $this->list_task($task)));
|
||||
@@ -247,7 +247,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
}
|
||||
|
||||
if ($autostart) {
|
||||
$task->setActive( ! ! $autostart);
|
||||
$task->setActive(!!$autostart);
|
||||
}
|
||||
|
||||
$result->set_datas(array('task' => $this->list_task($task)));
|
||||
@@ -615,7 +615,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
|
||||
$fields = $record->get_caption()->get_fields();
|
||||
|
||||
$ret = array();
|
||||
$ret = array('caption_metadatas' => array());
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$ret['caption_metadatas'][] = array(
|
||||
@@ -636,24 +636,24 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
throw new API_V1_exception_badrequest('Missing file parameter');
|
||||
}
|
||||
|
||||
if ( ! $request->files->get('file') instanceof Symfony\Component\HttpFoundation\File\UploadedFile) {
|
||||
if (!$request->files->get('file') instanceof Symfony\Component\HttpFoundation\File\UploadedFile) {
|
||||
throw new API_V1_exception_badrequest('You can upload one file at time');
|
||||
}
|
||||
|
||||
$file = $request->files->get('file');
|
||||
/* @var $file Symfony\Component\HttpFoundation\File\UploadedFile */
|
||||
|
||||
if ( ! $file->isValid()) {
|
||||
if (!$file->isValid()) {
|
||||
throw new API_V1_exception_badrequest('Datas corrupted, please try again');
|
||||
}
|
||||
|
||||
if ( ! $request->get('base_id')) {
|
||||
if (!$request->get('base_id')) {
|
||||
throw new API_V1_exception_badrequest('Missing base_id parameter');
|
||||
}
|
||||
|
||||
$collection = \collection::get_from_base_id($this->app, $request->get('base_id'));
|
||||
|
||||
if ( ! $app['phraseanet.user']->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord')) {
|
||||
if (!$app['phraseanet.user']->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord')) {
|
||||
throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_name()));
|
||||
}
|
||||
|
||||
@@ -674,7 +674,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$reasons = $output = null;
|
||||
|
||||
$callback = function($element, $visa, $code) use (&$reasons, &$output) {
|
||||
if ( ! $visa->isValid()) {
|
||||
if (!$visa->isValid()) {
|
||||
$reasons = array();
|
||||
|
||||
foreach ($visa->getResponses() as $response) {
|
||||
@@ -765,7 +765,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
throw new \API_V1_exception_notfound(sprintf('Lazaret file id %d not found', $lazaret_id));
|
||||
}
|
||||
|
||||
if ( ! $app['phraseanet.user']->ACL()->has_right_on_base($lazaretFile->getBaseId(), 'canaddrecord')) {
|
||||
if (!$app['phraseanet.user']->ACL()->has_right_on_base($lazaretFile->getBaseId(), 'canaddrecord')) {
|
||||
throw new \API_V1_exception_forbidden('You do not have access to this quarantine item');
|
||||
}
|
||||
|
||||
@@ -882,11 +882,11 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
|
||||
$options->set_bases($params['bases'], $this->app['phraseanet.user']->ACL());
|
||||
|
||||
if ( ! is_array($params['fields'])) {
|
||||
if (!is_array($params['fields'])) {
|
||||
$params['fields'] = array();
|
||||
}
|
||||
$options->set_fields($params['fields']);
|
||||
if ( ! is_array($params['status'])) {
|
||||
if (!is_array($params['status'])) {
|
||||
$params['status'] = array();
|
||||
}
|
||||
$options->set_status($params['status']);
|
||||
@@ -1052,12 +1052,12 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
try {
|
||||
$metadatas = $request->get('metadatas');
|
||||
|
||||
if ( ! is_array($metadatas)) {
|
||||
if (!is_array($metadatas)) {
|
||||
throw new Exception('Metadatas should be an array');
|
||||
}
|
||||
|
||||
foreach ($metadatas as $metadata) {
|
||||
if ( ! is_array($metadata)) {
|
||||
if (!is_array($metadata)) {
|
||||
throw new Exception('Each Metadata value should be an array');
|
||||
}
|
||||
}
|
||||
@@ -1083,17 +1083,17 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
|
||||
$datas = strrev($record->get_status());
|
||||
|
||||
if ( ! is_array($status)) {
|
||||
if (!is_array($status)) {
|
||||
throw new API_V1_exception_badrequest();
|
||||
}
|
||||
foreach ($status as $n => $value) {
|
||||
if ($n > 63 || $n < 4) {
|
||||
throw new API_V1_exception_badrequest();
|
||||
}
|
||||
if ( ! in_array($value, array('0', '1'))) {
|
||||
if (!in_array($value, array('0', '1'))) {
|
||||
throw new API_V1_exception_badrequest();
|
||||
}
|
||||
if ( ! isset($status_bits[$n])) {
|
||||
if (!isset($status_bits[$n])) {
|
||||
throw new API_V1_exception_badrequest ();
|
||||
}
|
||||
|
||||
@@ -1370,7 +1370,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$this->app['EM']->merge($Basket);
|
||||
$this->app['EM']->flush();
|
||||
|
||||
$result->set_datas(array( "basket" => $this->list_basket($Basket)));
|
||||
$result->set_datas(array("basket" => $this->list_basket($Basket)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -1499,7 +1499,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
|
||||
$collection = $entry->get_feed()->get_collection();
|
||||
|
||||
if (null !== $collection && ! $user->ACL()->has_access_to_base($collection->get_base_id())) {
|
||||
if (null !== $collection && !$user->ACL()->has_access_to_base($collection->get_base_id())) {
|
||||
throw new \API_V1_exception_forbidden('You have not access to the parent feed');
|
||||
}
|
||||
|
||||
@@ -1528,7 +1528,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
'total_entries' => $feed->get_count_total_entries(),
|
||||
'icon' => $feed->get_icon_url(),
|
||||
'public' => $feed->is_public(),
|
||||
'readonly' => ! $feed->is_publisher($user),
|
||||
'readonly' => !$feed->is_publisher($user),
|
||||
'deletable' => $feed->is_owner($user),
|
||||
'created_on' => $feed->get_created_on()->format(DATE_ATOM),
|
||||
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM),
|
||||
@@ -1636,7 +1636,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
*/
|
||||
protected function list_embedable_media(media_subdef $media, registryInterface $registry)
|
||||
{
|
||||
if ( ! $media->is_physically_present()) {
|
||||
if (!$media->is_physically_present()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1690,7 +1690,7 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
$status = strrev($status);
|
||||
$ret = array();
|
||||
foreach ($databox->get_statusbits() as $bit => $status_datas) {
|
||||
$ret[] = array('bit' => $bit, 'state' => ! ! substr($status, ($bit - 1), 1));
|
||||
$ret[] = array('bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -1745,8 +1745,8 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
'name' => $basket->getName(),
|
||||
'pusher_usr_id' => $basket->getPusherId(),
|
||||
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
|
||||
'unread' => ! $basket->getIsRead(),
|
||||
'validation_basket' => ! ! $basket->getValidation()
|
||||
'unread' => !$basket->getIsRead(),
|
||||
'validation_basket' => !!$basket->getValidation()
|
||||
);
|
||||
|
||||
if ($basket->getValidation()) {
|
||||
@@ -1917,8 +1917,8 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
'label_off' => $datas['labeloff'],
|
||||
'img_on' => $datas['img_on'],
|
||||
'img_off' => $datas['img_off'],
|
||||
'searchable' => ! ! $datas['searchable'],
|
||||
'printable' => ! ! $datas['printable'],
|
||||
'searchable' => !!$datas['searchable'],
|
||||
'printable' => !!$datas['printable'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -798,7 +798,7 @@ class databox extends base
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function feed_meta_fields()
|
||||
public function feed_meta_fields()
|
||||
{
|
||||
$sxe = $this->get_sxml_structure();
|
||||
|
||||
@@ -832,21 +832,20 @@ class databox extends base
|
||||
|
||||
$meta_struct_field = databox_field::create($this->app, $this, $fname, $multi);
|
||||
$meta_struct_field
|
||||
->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0)
|
||||
->set_indexable(isset($field['index']) ? $field['index'] : '1')
|
||||
->set_separator(isset($field['separator']) ? $field['separator'] : '')
|
||||
->set_required((isset($field['required']) && $field['required'] == 1))
|
||||
->set_business((isset($field['business']) && $field['business'] == 1))
|
||||
->set_readonly(isset($field['readonly']) ? (string) $field['readonly'] : 0)
|
||||
->set_indexable(isset($field['index']) ? (string) $field['index'] : '1')
|
||||
->set_separator(isset($field['separator']) ? (string) $field['separator'] : '')
|
||||
->set_required((isset($field['required']) && (string) $field['required'] == 1))
|
||||
->set_business((isset($field['business']) && (string) $field['business'] == 1))
|
||||
->set_type($type)
|
||||
->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '')
|
||||
->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
|
||||
->set_report(isset($field['report']) ? $field['report'] : '1')
|
||||
->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
|
||||
->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
|
||||
->set_report(isset($field['report']) ? (string) $field['report'] : '1')
|
||||
->save();
|
||||
|
||||
try {
|
||||
$meta_struct_field->set_tag(\databox_field::loadClassFromTagName($src))->save();
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -96,8 +96,8 @@ class patch_320c implements patchInterface
|
||||
$xp_struct = $databox->get_xpath_structure();
|
||||
|
||||
foreach ($sxe->description->children() as $fname => $field) {
|
||||
$src = trim(isset($field['src']) ? $field['src'] : '');
|
||||
|
||||
$src = trim(isset($field['src']) ? $field['src'] : '');
|
||||
if (array_key_exists($src, $phrasea_maps)) {
|
||||
$src = $phrasea_maps[$src];
|
||||
}
|
||||
@@ -111,9 +111,7 @@ class patch_320c implements patchInterface
|
||||
}
|
||||
|
||||
$databox->saveStructure($dom_struct);
|
||||
|
||||
$ext_databox = new extended_databox($databox->get_sbas_id());
|
||||
$ext_databox->migrate_fields();
|
||||
$databox->feed_meta_fields();
|
||||
|
||||
$databox->delete_data_from_cache(databox::CACHE_STRUCTURE);
|
||||
$databox->delete_data_from_cache(databox::CACHE_META_STRUCT);
|
||||
@@ -129,19 +127,3 @@ class patch_320c implements patchInterface
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class extended_databox extends databox
|
||||
{
|
||||
|
||||
public function __construct($sbas_id)
|
||||
{
|
||||
parent::__construct($sbas_id);
|
||||
}
|
||||
|
||||
public function migrate_fields()
|
||||
{
|
||||
$this->feed_meta_fields();
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -174,8 +174,6 @@ class patch_320f implements patchInterface
|
||||
}
|
||||
|
||||
if ( ! ($collection instanceof collection)) {
|
||||
echo "unable to find a collection to protect feeds";
|
||||
|
||||
return false;
|
||||
}
|
||||
$feed->set_collection($collection);
|
||||
|
@@ -19,9 +19,11 @@ class sphinxrt
|
||||
protected static $_instance;
|
||||
protected static $_failure = false;
|
||||
protected $connection;
|
||||
protected $registry;
|
||||
|
||||
protected function __construct(registry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
try {
|
||||
$dsn = sprintf('mysql:host=%s;port=%s;', $registry->get('GV_sphinx_rt_host'), $registry->get('GV_sphinx_rt_port'));
|
||||
$this->connection = @new PDO($dsn);
|
||||
@@ -64,7 +66,7 @@ class sphinxrt
|
||||
|
||||
$cl = new SphinxClient();
|
||||
|
||||
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
|
||||
$cl->SetServer($this->registry->get('GV_sphinx_host'), (int) $this->registry->get('GV_sphinx_port'));
|
||||
$cl->SetConnectTimeout(1);
|
||||
|
||||
foreach ($index_ids as $index_id)
|
||||
@@ -92,7 +94,7 @@ class sphinxrt
|
||||
return $this;
|
||||
}
|
||||
|
||||
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
|
||||
$cl->SetServer($this->registry->get('GV_sphinx_host'), (int) $this->registry->get('GV_sphinx_port'));
|
||||
$cl->SetConnectTimeout(1);
|
||||
|
||||
$status = strrev($status);
|
||||
|
Reference in New Issue
Block a user