Skip to content

Commit 04ccd74

Browse files
authored
Merge pull request #1095 from phalcon/3.2.x
3.2.4
2 parents 6775406 + ac4544f commit 04ccd74

30 files changed

+587
-31
lines changed

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ env:
3838
- TEST_DB_POSTGRESQL_USER="postgres"
3939
- TEST_DB_POSTGRESQL_PASSWD=""
4040
- TEST_DB_POSTGRESQL_NAME="devtools"
41+
- TEST_DB_MYSQL_DSN="mysql:host=127.0.0.1;dbname=devtools"
42+
- TEST_DB_MYSQL_HOST="127.0.0.1"
43+
- TEST_DB_MYSQL_PORT="3306"
44+
- TEST_DB_MYSQL_USER="root"
45+
- TEST_DB_MYSQL_PASSWD=""
46+
- TEST_DB_MYSQL_NAME="devtools"
47+
- TEST_DB_MYSQL_CHARSET="utf8"
4148
- PATH="$PATH:~/bin"
4249
- DISPLAY=":99.0"
4350
- PHALCON_VERSION="v3.2.0"
@@ -57,9 +64,14 @@ install:
5764
- cd $TRAVIS_BUILD_DIR
5865
- travis_retry composer install --prefer-dist --no-interaction
5966

67+
before_script:
68+
- ln -s $PWD/phalcon.php ~/bin/phalcon
69+
6070
script:
6171
- vendor/bin/codecept build
6272
- vendor/bin/codecept run unit -v
73+
- vendor/bin/codecept run functional -v
74+
- vendor/bin/codecept run console -v
6375

6476
notifications:
6577
email:

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
"Phalcon\\Test\\": "tests/unit",
4646
"Phalcon\\Test\\Models\\": "tests/_data/models",
4747
"Phalcon\\Test\\Module\\": "tests/_support/Module"
48-
}
48+
},
49+
"files": [
50+
"tests/_support/helpers.php"
51+
]
4952
},
5053
"bin": ["phalcon.php"]
5154
}

scripts/Phalcon/Builder/Project/Micro.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ private function createHtaccessFiles()
8686
*/
8787
private function createIndexViewFiles()
8888
{
89-
$getFile = $this->options->get('templatePath') . '/project/micro/views/index.phtml';
90-
$putFile = $this->options->get('projectPath').'app/views/index.phtml';
89+
$engine = $this->options->get('templateEngine') == 'volt' ? 'volt' : 'phtml';
90+
91+
$getFile = $this->options->get('templatePath') . '/project/micro/views/index.' . $engine;
92+
$putFile = $this->options->get('projectPath').'app/views/index.' . $engine;
9193
$this->generateFile($getFile, $putFile);
9294

93-
$getFile = $this->options->get('templatePath') . '/project/micro/views/404.phtml';
94-
$putFile = $this->options->get('projectPath').'app/views/404.phtml';
95+
$getFile = $this->options->get('templatePath') . '/project/micro/views/404.' . $engine;
96+
$putFile = $this->options->get('projectPath').'app/views/404.' . $engine;
9597
$this->generateFile($getFile, $putFile);
9698

9799
return $this;

scripts/Phalcon/Builder/Project/Modules.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,14 @@ private function createHtaccessFiles()
147147
*/
148148
private function createIndexViewFiles()
149149
{
150-
$getFile = $this->options->get('templatePath') . '/project/modules/views/index.volt';
151-
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index.volt';
150+
$engine = $this->options->get('templateEngine') == 'volt' ? 'volt' : 'phtml';
151+
152+
$getFile = $this->options->get('templatePath') . '/project/modules/views/index.' . $engine;
153+
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index.' . $engine;
152154
$this->generateFile($getFile, $putFile);
153155

154-
$getFile = $this->options->get('templatePath') . '/project/modules/views/index/index.volt';
155-
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index/index.volt';
156+
$getFile = $this->options->get('templatePath') . '/project/modules/views/index/index.' . $engine;
157+
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index/index.' . $engine;
156158
$this->generateFile($getFile, $putFile);
157159

158160
return $this;

scripts/Phalcon/Builder/Project/Simple.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@ private function createHtaccessFiles()
116116
*/
117117
private function createIndexViewFiles()
118118
{
119-
$getFile = $this->options->get('templatePath') . '/project/simple/views/index.volt';
120-
$putFile = $this->options->get('projectPath').'app/views/index.volt';
119+
$engine = $this->options->get('templateEngine') == 'volt' ? 'volt' : 'phtml';
120+
121+
$getFile = $this->options->get('templatePath') . '/project/simple/views/index.' . $engine;
122+
$putFile = $this->options->get('projectPath').'app/views/index.' . $engine;
121123
$this->generateFile($getFile, $putFile);
122124

123-
$getFile = $this->options->get('templatePath') . '/project/simple/views/index/index.volt';
124-
$putFile = $this->options->get('projectPath').'app/views/index/index.volt';
125+
$getFile = $this->options->get('templatePath') . '/project/simple/views/index/index.' . $engine;
126+
$putFile = $this->options->get('projectPath').'app/views/index/index.' . $engine;
125127
$this->generateFile($getFile, $putFile);
126128

127129
return $this;

scripts/Phalcon/Commands/Builtin/Project.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ public function getPossibleParams()
4242
{
4343
return [
4444
'name=s' => 'Name of the new project',
45-
'enable-webtools' => 'Determines if webtools should be enabled [optional]',
46-
'directory=s' => 'Base path on which project will be created [optional]',
47-
'type=s' => 'Type of the application to be generated (cli, micro, simple, modules)',
48-
'template-path=s' => 'Specify a template path [optional]',
49-
'use-config-ini' => 'Use a ini file as configuration file [optional]',
50-
'trace' => 'Shows the trace of the framework in case of exception [optional]',
51-
'help' => 'Shows this help [optional]',
45+
'enable-webtools' => 'Determines if webtools should be enabled [optional]',
46+
'directory=s' => 'Base path on which project will be created [optional]',
47+
'type=s' => 'Type of the application to be generated (cli, micro, simple, modules)',
48+
'template-path=s' => 'Specify a template path [optional]',
49+
'template-engine=s' => 'Define the template engine, default phtml (phtml, volt) [optional]',
50+
'use-config-ini' => 'Use a ini file as configuration file [optional]',
51+
'trace' => 'Shows the trace of the framework in case of exception [optional]',
52+
'help' => 'Shows this help [optional]',
5253
];
5354
}
5455

@@ -60,19 +61,21 @@ public function getPossibleParams()
6061
*/
6162
public function run(array $parameters)
6263
{
63-
$projectName = $this->getOption(['name', 1], null, 'default');
64-
$projectType = $this->getOption(['type', 2], null, 'simple');
65-
$projectPath = $this->getOption(['directory', 3]);
66-
$templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
64+
$projectName = $this->getOption(['name', 1], null, 'default');
65+
$projectType = $this->getOption(['type', 2], null, 'simple');
66+
$projectPath = $this->getOption(['directory', 3]);
67+
$templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
6768
$enableWebtools = $this->getOption(['enable-webtools', 4], null, false);
68-
$useConfigIni = $this->getOption('use-config-ini');
69+
$useConfigIni = $this->getOption('use-config-ini');
70+
$templateEngine = $this->getOption(['template-engine'], null, "phtml");
6971

7072
$builder = new ProjectBuilder([
7173
'name' => $projectName,
7274
'type' => $projectType,
7375
'directory' => $projectPath,
7476
'enableWebTools' => $enableWebtools,
7577
'templatePath' => $templatePath,
78+
'templateEngine' => $templateEngine,
7679
'useConfigIni' => $useConfigIni
7780
]);
7881

scripts/Phalcon/Commands/Builtin/Scaffold.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getPossibleParams()
4747
'get-set' => 'Attributes will be protected and have setters/getters. [optional]',
4848
'directory=s' => 'Base path on which project was created [optional]',
4949
'template-path=s' => 'Specify a template path [optional]',
50-
'template-engine=s' => 'Define the template engine, default php (php, volt) [optional]',
50+
'template-engine=s' => 'Define the template engine, default phtml (phtml, volt) [optional]',
5151
'force' => 'Forces to rewrite generated code if they already exists [optional]',
5252
'trace' => 'Shows the trace of the framework in case of exception [optional]',
5353
'ns-models=s' => "Model's namespace [optional]",
@@ -67,7 +67,7 @@ public function run(array $parameters)
6767
$name = $this->getOption(['table-name', 1]);
6868
$templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
6969
$schema = $this->getOption('schema');
70-
$templateEngine = $this->getOption(['template-engine'], null, "php");
70+
$templateEngine = $this->getOption(['template-engine'], null, "phtml");
7171

7272
$scaffoldBuilder = new ScaffoldBuilder([
7373
'name' => $name,

scripts/Phalcon/Migrations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public static function removeCurrentVersion($options, $version)
547547
if (isset($options['migrationsInDb']) && (bool)$options['migrationsInDb']) {
548548
/** @var AdapterInterface $connection */
549549
$connection = self::$_storage;
550-
$connection->execute('DELETE FROM '. self::MIGRATION_LOG_TABLE .' WHERE version=\'' . $version . '\' LIMIT 1');
550+
$connection->execute('DELETE FROM '. self::MIGRATION_LOG_TABLE .' WHERE version=\'' . $version . '\'');
551551
} else {
552552
$currentVersions = self::getCompletedVersions($options);
553553
unset($currentVersions[(string)$version]);

scripts/Phalcon/Mvc/Model/Migration.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,15 @@ public function batchDelete($tableName)
882882
self::$_connection->begin();
883883
self::$_connection->delete($tableName);
884884
$batchHandler = fopen($migrationData, 'r');
885-
while (($line = fgets($batchHandler)) !== false) {
886-
$data = explode('|', rtrim($line), 2);
887-
self::$_connection->delete($tableName, 'id=?', [$data[0]]);
885+
while (($line = fgetcsv($batchHandler)) !== false) {
886+
$values = array_map(
887+
function ($value) {
888+
return null === $value ? null : $value;
889+
},
890+
$line
891+
);
892+
893+
self::$_connection->delete($tableName, 'id=?', [$values[0]]);
888894
unset($line);
889895
}
890896
fclose($batchHandler);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
<title>Phalcon PHP Framework</title>
7+
</head>
8+
<body>
9+
<div class="container">
10+
<h1>Not found :(</h1>
11+
<em>This page is located in views/404.volt</em>
12+
</div>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)