From e3f917f764dae27023f85e365555e1589e00d9f4 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 5 Apr 2012 20:16:35 +0200 Subject: [PATCH 01/77] Database: fixed loadFromFile() (second try) --- Nette/Database/Helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nette/Database/Helpers.php b/Nette/Database/Helpers.php index 95f8469a04..646447e492 100644 --- a/Nette/Database/Helpers.php +++ b/Nette/Database/Helpers.php @@ -162,7 +162,7 @@ public static function loadFromFile(Connection $connection, $file) $count++; } } - if ($sql !== '') { + if (trim($sql) !== '') { $connection->exec($sql); $count++; } From fd618f418cbbc42b5a222d6dc8a2439f535daf25 Mon Sep 17 00:00:00 2001 From: hrach Date: Thu, 19 Apr 2012 14:52:49 +0200 Subject: [PATCH 02/77] Database: fixed query conditions. --- Nette/Database/Table/Selection.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Nette/Database/Table/Selection.php b/Nette/Database/Table/Selection.php index d2d2a61893..f5bc62ecd0 100644 --- a/Nette/Database/Table/Selection.php +++ b/Nette/Database/Table/Selection.php @@ -744,10 +744,9 @@ public function getReferencingTable($table, $column, $active = NULL, $forceNewIn $referencing = & $this->referencing["$table:$column"]; if (!$referencing || $forceNewInstance) { $referencing = new GroupedSelection($table, $this, $column); - $referencing->where("$table.$column", array_keys((array) $this->rows)); // (array) - is NULL after insert } - return $referencing->setActive($active); + return $referencing->setActive($active)->where("$table.$column", array_keys((array) $this->rows)); } From ca7af3a1ce6f68e00f1463e0be1a0023d09a357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20H=C5=AFla?= Date: Wed, 21 Mar 2012 11:31:57 +0100 Subject: [PATCH 03/77] Database: fixed PgSqlDriver Reflection code is refactored. information_schema is used as more as possible for compatibility. Only getIndexes() use PG catalog, because in information_schema are not all indexes. --- Nette/Database/Drivers/PgSqlDriver.php | 114 ++++++++++++++----------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/Nette/Database/Drivers/PgSqlDriver.php b/Nette/Database/Drivers/PgSqlDriver.php index d1a98416da..2ceef3be76 100644 --- a/Nette/Database/Drivers/PgSqlDriver.php +++ b/Nette/Database/Drivers/PgSqlDriver.php @@ -64,7 +64,8 @@ public function formatDateTime(\DateTime $value) */ public function formatLike($value, $pos) { - throw new Nette\NotImplementedException; + $value = strtr($value, array("'" => "''", '\\' => '\\\\', '%' => '\\\\%', '_' => '\\\\_')); + return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'"); } @@ -102,11 +103,20 @@ public function normalizeRow($row, $statement) */ public function getTables() { - return $this->connection->query(" - SELECT table_name as name, CAST(table_type = 'VIEW' AS INTEGER) as view - FROM information_schema.tables - WHERE table_schema = current_schema() - ")->fetchAll(); + $tables = array(); + foreach ($this->connection->query(" + SELECT + table_name AS name, + table_type = 'VIEW' AS view + FROM + information_schema.tables + WHERE + table_schema = current_schema() + ") as $row) { + $tables[] = (array) $row; + } + + return $tables; } @@ -116,33 +126,35 @@ public function getTables() */ public function getColumns($table) { - $primary = (int) $this->connection->query(" - SELECT indkey - FROM pg_class - LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid AND pg_index.indisprimary - WHERE pg_class.relname = {$this->connection->quote($table)} - ")->fetchColumn(0); - $columns = array(); foreach ($this->connection->query(" - SELECT * - FROM information_schema.columns - WHERE table_name = {$this->connection->quote($table)} AND table_schema = current_schema() - ORDER BY ordinal_position + SELECT + c.column_name AS name, + c.table_name AS table, + upper(c.udt_name) AS nativetype, + greatest(c.character_maximum_length, c.numeric_precision) AS size, + FALSE AS unsigned, + c.is_nullable = 'YES' AS nullable, + c.column_default AS default, + coalesce(tc.constraint_type = 'PRIMARY KEY', FALSE) AND strpos(c.column_default, 'nextval') = 1 AS autoincrement, + coalesce(tc.constraint_type = 'PRIMARY KEY', FALSE) AS primary + FROM + information_schema.columns AS c + LEFT JOIN information_schema.constraint_column_usage AS ccu USING(table_catalog, table_schema, table_name, column_name) + LEFT JOIN information_schema.table_constraints AS tc USING(constraint_catalog, constraint_schema, constraint_name) + WHERE + c.table_name = {$this->connection->quote($table)} + AND + c.table_schema = current_schema() + AND + (tc.constraint_type IS NULL OR tc.constraint_type = 'PRIMARY KEY') + ORDER BY + c.ordinal_position ") as $row) { - $size = (int) max($row['character_maximum_length'], $row['numeric_precision']); - $columns[] = array( - 'name' => $row['column_name'], - 'table' => $table, - 'nativetype' => strtoupper($row['udt_name']), - 'size' => $size ? $size : NULL, - 'nullable' => $row['is_nullable'] === 'YES', - 'default' => $row['column_default'], - 'autoincrement' => (int) $row['ordinal_position'] === $primary && substr($row['column_default'], 0, 7) === 'nextval', - 'primary' => (int) $row['ordinal_position'] === $primary, - 'vendor' => (array) $row, - ); + $row['vendor'] = array(); + $columns[] = (array) $row; } + return $columns; } @@ -153,31 +165,33 @@ public function getColumns($table) */ public function getIndexes($table) { - $columns = array(); - foreach ($this->connection->query(" - SELECT ordinal_position, column_name - FROM information_schema.columns - WHERE table_name = {$this->connection->quote($table)} AND table_schema = current_schema() - ORDER BY ordinal_position - ") as $row) { - $columns[$row['ordinal_position']] = $row['column_name']; - } - + /* There is no information about all indexes in information_schema, so pg catalog must be used */ $indexes = array(); foreach ($this->connection->query(" - SELECT pg_class2.relname, indisunique, indisprimary, indkey - FROM pg_class - LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid - INNER JOIN pg_class as pg_class2 on pg_class2.oid = pg_index.indexrelid - WHERE pg_class.relname = {$this->connection->quote($table)} + SELECT + c2.relname AS name, + indisunique AS unique, + indisprimary AS primary, + attname AS column + FROM + pg_class AS c1 + JOIN pg_namespace ON c1.relnamespace = pg_namespace.oid + JOIN pg_index ON c1.oid = indrelid + JOIN pg_class AS c2 ON indexrelid = c2.oid + LEFT JOIN pg_attribute ON c1.oid = attrelid AND attnum = ANY(indkey) + WHERE + nspname = current_schema() + AND + c1.relkind = 'r' + AND + c1.relname = {$this->connection->quote($table)} ") as $row) { - $indexes[$row['relname']]['name'] = $row['relname']; - $indexes[$row['relname']]['unique'] = $row['indisunique'] === 't'; - $indexes[$row['relname']]['primary'] = $row['indisprimary'] === 't'; - foreach (explode(' ', $row['indkey']) as $index) { - $indexes[$row['relname']]['columns'][] = $columns[$index]; - } + $indexes[$row['name']]['name'] = $row['name']; + $indexes[$row['name']]['unique'] = $row['unique']; + $indexes[$row['name']]['primary'] = $row['primary']; + $indexes[$row['name']]['columns'][] = $row['column']; } + return array_values($indexes); } From a109f73a542d83d468390ded4265ba993a49225c Mon Sep 17 00:00:00 2001 From: Jan Dolecek Date: Thu, 19 Apr 2012 11:05:14 +0200 Subject: [PATCH 04/77] Debugger: use colors in dump only if terminal supports it --- Nette/Diagnostics/Debugger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nette/Diagnostics/Debugger.php b/Nette/Diagnostics/Debugger.php index 5fc982343d..fe854ae18b 100644 --- a/Nette/Diagnostics/Debugger.php +++ b/Nette/Diagnostics/Debugger.php @@ -606,7 +606,7 @@ public static function dump($var, $return = FALSE) } if (self::$consoleMode) { - if (self::$consoleColors && substr(PHP_OS, 0, 3) !== 'WIN') { + if (self::$consoleColors && substr(getenv('TERM'), 0, 5) === 'xterm') { $output = preg_replace_callback('#|#', function($m) { return "\033[" . (isset($m[1], Debugger::$consoleColors[$m[1]]) ? Debugger::$consoleColors[$m[1]] : '0') . "m"; }, $output); From 9286cf8703090318ef200e014db861518b9a6ce7 Mon Sep 17 00:00:00 2001 From: Ondrej Novy Date: Mon, 16 Apr 2012 22:36:53 +0200 Subject: [PATCH 05/77] Database: added support for foreign keys in PostgreSQL driver. --- Nette/Database/Drivers/PgSqlDriver.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Nette/Database/Drivers/PgSqlDriver.php b/Nette/Database/Drivers/PgSqlDriver.php index 2ceef3be76..b9f8644042 100644 --- a/Nette/Database/Drivers/PgSqlDriver.php +++ b/Nette/Database/Drivers/PgSqlDriver.php @@ -202,7 +202,16 @@ public function getIndexes($table) */ public function getForeignKeys($table) { - throw new NotImplementedException; + return $this->connection->query(" + SELECT tc.table_name AS name, kcu.column_name AS local, ccu.table_name AS table, ccu.column_name AS foreign + FROM information_schema.table_constraints AS tc + JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name AND tc.constraint_schema = kcu.constraint_schema + JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name AND ccu.constraint_schema = tc.constraint_schema + WHERE + constraint_type = 'FOREIGN KEY' AND + tc.table_name = {$this->connection->quote($table)} AND + tc.constraint_schema = current_schema() + ")->fetchAll(); } From 9ff3f0ebce529ec9b4db63639c162339e3fbfc1d Mon Sep 17 00:00:00 2001 From: Jan-Sebastian Fabik Date: Mon, 21 May 2012 22:15:18 +0200 Subject: [PATCH 06/77] Selection: fixed possible reading from an uninitialized property $rows --- Nette/Database/Table/Selection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Nette/Database/Table/Selection.php b/Nette/Database/Table/Selection.php index f5bc62ecd0..2b8c9f842c 100644 --- a/Nette/Database/Table/Selection.php +++ b/Nette/Database/Table/Selection.php @@ -705,6 +705,7 @@ public function getReferencedTable($table, $column, $checkReferenceNewKeys = FAL $referenced = & $this->referenced["$table.$column"]; if ($referenced === NULL || $checkReferenceNewKeys || $this->checkReferenceNewKeys) { $keys = array(); + $this->execute(); foreach ($this->rows as $row) { if ($row[$column] === NULL) continue; From 6d1916f78e508d78f66ecb168d8c839dd308ef46 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 20 Apr 2012 02:05:46 +0200 Subject: [PATCH 07/77] Diagnostics\Bar: is hidden in @media print --- Nette/Diagnostics/templates/bar.phtml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Nette/Diagnostics/templates/bar.phtml b/Nette/Diagnostics/templates/bar.phtml index 1eb2a894b2..4e1000a0de 100644 --- a/Nette/Diagnostics/templates/bar.phtml +++ b/Nette/Diagnostics/templates/bar.phtml @@ -308,6 +308,12 @@ use Nette; #nette-debug pre.nette-dump .php-visibility { font-size: 85%; color: #999; } + + @media print { + #nette-debug * { + display: none; + } + } ') { $this->output .= $token->text; @@ -317,7 +317,7 @@ private function processHtmlTagEnd($token) - private function processHtmlAttribute($token) + private function processHtmlAttribute(Token $token) { $htmlNode = end($this->htmlNodes); if (Strings::startsWith($token->name, Parser::N_PREFIX)) { From 3171c9b820dcdcf5f6e81048652597096169547a Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 29 May 2012 23:37:43 +0200 Subject: [PATCH 68/77] typos --- Nette/Utils/Tokenizer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Nette/Utils/Tokenizer.php b/Nette/Utils/Tokenizer.php index 66d2434e2b..43b8284d35 100644 --- a/Nette/Utils/Tokenizer.php +++ b/Nette/Utils/Tokenizer.php @@ -295,7 +295,6 @@ private function scan($wanted, $first, $advance = TRUE, $neg = FALSE, $prev = FA /** * The exception that indicates tokenizer error. - * @internal */ class TokenizerException extends \Exception { From e088f2ba948251e829d3a2fc01503ca4d369dd23 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 15 Jul 2012 23:33:51 +0200 Subject: [PATCH 69/77] typos --- tests/Nette/Utils/NeonParser.syntax.txt | 31 +++++++------------------ 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/tests/Nette/Utils/NeonParser.syntax.txt b/tests/Nette/Utils/NeonParser.syntax.txt index 93c3bfe1b9..20c5340487 100644 --- a/tests/Nette/Utils/NeonParser.syntax.txt +++ b/tests/Nette/Utils/NeonParser.syntax.txt @@ -1,7 +1,7 @@ Preprocessing ------------- - tabs are converted to single space -- \r is deleted +- \r is removed Comment @@ -9,37 +9,24 @@ Comment Comment ::= '#' .* -Values --------------- -Value ::= Boolean | Null | integer | float | String | Literal | InlineArray | Object +Values +------ +Value ::= Boolean | Null | integer | float | String | DateTime | Literal | InlineArray | Entity Boolean ::= 'true' | 'TRUE' | 'false' | 'FALSE' | 'yes' | 'YES' | 'no' | 'NO' Null ::= 'null' | 'NULL' | '' String ::= "word\u231" | 'word' -Literal ::= trimmed stream of characters [^#"',:=@[\]{}()\s] ( [^#,:=\]})\n] | ':' \S | \S '#' )* +Literal ::= trimmed stream of characters [^#"',:=@[\]{}()\s!`] ( [^#,:=\]})(] | ':' [^\s,\]})] | \S '#' )* +Entity ::= Value '(' ( ArrayEntry ',' )* ')' InlineArray ----------- -InlineArray ::= '{' ( ArrayEntry ',' )* '}' | '[' ( ArrayEntry ',' )* ']' +InlineArray ::= '{' ( ArrayEntry ',' )* '}' | '[' ( ArrayEntry ',' )* ']' | '(' ( ArrayEntry ',' )* ')' ArrayEntry ::= Value | KeyValuePair -KeyValuePair ::= Key '=' Value | Key ': ' Value -Key ::= integer | String | Literal - - -Entity ------- -Entity ::= Literal '(' ( ArrayEntry ',' )* ')' +KeyValuePair ::= Value '=' Value | Value ': ' Value BlockArray ---------- -BlockArray ::= Indent '- ' Value EOL - - -BlockHash ---------- -BlockHash ::= Indent Key ': ' KeyValuePair EOL - -NestedBlockHash ::= Indent Key ':' EOL - Indent Value +BlockArray ::= Indent ( '- ' Value | KeyValuePair ) EOL From dde134b3b60fc4ebcf9de2d3e0749f3a135e1f85 Mon Sep 17 00:00:00 2001 From: enumag Date: Mon, 9 Jul 2012 21:51:20 +0300 Subject: [PATCH 70/77] typos --- Nette/Forms/Controls/TextArea.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Nette/Forms/Controls/TextArea.php b/Nette/Forms/Controls/TextArea.php index 2629a1d406..b0c68b1850 100644 --- a/Nette/Forms/Controls/TextArea.php +++ b/Nette/Forms/Controls/TextArea.php @@ -24,7 +24,6 @@ class TextArea extends TextBase { /** - * @param string control name * @param string label * @param int width of the control * @param int height of the control in text lines From ce196dc77bcafbefd348ce36a88f2899fba8a06b Mon Sep 17 00:00:00 2001 From: enumag Date: Sat, 9 Jun 2012 00:31:00 +0300 Subject: [PATCH 71/77] typos --- Nette/Forms/Controls/SelectBox.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Nette/Forms/Controls/SelectBox.php b/Nette/Forms/Controls/SelectBox.php index 3dcbaab2a6..383d4ad147 100644 --- a/Nette/Forms/Controls/SelectBox.php +++ b/Nette/Forms/Controls/SelectBox.php @@ -148,6 +148,7 @@ final public function areKeysUsed() /** * Sets items from which to choose. * @param array + * @param bool * @return SelectBox provides a fluent interface */ public function setItems(array $items, $useKeys = TRUE) From be521c1ea56871669199de11e829f774d365e51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Sebastian=20Fab=C3=ADk?= Date: Sat, 2 Jun 2012 12:25:16 +0300 Subject: [PATCH 72/77] typo --- Nette/Security/IResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nette/Security/IResource.php b/Nette/Security/IResource.php index e6caab27e9..5cf632464b 100644 --- a/Nette/Security/IResource.php +++ b/Nette/Security/IResource.php @@ -27,6 +27,6 @@ interface IResource * Returns a string identifier of the Resource. * @return string */ - public function getResourceId(); + function getResourceId(); } From c2956bb6534fe46f93f2407d5dd79ba4f896a3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Sebastian=20Fab=C3=ADk?= Date: Sat, 2 Jun 2012 12:26:23 +0300 Subject: [PATCH 73/77] typo --- Nette/Security/IRole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nette/Security/IRole.php b/Nette/Security/IRole.php index 227addb08a..9a0869e41b 100644 --- a/Nette/Security/IRole.php +++ b/Nette/Security/IRole.php @@ -27,6 +27,6 @@ interface IRole * Returns a string identifier of the Role. * @return string */ - public function getRoleId(); + function getRoleId(); } From b1357dd05aa74273a18183b38f0bd8ee2ce89d05 Mon Sep 17 00:00:00 2001 From: Michal Gebauer Date: Thu, 24 May 2012 15:24:58 +0300 Subject: [PATCH 74/77] typo --- readme.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 5d193d20c8..4a547113c2 100644 --- a/readme.txt +++ b/readme.txt @@ -4,10 +4,10 @@ Welcome to Nette Framework Nette Framework is a powerful, component-based and event-driven framework for creating web applications and services in PHP 5.2 & 5.3. Nette Framework is designed with simplicity, speed and flexibility in mind. It allows developers -to easy built better websites. +to easily build better websites. Nette Framework focuses on security and performance and is definitely one of -the safest and fastest PHP frameworks. Nette Framework support the latest +the safest and fastest PHP frameworks. Nette Framework supports the latest technologies and approaches like AJAX, HTML5, SEO, DRY, KISS, MVC, etc. @@ -28,7 +28,7 @@ extract it to a directory accessible by web server. The installation is done! The source tree includes the following directories: - Nette: this directory contains the source code of Nette Framework. This is - the only directory that you will need in order to deploy with your application. + the only directory that you will need in order to deploy your application. - Nette-minified: contains Nette Framework source code compressed into single file. From 255a822943c1fdd9393c9b5c2bf59d95661dae25 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 25 Jul 2012 16:40:33 +0200 Subject: [PATCH 75/77] typo --- .../Nette/Latte/{macros.contentType.phpt => macros.status.phpt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/Nette/Latte/{macros.contentType.phpt => macros.status.phpt} (91%) diff --git a/tests/Nette/Latte/macros.contentType.phpt b/tests/Nette/Latte/macros.status.phpt similarity index 91% rename from tests/Nette/Latte/macros.contentType.phpt rename to tests/Nette/Latte/macros.status.phpt index acd3d048a8..74d1486cbe 100644 --- a/tests/Nette/Latte/macros.contentType.phpt +++ b/tests/Nette/Latte/macros.status.phpt @@ -1,7 +1,7 @@ Date: Mon, 30 Jul 2012 01:29:46 +0300 Subject: [PATCH 76/77] phpdoc typo Fixes PhpEd bug when intelliSense prefere private phpdoc over property-read definition. --- Nette/Application/UI/Presenter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nette/Application/UI/Presenter.php b/Nette/Application/UI/Presenter.php index 3873e6e16f..37a778d2ac 100644 --- a/Nette/Application/UI/Presenter.php +++ b/Nette/Application/UI/Presenter.php @@ -108,7 +108,7 @@ abstract class Presenter extends Control implements Application\IPresenter /** @var array */ private $lastCreatedRequestFlag; - /** @var Nette\DI\Container */ + /** @var \SystemContainer|Nette\DI\Container */ private $context; From 2f3808e49e0d34242e68cf3fd57e1b0ac375516a Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 30 Jul 2012 19:59:14 +0100 Subject: [PATCH 77/77] Released version 2.0.4 --- Nette/common/Framework.php | 2 +- Nette/loader.php | 4 ++-- version.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Nette/common/Framework.php b/Nette/common/Framework.php index 678f134cd7..3051b80197 100644 --- a/Nette/common/Framework.php +++ b/Nette/common/Framework.php @@ -25,7 +25,7 @@ final class Framework /** Nette Framework version identification */ const NAME = 'Nette Framework', - VERSION = '2.0.3', + VERSION = '2.0.4', REVISION = '$WCREV$ released on $WCDATE$'; /** @var bool set to TRUE if your host has disabled function ini_set */ diff --git a/Nette/loader.php b/Nette/loader.php index 3ad30652c1..e8d22a6fc3 100644 --- a/Nette/loader.php +++ b/Nette/loader.php @@ -1,7 +1,7 @@