Skip to content

Commit

Permalink
* [FIX] Wrong behavior when accessing through API. Maintenance mode w…
Browse files Browse the repository at this point in the history
…as wrongly checked. Thanks to @pierrehenrymuller for the feedback. Closes #1108

* [MOD] Updated displayed strings for custom fields type.

Signed-off-by: nuxsmin <nuxsmin@syspass.org>
  • Loading branch information
nuxsmin committed Nov 18, 2018
1 parent 5726087 commit afdfa80
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/modules/api/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function initialize($controller)
$this->checkInstalled();

// Checks if maintenance mode is turned on
if (!$this->checkMaintenanceMode($this->context)) {
if ($this->checkMaintenanceMode($this->context)) {
throw new InitializationException('Maintenance mode');
}

Expand Down
10 changes: 8 additions & 2 deletions lib/SP/Services/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class Installer extends Service
*/
const VERSION = [3, 0, 0];
const VERSION_TEXT = '3.0-rc3';
const BUILD = 18111801;
const BUILD = 18111901;

/**
* @var DatabaseSetupInterface
Expand Down Expand Up @@ -289,7 +289,13 @@ private function setupDb($type = 'mysql')
private function updateConnectionData()
{
$this->dic->set(DBStorageInterface::class, $this->dbs->createDbHandlerFromInstaller());
$this->dic->set(Database::class, new Database($this->dic->get(DBStorageInterface::class), $this->dic->get(EventDispatcher::class)));
$this->dic->set(
Database::class,
new Database(
$this->dic->get(DBStorageInterface::class),
$this->dic->get(EventDispatcher::class)
)
);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/SP/Services/Upgrade/UpgradeDatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ final class UpgradeDatabaseService extends Service implements UpgradeInterface
'300.18091101',
'300.18092401',
'300.18093001',
'300.18111801'
'300.18111801',
'300.18111901'
];

/**
Expand Down
23 changes: 23 additions & 0 deletions schemas/30018111901.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
DELIMITER $$

UPDATE CustomFieldType
SET `text` = 'Text'
WHERE name = 'text' $$
UPDATE CustomFieldType
SET `text` = 'Password'
WHERE name = 'password' $$
UPDATE CustomFieldType
SET `text` = 'Date'
WHERE name = 'date' $$
UPDATE CustomFieldType
SET `text` = 'Number'
WHERE name = 'number' $$
UPDATE CustomFieldType
SET `text` = 'Email'
WHERE name = 'email' $$
UPDATE CustomFieldType
SET `text` = 'Phone'
WHERE name = 'telephone' $$
UPDATE CustomFieldType
SET `text` = 'Text Area'
WHERE name = 'textarea' $$
12 changes: 6 additions & 6 deletions schemas/dbstructure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -380,16 +380,16 @@ CREATE TABLE `EventLog` (
COLLATE utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO CustomFieldType (id, name, text)
VALUES (1, 'text', 'Texto'),
(2, 'password', 'Clave'),
(3, 'date', 'Fecha'),
(4, 'number', 'Número'),
VALUES (1, 'text', 'Text'),
(2, 'password', 'Password'),
(3, 'date', 'Date'),
(4, 'number', 'Number'),
(5, 'email', 'Email'),
(6, 'telephone', 'Teléfono'),
(6, 'telephone', 'Phone'),
(7, 'url', 'URL'),
(8, 'color', 'Color'),
(9, 'wiki', 'Wiki'),
(10, 'textarea', 'Área de Texto');
(10, 'textarea', 'Text Area');
DROP TABLE IF EXISTS `Notification`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
Expand Down
4 changes: 2 additions & 2 deletions tests/SP/Modules/Api/Controllers/AccountControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testCreateAction()
$this->assertNull($result->result->count);
$this->assertInstanceOf(\stdClass::class, $result->result);
$this->assertEquals(3, $result->result->itemId);
$this->assertEquals('Account added', $result->result->resultMessage);
$this->assertEquals('Account created', $result->result->resultMessage);

return $result->result->itemId;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public function testCreateActionNoUserData()
$this->assertNull($result->result->count);
$this->assertInstanceOf(\stdClass::class, $result->result);
$this->assertEquals(4, $result->result->itemId);
$this->assertEquals('Account added', $result->result->resultMessage);
$this->assertEquals('Account created', $result->result->resultMessage);

$data = [
'jsonrpc' => '2.0',
Expand Down

0 comments on commit afdfa80

Please sign in to comment.