From 5e8a6739503ad68763c6cbdbf3aee2e97e0da74a Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Sat, 26 Dec 2015 01:40:27 +0100 Subject: [PATCH 01/29] Php Inspections (EA Extended): Static Code Analysis - mkdir race conditions fixed - code simplification - functions miss-uses fixed - one time use variables dropped - more minor and bug-fixes --- data/bin/sandbox_installer.php | 2 +- lib/cache/sfFileCache.class.php | 8 ++++---- lib/cache/sfSQLiteCache.class.php | 2 +- lib/command/sfAnsiColorFormatter.class.php | 2 +- lib/config/sfConfigCache.class.php | 10 ++++------ lib/database/sfPDODatabase.class.php | 2 +- lib/debug/sfWebDebugPanelMemory.class.php | 2 +- lib/generator/sfGeneratorManager.class.php | 7 ++++--- lib/helper/TagHelper.php | 2 +- lib/helper/TextHelper.php | 4 ++-- lib/helper/UrlHelper.php | 2 +- lib/i18n/sfChoiceFormat.class.php | 7 +------ lib/i18n/sfMessageSource_MySQL.class.php | 8 ++------ lib/i18n/sfMessageSource_SQLite3.class.php | 12 ++++++------ lib/i18n/sfMessageSource_XLIFF.class.php | 4 +--- lib/log/sfFileLogger.class.php | 7 ++++--- lib/plugin/sfPearConfig.class.php | 4 +--- lib/plugin/sfPearEnvironment.class.php | 4 ++-- lib/request/sfWebRequest.class.php | 4 ++-- lib/response/sfWebResponse.class.php | 2 +- lib/storage/sfSessionTestStorage.class.php | 7 ++++--- lib/task/generator/sfGenerateProjectTask.class.php | 2 +- lib/task/i18n/sfI18nExtractTask.class.php | 4 ++-- lib/util/sfToolkit.class.php | 2 +- lib/validator/sfValidatedFile.class.php | 4 ++-- lib/validator/sfValidatorDate.class.php | 2 +- lib/validator/sfValidatorTime.class.php | 2 +- lib/view/sfViewCacheManager.class.php | 2 +- 28 files changed, 54 insertions(+), 66 deletions(-) diff --git a/data/bin/sandbox_installer.php b/data/bin/sandbox_installer.php index f503e0a03..c45891174 100644 --- a/data/bin/sandbox_installer.php +++ b/data/bin/sandbox_installer.php @@ -26,7 +26,7 @@ $seen = array(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(sfConfig::get('sf_root_dir')), RecursiveIteratorIterator::CHILD_FIRST) as $path => $item) { - if ($item->isDir() && !$item->isLink() && !isset($seen[$path])) + if (!isset($seen[$path]) && $item->isDir() && !$item->isLink()) { touch($item->getRealPath().'/.sf'); } diff --git a/lib/cache/sfFileCache.class.php b/lib/cache/sfFileCache.class.php index 19c0ac4cb..33c09177c 100644 --- a/lib/cache/sfFileCache.class.php +++ b/lib/cache/sfFileCache.class.php @@ -277,13 +277,13 @@ protected function write($path, $data, $timeout) $current_umask = umask(); umask(0000); - if (!is_dir(dirname($path))) + $cacheDir = dirname($path); + if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { - // create directory structure if needed - mkdir(dirname($path), 0777, true); + throw new sfCacheException(sprintf('Cache was not able to create a directory "%s".', $cacheDir)); } - $tmpFile = tempnam(dirname($path), basename($path)); + $tmpFile = tempnam($cacheDir, basename($path)); if (!$fp = @fopen($tmpFile, 'wb')) { diff --git a/lib/cache/sfSQLiteCache.class.php b/lib/cache/sfSQLiteCache.class.php index 61916037b..f46d4f80f 100644 --- a/lib/cache/sfSQLiteCache.class.php +++ b/lib/cache/sfSQLiteCache.class.php @@ -142,7 +142,7 @@ public function clean($mode = sfCache::ALL) { $res = $this->dbh->exec("DELETE FROM cache".(sfCache::OLD == $mode ? sprintf(" WHERE timeout < '%s'", time()) : '')); - if ($res); + if ($res) { return (boolean) $this->dbh->changes(); } diff --git a/lib/command/sfAnsiColorFormatter.class.php b/lib/command/sfAnsiColorFormatter.class.php index 71cba3d03..37a3ec23d 100644 --- a/lib/command/sfAnsiColorFormatter.class.php +++ b/lib/command/sfAnsiColorFormatter.class.php @@ -98,7 +98,7 @@ public function formatSection($section, $text, $size = null, $style = 'INFO') $style = array_key_exists($style, $this->styles) ? $style : 'INFO'; $width = 9 + strlen($this->format('', $style)); - return sprintf(">> %-{$width}s %s", $this->format($section, $style), $this->excerpt($text, $size - 4 - (strlen($section) > 9 ? strlen($section) : 9))); + return sprintf(">> %-${width}s %s", $this->format($section, $style), $this->excerpt($text, $size - 4 - (strlen($section) > 9 ? strlen($section) : 9))); } /** diff --git a/lib/config/sfConfigCache.class.php b/lib/config/sfConfigCache.class.php index eb2d4555b..d8a1eb55b 100644 --- a/lib/config/sfConfigCache.class.php +++ b/lib/config/sfConfigCache.class.php @@ -333,15 +333,13 @@ protected function loadConfigHandlers() protected function writeCacheFile($config, $cache, $data) { $current_umask = umask(0000); - if (!is_dir(dirname($cache))) + $cacheDir = dirname($cache); + if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { - if (false === @mkdir(dirname($cache), 0777, true)) - { - throw new sfCacheException(sprintf('Failed to make cache directory "%s" while generating cache for configuration file "%s".', dirname($cache), $config)); - } + throw new \sfCacheException(sprintf('Failed to make cache directory "%s" while generating cache for configuration file "%s".', $cacheDir, $config)); } - $tmpFile = tempnam(dirname($cache), basename($cache)); + $tmpFile = tempnam($cacheDir, basename($cache)); if (!$fp = @fopen($tmpFile, 'wb')) { diff --git a/lib/database/sfPDODatabase.class.php b/lib/database/sfPDODatabase.class.php index 7e7ceddc9..886d19d0c 100644 --- a/lib/database/sfPDODatabase.class.php +++ b/lib/database/sfPDODatabase.class.php @@ -42,7 +42,7 @@ public function connect() $password = $this->getParameter('password'); $persistent = $this->getParameter('persistent'); - $options = ($persistent) ? array(PDO::ATTR_PERSISTENT => true) : array(); + $options = $persistent ? array(PDO::ATTR_PERSISTENT => true) : array(); $this->connection = new $pdo_class($dsn, $username, $password, $options); diff --git a/lib/debug/sfWebDebugPanelMemory.class.php b/lib/debug/sfWebDebugPanelMemory.class.php index fdda5ec03..2a37073ab 100644 --- a/lib/debug/sfWebDebugPanelMemory.class.php +++ b/lib/debug/sfWebDebugPanelMemory.class.php @@ -20,7 +20,7 @@ class sfWebDebugPanelMemory extends sfWebDebugPanel { public function getTitle() { - $totalMemory = sprintf('%.1f', (memory_get_peak_usage(true) / 1024)); + $totalMemory = sprintf('%.1f', memory_get_peak_usage(true) / 1024); return 'Memory '.$totalMemory.' KB'; } diff --git a/lib/generator/sfGeneratorManager.class.php b/lib/generator/sfGeneratorManager.class.php index 9b2dd4754..d7dfaebbc 100644 --- a/lib/generator/sfGeneratorManager.class.php +++ b/lib/generator/sfGeneratorManager.class.php @@ -80,12 +80,13 @@ public function save($path, $content) { $path = $this->getBasePath().DIRECTORY_SEPARATOR.$path; - if (!is_dir(dirname($path))) + $cacheDir = dirname($path); + if (!is_dir($cacheDir)) { $current_umask = umask(0000); - if (false === @mkdir(dirname($path), 0777, true)) + if (!@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { - throw new sfCacheException(sprintf('Failed to make cache directory "%s".', dirname($path))); + throw new \sfCacheException(sprintf('Failed to make cache directory "%s".', $cacheDir)); } umask($current_umask); } diff --git a/lib/helper/TagHelper.php b/lib/helper/TagHelper.php index b2b5e01c5..848895109 100644 --- a/lib/helper/TagHelper.php +++ b/lib/helper/TagHelper.php @@ -34,7 +34,7 @@ function tag($name, $options = array(), $open = false) return ''; } - return '<'.$name._tag_options($options).(($open) ? '>' : ' />'); + return '<'.$name._tag_options($options).($open ? '>' : ' />'); } function content_tag($name, $content = '', $options = array()) diff --git a/lib/helper/TextHelper.php b/lib/helper/TextHelper.php index 6bb9adef8..a09029c1e 100644 --- a/lib/helper/TextHelper.php +++ b/lib/helper/TextHelper.php @@ -45,8 +45,8 @@ function truncate_text($text, $length = 30, $truncate_string = '...', $truncate_ $old_encoding = mb_internal_encoding(); @mb_internal_encoding(mb_detect_encoding($text)); } - $strlen = ($mbstring) ? 'mb_strlen' : 'strlen'; - $substr = ($mbstring) ? 'mb_substr' : 'substr'; + $strlen = $mbstring ? 'mb_strlen' : 'strlen'; + $substr = $mbstring ? 'mb_substr' : 'substr'; if ($strlen($text) > $length) { diff --git a/lib/helper/UrlHelper.php b/lib/helper/UrlHelper.php index 2c380c494..88b1895ac 100644 --- a/lib/helper/UrlHelper.php +++ b/lib/helper/UrlHelper.php @@ -74,7 +74,7 @@ function link_to1($name, $internal_uri, $options = array()) } } - if (!strlen($name)) + if ('' === $name) { $name = $html_options['href']; } diff --git a/lib/i18n/sfChoiceFormat.class.php b/lib/i18n/sfChoiceFormat.class.php index 02c4be9e7..8c3e99681 100644 --- a/lib/i18n/sfChoiceFormat.class.php +++ b/lib/i18n/sfChoiceFormat.class.php @@ -155,12 +155,7 @@ public function isValid($number, $set) $right = $number < $elements[$total - 1]; } - if ($left && $right) - { - return true; - } - - return false; + return $left && $right; } protected function isValidSetNotation($number, $set) diff --git a/lib/i18n/sfMessageSource_MySQL.class.php b/lib/i18n/sfMessageSource_MySQL.class.php index a1b7b0ec3..5fbfec015 100644 --- a/lib/i18n/sfMessageSource_MySQL.class.php +++ b/lib/i18n/sfMessageSource_MySQL.class.php @@ -255,9 +255,7 @@ protected function getLastModified($source) $rs = mysql_query("SELECT date_modified FROM catalogue WHERE name = '{$source}'", $this->db); - $result = $rs ? (int) mysql_result($rs, 0) : 0; - - return $result; + return $rs ? (int)mysql_result($rs, 0) : 0; } /** @@ -274,9 +272,7 @@ public function isValidSource($variant) $row = mysql_fetch_array($rs, MYSQL_NUM); - $result = $row && $row[0] == '1'; - - return $result; + return $row && $row[0] == '1'; } /** diff --git a/lib/i18n/sfMessageSource_SQLite3.class.php b/lib/i18n/sfMessageSource_SQLite3.class.php index 7a639eafe..45cd7e7e9 100644 --- a/lib/i18n/sfMessageSource_SQLite3.class.php +++ b/lib/i18n/sfMessageSource_SQLite3.class.php @@ -138,7 +138,7 @@ public function &loadData($variant) $result[$source][] = $row[3]; //comments } - $db->close();; + $db->close(); return $result; } @@ -177,7 +177,7 @@ public function isValidSource($variant) $rs = $db->querySingle("SELECT COUNT(*) FROM catalogue WHERE name = '{$variant}'"); $result = null !== $rs && (int) $rs; - $db->close();; + $db->close(); return $result; } @@ -303,7 +303,7 @@ public function save($catalogue = 'messages') $this->updateCatalogueTime($cat_id, $variant); } - $db->close();; + $db->close(); return $inserted > 0; } @@ -345,7 +345,7 @@ function update($text, $target, $comments, $catalogue = 'messages') $updated = true; } - $db->close();; + $db->close(); return $updated; } @@ -384,7 +384,7 @@ function delete($message, $catalogue = 'messages') $deleted = false; } - $db->close();; + $db->close(); return $deleted; } @@ -411,7 +411,7 @@ function catalogues() $result[] = $details; } - $db->close();; + $db->close(); return $result; } diff --git a/lib/i18n/sfMessageSource_XLIFF.class.php b/lib/i18n/sfMessageSource_XLIFF.class.php index 01dda3b7f..e6f8fdecc 100644 --- a/lib/i18n/sfMessageSource_XLIFF.class.php +++ b/lib/i18n/sfMessageSource_XLIFF.class.php @@ -53,9 +53,7 @@ public function &loadData($filename) libxml_use_internal_errors(true); if (!$xml = simplexml_load_file($filename)) { - $error = false; - - return $error; + return false; } libxml_use_internal_errors(false); diff --git a/lib/log/sfFileLogger.class.php b/lib/log/sfFileLogger.class.php index 6cc4421bf..f4d9d4cce 100644 --- a/lib/log/sfFileLogger.class.php +++ b/lib/log/sfFileLogger.class.php @@ -63,10 +63,11 @@ public function initialize(sfEventDispatcher $dispatcher, $options = array()) $this->type = $options['type']; } - $dir = dirname($options['file']); - if (!is_dir($dir)) + $dir = dirname($options['file']); + $dirMode = isset($options['dir_mode']) ? $options['dir_mode'] : 0777; + if (!is_dir($dir) && !@mkdir($dir, $dirMode, true) && !is_dir($dir)) { - mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true); + throw new \RuntimeException(sprintf('Logger was not able to create a directory "%s"', $dir)); } $fileExists = file_exists($options['file']); diff --git a/lib/plugin/sfPearConfig.class.php b/lib/plugin/sfPearConfig.class.php index 2c81c180a..cf0f1336e 100644 --- a/lib/plugin/sfPearConfig.class.php +++ b/lib/plugin/sfPearConfig.class.php @@ -24,8 +24,6 @@ function &getREST($version, $options = array()) { $class = 'sfPearRest'.str_replace('.', '', $version); - $remote = new $class($this, $options); - - return $remote; + return new $class($this, $options); } } diff --git a/lib/plugin/sfPearEnvironment.class.php b/lib/plugin/sfPearEnvironment.class.php index 769bd5779..83c748f32 100644 --- a/lib/plugin/sfPearEnvironment.class.php +++ b/lib/plugin/sfPearEnvironment.class.php @@ -79,9 +79,9 @@ public function initialize(sfEventDispatcher $dispatcher, $options = array()) throw new sfConfigurationException('You must provide a "cache_dir" option.'); } - if (!is_dir($options['cache_dir'])) + if (!is_dir($options['cache_dir']) && !@mkdir($options['cache_dir'], 0777, true) && !is_dir($options['cache_dir'])) { - mkdir($options['cache_dir'], 0777, true); + throw new \RuntimeException(sprintf('Pear was not able to create a directory "%s"', $options['cache_dir'])); } if (!isset($options['rest_base_class'])) diff --git a/lib/request/sfWebRequest.class.php b/lib/request/sfWebRequest.class.php index ea95414e4..7839899ff 100644 --- a/lib/request/sfWebRequest.class.php +++ b/lib/request/sfWebRequest.class.php @@ -579,7 +579,7 @@ public function getHttpHeader($name, $prefix = 'http') $prefix = strtoupper($prefix).'_'; } - $name = $prefix.strtoupper(strtr($name, '-', '_')); + $name = $prefix.strtoupper(str_replace('-', '_', $name)); $pathArray = $this->getPathInfoArray(); @@ -991,7 +991,7 @@ public function getClientIp($proxy = true) if ($this->getOption('trust_proxy') && ($ip = $this->getForwardedFor())) { - return isset($ip[0]) ? trim($ip[0]) : '';; + return isset($ip[0]) ? trim($ip[0]) : ''; } } diff --git a/lib/response/sfWebResponse.class.php b/lib/response/sfWebResponse.class.php index 36dd49102..9bb9cabc3 100644 --- a/lib/response/sfWebResponse.class.php +++ b/lib/response/sfWebResponse.class.php @@ -484,7 +484,7 @@ public function addCacheControlHttpHeader($name, $value = null) $currentHeaders[$tmp[0]] = isset($tmp[1]) ? $tmp[1] : null; } } - $currentHeaders[strtr(strtolower($name), '_', '-')] = $value; + $currentHeaders[str_replace('_', '-', strtolower($name))] = $value; $headers = array(); foreach ($currentHeaders as $key => $value) diff --git a/lib/storage/sfSessionTestStorage.class.php b/lib/storage/sfSessionTestStorage.class.php index 86cbd5aa2..5cc6b59d8 100644 --- a/lib/storage/sfSessionTestStorage.class.php +++ b/lib/storage/sfSessionTestStorage.class.php @@ -158,12 +158,13 @@ public function shutdown() if ($this->sessionId) { $current_umask = umask(0000); - if (!is_dir($this->options['session_path'])) + $sessionsDir = $this->options['session_path']; + if (!is_dir($sessionsDir) && !@mkdir($sessionsDir, 0777, true) && !is_dir($sessionsDir)) { - mkdir($this->options['session_path'], 0777, true); + throw new \RuntimeException(sprintf('Logger was not able to create a directory "%s"', $sessionsDir)); } umask($current_umask); - file_put_contents($this->options['session_path'].DIRECTORY_SEPARATOR.$this->sessionId.'.session', serialize($this->sessionData)); + file_put_contents($sessionsDir.DIRECTORY_SEPARATOR.$this->sessionId.'.session', serialize($this->sessionData)); $this->sessionId = ''; $this->sessionData = array(); } diff --git a/lib/task/generator/sfGenerateProjectTask.class.php b/lib/task/generator/sfGenerateProjectTask.class.php index 1c6d0e77b..1cfcb4343 100755 --- a/lib/task/generator/sfGenerateProjectTask.class.php +++ b/lib/task/generator/sfGenerateProjectTask.class.php @@ -123,7 +123,7 @@ protected function execute($arguments = array(), $options = array()) $this->replaceTokens(); // execute the choosen ORM installer script - if (in_array($options['orm'], array('Doctrine'))) + if ('Doctrine' === $options['orm']) { include __DIR__.'/../../plugins/sf'.$options['orm'].'Plugin/config/installer.php'; } diff --git a/lib/task/i18n/sfI18nExtractTask.class.php b/lib/task/i18n/sfI18nExtractTask.class.php index 387d69e8a..95f6fa8f6 100644 --- a/lib/task/i18n/sfI18nExtractTask.class.php +++ b/lib/task/i18n/sfI18nExtractTask.class.php @@ -103,7 +103,7 @@ public function execute($arguments = array(), $options = array()) if ($options['display-new']) { - $this->logSection('i18n', sprintf('display new i18n strings', count($extract->getOldMessages()))); + $this->logSection('i18n', sprintf('display "%d" new i18n strings', count($extract->getOldMessages()))); foreach ($extract->getNewMessages() as $message) { $this->log(' '.$message."\n"); @@ -119,7 +119,7 @@ public function execute($arguments = array(), $options = array()) if ($options['display-old']) { - $this->logSection('i18n', sprintf('display old i18n strings', count($extract->getOldMessages()))); + $this->logSection('i18n', sprintf('display "%d" old i18n strings', count($extract->getOldMessages()))); foreach ($extract->getOldMessages() as $message) { $this->log(' '.$message."\n"); diff --git a/lib/util/sfToolkit.class.php b/lib/util/sfToolkit.class.php index 6c8f7b368..d631cde44 100644 --- a/lib/util/sfToolkit.class.php +++ b/lib/util/sfToolkit.class.php @@ -380,7 +380,7 @@ public static function isArrayValuesEmpty($array) static $isEmpty = true; foreach ($array as $value) { - $isEmpty = (is_array($value)) ? self::isArrayValuesEmpty($value) : (strlen($value) == 0); + $isEmpty = is_array($value) ? self::isArrayValuesEmpty($value) : '' === (string)$value; if (!$isEmpty) { break; diff --git a/lib/validator/sfValidatedFile.class.php b/lib/validator/sfValidatedFile.class.php index 23ea76061..a6959f016 100644 --- a/lib/validator/sfValidatedFile.class.php +++ b/lib/validator/sfValidatedFile.class.php @@ -91,10 +91,10 @@ public function save($file = null, $fileMode = 0666, $create = true, $dirMode = if (!is_readable($directory)) { - if ($create && !@mkdir($directory, $dirMode, true)) + if ($create && !@mkdir($directory, $dirMode, true) && !is_dir($directory)) { // failed to create the directory - throw new Exception(sprintf('Failed to create file upload directory "%s".', $directory)); + throw new \Exception(sprintf('Failed to create file upload directory "%s".', $directory)); } // chmod the directory since it doesn't seem to work on recursive paths diff --git a/lib/validator/sfValidatorDate.class.php b/lib/validator/sfValidatorDate.class.php index 594e3b44c..2cc5ffdec 100644 --- a/lib/validator/sfValidatorDate.class.php +++ b/lib/validator/sfValidatorDate.class.php @@ -174,7 +174,7 @@ protected function convertDateArrayToString($value) // all elements must be empty or a number foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $key) { - if (isset($value[$key]) && !preg_match('#^\d+$#', $value[$key]) && !empty($value[$key])) + if (isset($value[$key]) && !empty($value[$key]) && !ctype_digit($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } diff --git a/lib/validator/sfValidatorTime.class.php b/lib/validator/sfValidatorTime.class.php index 5a3a70a50..9450e6400 100644 --- a/lib/validator/sfValidatorTime.class.php +++ b/lib/validator/sfValidatorTime.class.php @@ -94,7 +94,7 @@ protected function convertTimeArrayToTimestamp($value) // all elements must be empty or a number foreach (array('hour', 'minute', 'second') as $key) { - if (isset($value[$key]) && !preg_match('#^\d+$#', $value[$key]) && !empty($value[$key])) + if (isset($value[$key]) && !empty($value[$key]) && !ctype_digit($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } diff --git a/lib/view/sfViewCacheManager.class.php b/lib/view/sfViewCacheManager.class.php index 5c2c7eaf7..834d46697 100644 --- a/lib/view/sfViewCacheManager.class.php +++ b/lib/view/sfViewCacheManager.class.php @@ -307,7 +307,7 @@ public function addCache($moduleName, $actionName, $options = array()) { foreach ($options['vary'] as $key => $name) { - $options['vary'][$key] = strtr(strtolower($name), '_', '-'); + $options['vary'][$key] = str_replace('_', '-', strtolower($name)); } } From 8cc5364aea5cb818f9554715a5e35d181a2aa381 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Sat, 26 Dec 2015 01:52:09 +0100 Subject: [PATCH 02/29] Php Inspections (EA Extended): fixing UTs --- lib/cache/sfFileCache.class.php | 2 +- lib/validator/sfValidatorDate.class.php | 2 +- lib/validator/sfValidatorTime.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cache/sfFileCache.class.php b/lib/cache/sfFileCache.class.php index 33c09177c..72f8c9cf0 100644 --- a/lib/cache/sfFileCache.class.php +++ b/lib/cache/sfFileCache.class.php @@ -280,7 +280,7 @@ protected function write($path, $data, $timeout) $cacheDir = dirname($path); if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) { - throw new sfCacheException(sprintf('Cache was not able to create a directory "%s".', $cacheDir)); + throw new \sfCacheException(sprintf('Cache was not able to create a directory "%s".', $cacheDir)); } $tmpFile = tempnam($cacheDir, basename($path)); diff --git a/lib/validator/sfValidatorDate.class.php b/lib/validator/sfValidatorDate.class.php index 2cc5ffdec..3b7e1f199 100644 --- a/lib/validator/sfValidatorDate.class.php +++ b/lib/validator/sfValidatorDate.class.php @@ -174,7 +174,7 @@ protected function convertDateArrayToString($value) // all elements must be empty or a number foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $key) { - if (isset($value[$key]) && !empty($value[$key]) && !ctype_digit($value[$key])) + if (isset($value[$key]) && !ctype_digit($value[$key]) && !empty($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } diff --git a/lib/validator/sfValidatorTime.class.php b/lib/validator/sfValidatorTime.class.php index 9450e6400..c1d857b18 100644 --- a/lib/validator/sfValidatorTime.class.php +++ b/lib/validator/sfValidatorTime.class.php @@ -94,7 +94,7 @@ protected function convertTimeArrayToTimestamp($value) // all elements must be empty or a number foreach (array('hour', 'minute', 'second') as $key) { - if (isset($value[$key]) && !empty($value[$key]) && !ctype_digit($value[$key])) + if (isset($value[$key]) && !ctype_digit($value[$key]) && !empty($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } From 99da217a97e21151774cc21832a247d70229b500 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Sat, 26 Dec 2015 01:59:22 +0100 Subject: [PATCH 03/29] Php Inspections (EA Extended): fixing UTs --- lib/validator/sfValidatorDate.class.php | 2 +- lib/validator/sfValidatorTime.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/validator/sfValidatorDate.class.php b/lib/validator/sfValidatorDate.class.php index 3b7e1f199..1b03cb6f8 100644 --- a/lib/validator/sfValidatorDate.class.php +++ b/lib/validator/sfValidatorDate.class.php @@ -174,7 +174,7 @@ protected function convertDateArrayToString($value) // all elements must be empty or a number foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $key) { - if (isset($value[$key]) && !ctype_digit($value[$key]) && !empty($value[$key])) + if (isset($value[$key]) && !ctype_digit((string)$value[$key]) && !empty($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } diff --git a/lib/validator/sfValidatorTime.class.php b/lib/validator/sfValidatorTime.class.php index c1d857b18..bc18924fc 100644 --- a/lib/validator/sfValidatorTime.class.php +++ b/lib/validator/sfValidatorTime.class.php @@ -94,7 +94,7 @@ protected function convertTimeArrayToTimestamp($value) // all elements must be empty or a number foreach (array('hour', 'minute', 'second') as $key) { - if (isset($value[$key]) && !ctype_digit($value[$key]) && !empty($value[$key])) + if (isset($value[$key]) && !ctype_digit((string)$value[$key]) && !empty($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } From 2ac7b67239ccf5b8bac64ffb756f0f53fd96042d Mon Sep 17 00:00:00 2001 From: Robin Corps Date: Fri, 15 Jan 2016 15:29:43 +0000 Subject: [PATCH 04/29] Fix integers used in mt_rand() The first integer provided was larger than the second one which causes PHP to generate a warning. Have removed a 1 from the first integer to make it smaller than the second. --- lib/task/generator/sfGenerateAppTask.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/task/generator/sfGenerateAppTask.class.php b/lib/task/generator/sfGenerateAppTask.class.php index 1abd35572..21f1e3e3e 100644 --- a/lib/task/generator/sfGenerateAppTask.class.php +++ b/lib/task/generator/sfGenerateAppTask.class.php @@ -118,7 +118,7 @@ protected function execute($arguments = array(), $options = array()) if (true === $options['csrf-secret']) { - $options['csrf-secret'] = sha1(mt_rand(111111111, 99999999).getmypid()); + $options['csrf-secret'] = sha1(mt_rand(11111111, 99999999).getmypid()); } // Set no_script_name value in settings.yml for production environment From ab7045d8aacd57c71cb3e2a8d3e6c80960466239 Mon Sep 17 00:00:00 2001 From: zema Date: Fri, 29 Jan 2016 11:27:13 +0200 Subject: [PATCH 05/29] Change parameter of sfAction::renderJson --- lib/action/sfAction.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/action/sfAction.class.php b/lib/action/sfAction.class.php index 503fa9f2d..5567d17e2 100644 --- a/lib/action/sfAction.class.php +++ b/lib/action/sfAction.class.php @@ -269,15 +269,15 @@ public function renderText($text) } /** - * Convert the given array of data into a JSON response. + * Convert the given data into a JSON response. * * return $this->renderJson(array('username' => 'john')) * - * @param array $data Data to encode as JSON + * @param mixed $data Data to encode as JSON * * @return sfView::NONE */ - public function renderJson(array $data) + public function renderJson($data) { $this->getResponse()->setContentType('application/json'); $this->getResponse()->setContent(json_encode($data)); From 80f92801e12cbac6b99f221eb62cff9c96fa885b Mon Sep 17 00:00:00 2001 From: Jeremy BENOIST Date: Mon, 1 Feb 2016 17:26:07 +0100 Subject: [PATCH 06/29] CS --- lib/form/sfForm.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/form/sfForm.class.php b/lib/form/sfForm.class.php index c87531e6d..4d206a7d3 100644 --- a/lib/form/sfForm.class.php +++ b/lib/form/sfForm.class.php @@ -610,7 +610,8 @@ public function setValidators(array $validators) */ public function setValidator($name, sfValidatorBase $validator) { - if (isset($this->embeddedForms[$name])) { + if (isset($this->embeddedForms[$name])) + { throw new LogicException('You cannot set a validator for an embedded form.'); } @@ -635,7 +636,8 @@ public function getValidator($name) throw new InvalidArgumentException(sprintf('The validator "%s" does not exist.', $name)); } - if (isset($this->embeddedForms[$name])) { + if (isset($this->embeddedForms[$name])) + { return $this->embeddedForms[$name]->getValidatorSchema(); } From c2674aec0265bb46c54417c3b76b584e93c9198a Mon Sep 17 00:00:00 2001 From: Jeremy BENOIST Date: Mon, 1 Feb 2016 18:10:28 +0100 Subject: [PATCH 07/29] Prepare 1.5.7 --- CHANGELOG.md | 11 +++++++++++ lib/autoload/sfCoreAutoload.class.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1829f11dd..8dde5ce54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ CHANGELOG ========= +02/02/2016: Version 1.5.7 +------------------------- + +* Fix error in embedded form #105 +* Added HTTP PATCH request method #110 +* Fix integers used in mt_rand() #113 +* Remove array cast from parameter of sfAction::renderJson #115 +* Don't post unnamed submit fields in sfBrowserBase #112 +* Add support for traits in autoloaders #112 +* Php Inspections (EA Extended): Static Code Analysis #111 + 22/07/2015: Version 1.5.6 ------------------------- diff --git a/lib/autoload/sfCoreAutoload.class.php b/lib/autoload/sfCoreAutoload.class.php index eb4de4ab6..b25199aa2 100755 --- a/lib/autoload/sfCoreAutoload.class.php +++ b/lib/autoload/sfCoreAutoload.class.php @@ -11,7 +11,7 @@ /** * The current symfony version. */ -define('SYMFONY_VERSION', '1.5.7-dev'); +define('SYMFONY_VERSION', '1.5.7'); /** * sfCoreAutoload class. From 6ac65f72d833542cee408f64dcf374725aa98dc5 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 1 Feb 2016 19:16:22 +0100 Subject: [PATCH 08/29] Use PHP 7.0 instead of nightly --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e065da05..ae0919ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,14 @@ php: - 5.4 - 5.5 - 5.6 - - nightly + - 7.0 - hhvm # run build against nightly but allow them to fail matrix: fast_finish: true allow_failures: - - php: nightly + - php: 7.0 - php: hhvm # faster builds on new travis setup not using sudo @@ -33,4 +33,4 @@ before_script: script: - php data/bin/check_configuration.php - - php -dshort_open_tag=Off -dmagic_quotes_gpc=Off data/bin/symfony symfony:test --trace + - php data/bin/symfony symfony:test --trace From ba992f9bd2bf7a9387b2b59d512bd285095ef997 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 1 Feb 2016 19:22:11 +0100 Subject: [PATCH 09/29] Update UPGRADE file about configureDoctrine Fix #42 --- UPGRADE.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index bb5289e24..b78b52f57 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -26,3 +26,32 @@ Due to the new embed form enhancements: * You cannot added the same `sfValidatorErrorSchema` instance twice or more into an `sfValidatorErrorSchema`. * The method `sfValidatorErrorSchema::addErrors` only accept an `sfValidatorErrorSchema` instance as argument. + The `sfValidatorErrorSchema` constructor no longer accept an array of errors as second argument. + +Doctrine & Project configuration +-------------------------------- + +Previously, you were able to configure doctrine in your `/config/ProjectConfiguration.class.php` using the method `configureDoctrine`. +This method isn't called anymore. You know need to connect to the `doctrine.configure` event: + +```php +dispatcher->connect('doctrine.configure', array($this, 'configureDoctrineEvent')); + } + + public function configureDoctrineEvent(sfEvent $event) + { + $manager = $event->getSubject(); + + // configure what ever you want on the doctrine manager + $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, false); + } +} +``` From b64c0fb81bef64af34defadf861ac1cf2545c8d3 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 2 Feb 2016 09:40:59 +0100 Subject: [PATCH 10/29] Typo --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index b78b52f57..d43c4ac13 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -31,7 +31,7 @@ Doctrine & Project configuration -------------------------------- Previously, you were able to configure doctrine in your `/config/ProjectConfiguration.class.php` using the method `configureDoctrine`. -This method isn't called anymore. You know need to connect to the `doctrine.configure` event: +This method isn't called anymore. You now need to connect to the `doctrine.configure` event: ```php Date: Tue, 2 Feb 2016 15:31:33 +0100 Subject: [PATCH 11/29] Prepare next release --- lib/autoload/sfCoreAutoload.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/autoload/sfCoreAutoload.class.php b/lib/autoload/sfCoreAutoload.class.php index b25199aa2..a7c47178b 100755 --- a/lib/autoload/sfCoreAutoload.class.php +++ b/lib/autoload/sfCoreAutoload.class.php @@ -11,7 +11,7 @@ /** * The current symfony version. */ -define('SYMFONY_VERSION', '1.5.7'); +define('SYMFONY_VERSION', '1.5.8-dev'); /** * sfCoreAutoload class. From 5ea8d656b6904d4fbb124cc814a72ddc58eb9d39 Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Thu, 4 Feb 2016 15:09:29 +0100 Subject: [PATCH 12/29] exception_handler signature changed in php7 --- lib/vendor/lime/lime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vendor/lime/lime.php b/lib/vendor/lime/lime.php index d57aa6b14..7734736ea 100644 --- a/lib/vendor/lime/lime.php +++ b/lib/vendor/lime/lime.php @@ -575,7 +575,7 @@ public function handle_error($code, $message, $file, $line, $context) $this->error($type.': '.$message, $file, $line, $trace); } - public function handle_exception(Exception $exception) + public function handle_exception(Throwable $exception) { $this->error(get_class($exception).': '.$exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTrace()); From 3b90d6303ea759f7711ea7361b7d2509c214da28 Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Fri, 5 Feb 2016 16:14:49 +0100 Subject: [PATCH 13/29] Improve test results --- lib/yaml/sfYamlInline.class.php | 4 +++- test/unit/storage/sfPDOSessionStorageTest.php | 2 +- test/unit/yaml/fixtures/YtsSpecificationExamples.yml | 4 ++-- test/unit/yaml/fixtures/YtsTypeTransfers.yml | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/yaml/sfYamlInline.class.php b/lib/yaml/sfYamlInline.class.php index 1c391bdd6..39ea36b81 100644 --- a/lib/yaml/sfYamlInline.class.php +++ b/lib/yaml/sfYamlInline.class.php @@ -405,8 +405,10 @@ static protected function evaluateScalar($scalar) return true; case in_array(strtolower($scalar), $falseValues): return false; + case 0 === strpos($scalar, '0x'): + return hexdec($scalar); case is_numeric($scalar): - return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar; + return floatval($scalar); case 0 == strcasecmp($scalar, '.inf'): case 0 == strcasecmp($scalar, '.NaN'): return -log(0); diff --git a/test/unit/storage/sfPDOSessionStorageTest.php b/test/unit/storage/sfPDOSessionStorageTest.php index 63805e349..52a47ee73 100644 --- a/test/unit/storage/sfPDOSessionStorageTest.php +++ b/test/unit/storage/sfPDOSessionStorageTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/test/unit/yaml/fixtures/YtsSpecificationExamples.yml b/test/unit/yaml/fixtures/YtsSpecificationExamples.yml index c975fe589..082d49c38 100644 --- a/test/unit/yaml/fixtures/YtsSpecificationExamples.yml +++ b/test/unit/yaml/fixtures/YtsSpecificationExamples.yml @@ -501,7 +501,7 @@ yaml: | php: | array( 'canonical' => 12345, - 'decimal' => 12345, + 'decimal' => 12345.0, 'octal' => 014, 'hexadecimal' => 0xC ) @@ -1522,7 +1522,7 @@ yaml: | php: | array( 'canonical' => 12345, - 'decimal' => 12345, + 'decimal' => 12345.0, 'octal' => 12, 'hexadecimal' => 12 ) diff --git a/test/unit/yaml/fixtures/YtsTypeTransfers.yml b/test/unit/yaml/fixtures/YtsTypeTransfers.yml index 398fa0eb8..1db3aa3f2 100644 --- a/test/unit/yaml/fixtures/YtsTypeTransfers.yml +++ b/test/unit/yaml/fixtures/YtsTypeTransfers.yml @@ -182,8 +182,8 @@ php: | array( 'zero' => 0, 'simple' => 12, - 'one-thousand' => 1000, - 'negative one-thousand' => -1000 + 'one-thousand' => 1000.0, + 'negative one-thousand' => -1000.0 ) --- test: Integers as Map Keys From f125ea3ab73ddfe10a58c0cf45c5eb4e1c2c0c4e Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Tue, 9 Feb 2016 09:43:54 +0100 Subject: [PATCH 14/29] Revert "Improve test results" Partial revert This reverts commit 0e70927aec8bf4b95f7f9f465bd3a4beaab5e06f. --- test/unit/storage/sfPDOSessionStorageTest.php | 2 +- test/unit/yaml/fixtures/YtsSpecificationExamples.yml | 4 ++-- test/unit/yaml/fixtures/YtsTypeTransfers.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unit/storage/sfPDOSessionStorageTest.php b/test/unit/storage/sfPDOSessionStorageTest.php index 52a47ee73..63805e349 100644 --- a/test/unit/storage/sfPDOSessionStorageTest.php +++ b/test/unit/storage/sfPDOSessionStorageTest.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/test/unit/yaml/fixtures/YtsSpecificationExamples.yml b/test/unit/yaml/fixtures/YtsSpecificationExamples.yml index 082d49c38..c975fe589 100644 --- a/test/unit/yaml/fixtures/YtsSpecificationExamples.yml +++ b/test/unit/yaml/fixtures/YtsSpecificationExamples.yml @@ -501,7 +501,7 @@ yaml: | php: | array( 'canonical' => 12345, - 'decimal' => 12345.0, + 'decimal' => 12345, 'octal' => 014, 'hexadecimal' => 0xC ) @@ -1522,7 +1522,7 @@ yaml: | php: | array( 'canonical' => 12345, - 'decimal' => 12345.0, + 'decimal' => 12345, 'octal' => 12, 'hexadecimal' => 12 ) diff --git a/test/unit/yaml/fixtures/YtsTypeTransfers.yml b/test/unit/yaml/fixtures/YtsTypeTransfers.yml index 1db3aa3f2..398fa0eb8 100644 --- a/test/unit/yaml/fixtures/YtsTypeTransfers.yml +++ b/test/unit/yaml/fixtures/YtsTypeTransfers.yml @@ -182,8 +182,8 @@ php: | array( 'zero' => 0, 'simple' => 12, - 'one-thousand' => 1000.0, - 'negative one-thousand' => -1000.0 + 'one-thousand' => 1000, + 'negative one-thousand' => -1000 ) --- test: Integers as Map Keys From 3a3da5077707530763ff634095a593d2716884a4 Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Fri, 5 Feb 2016 16:29:07 +0100 Subject: [PATCH 15/29] Fix test --- lib/helper/AssetHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/helper/AssetHelper.php b/lib/helper/AssetHelper.php index 157cc8613..2812cf6c6 100644 --- a/lib/helper/AssetHelper.php +++ b/lib/helper/AssetHelper.php @@ -365,7 +365,9 @@ function image_tag($source, $options = array()) if (isset($options['size'])) { - list($options['width'], $options['height']) = explode('x', $options['size'], 2); + list($width, $height) = explode('x', $options['size'], 2); + $options['height'] = $height; + $options['width'] = $width; unset($options['size']); } From 892186d86b16819bf9387dedb6aebddd23a904e0 Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Tue, 9 Feb 2016 10:16:14 +0100 Subject: [PATCH 16/29] Fix yaml tests for php7 --- lib/yaml/sfYamlInline.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/yaml/sfYamlInline.class.php b/lib/yaml/sfYamlInline.class.php index 39ea36b81..c4a961833 100644 --- a/lib/yaml/sfYamlInline.class.php +++ b/lib/yaml/sfYamlInline.class.php @@ -415,7 +415,11 @@ static protected function evaluateScalar($scalar) case 0 == strcasecmp($scalar, '-.inf'): return log(0); case preg_match('/^(-|\+)?[0-9,]+(\.\d+)?$/', $scalar): - return (float) str_replace(',', '', $scalar); + $replaced = str_replace(',', '', $scalar); + $replaced = str_replace('+', '', $replaced); + $floatval = floatval($replaced); + $intval = intval($replaced); + return $floatval == $intval ? $intval : $floatval; case preg_match(self::getTimestampRegex(), $scalar): return strtotime($scalar); default: From f43220203815c4cd97b8765dd0bb8f8dd27da31b Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Tue, 9 Feb 2016 10:30:10 +0100 Subject: [PATCH 17/29] Fix sfWebControllerTest in php7 --- lib/controller/sfWebController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/controller/sfWebController.class.php b/lib/controller/sfWebController.class.php index 8a175d5b9..2e7cb480f 100644 --- a/lib/controller/sfWebController.class.php +++ b/lib/controller/sfWebController.class.php @@ -120,7 +120,7 @@ public function convertUrlStringToParameters($url) } // routeName? - if ($url[0] == '@') + if ($url && $url[0] == '@') { $route = substr($url, 1); } From 1f0d1ce0b5a3dfa895725bdd1fe57c9644bb9b0f Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Tue, 9 Feb 2016 10:58:44 +0100 Subject: [PATCH 18/29] Fix php7 tests for viewConfigHandler --- lib/config/sfViewConfigHandler.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/config/sfViewConfigHandler.class.php b/lib/config/sfViewConfigHandler.class.php index 562be5c13..962398f48 100644 --- a/lib/config/sfViewConfigHandler.class.php +++ b/lib/config/sfViewConfigHandler.class.php @@ -263,6 +263,7 @@ private function addAssets($type, $assets){ $position = ''; if (is_array($asset)) { + reset($asset); $key = key($asset); $options = $asset[$key]; if (isset($options['position'])) From d444e9b3d5b6d7496405d009b2b2dfa1854b7088 Mon Sep 17 00:00:00 2001 From: Tijmen Klein Date: Tue, 9 Feb 2016 11:42:48 +0100 Subject: [PATCH 19/29] Fix php7 tests Removed a test that tested php implementation --- test/unit/storage/sfPDOSessionStorageTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/unit/storage/sfPDOSessionStorageTest.php b/test/unit/storage/sfPDOSessionStorageTest.php index 63805e349..4e055d4df 100644 --- a/test/unit/storage/sfPDOSessionStorageTest.php +++ b/test/unit/storage/sfPDOSessionStorageTest.php @@ -11,7 +11,7 @@ require_once(__DIR__.'/../../bootstrap/unit.php'); ob_start(); -$plan = 15; +$plan = 14; $t = new lime_test($plan); if (!extension_loaded('SQLite') && !extension_loaded('pdo_SQLite')) @@ -45,7 +45,6 @@ $result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', $session_id)); $data = $result->fetchAll(); $t->is(count($data), 1, 'regenerate() has kept destroyed old session'); -$t->is($data[0]['sess_data'], $oldSessionData, 'regenerate() has kept destroyed old session data'); // checking if the new session record has been created $result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', session_id())); From b17574f67445f41a7edfb877c1d97a151ede3cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Feh=C3=A9r=20Zolt=C3=A1n?= Date: Tue, 10 May 2016 15:10:02 +0200 Subject: [PATCH 20/29] Not adding APC on php7, not allowing php7 failures --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae0919ffa..e6145e7be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ php: matrix: fast_finish: true allow_failures: - - php: 7.0 - php: hhvm # faster builds on new travis setup not using sudo @@ -28,7 +27,7 @@ install: - composer self-update before_script: - - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ] && [ $(php -r "echo PHP_MAJOR_VERSION;") -le 5 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - composer install script: From 717ae86c1cad3d9ccf5f5479d497391a1df6482a Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Tue, 10 May 2016 17:39:48 +0200 Subject: [PATCH 21/29] added php nightly --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e6145e7be..1857ea28b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,14 @@ php: - 5.6 - 7.0 - hhvm + - nightly # run build against nightly but allow them to fail matrix: fast_finish: true allow_failures: - php: hhvm + - php: nightly # faster builds on new travis setup not using sudo sudo: false From 956fa7537dd3d26539eee0d729530a04f9f14ff4 Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Tue, 10 May 2016 18:04:01 +0200 Subject: [PATCH 22/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2163e8c5..0fcc657b3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ All the enhancements and BC breaks are listed in the [WHATS_NEW](https://github. - [DIC](https://github.com/LExpress/symfony1/wiki/ServiceContainer) - Composer support -- PHP 5.6 support +- PHP 7.0 support - performance boost - new widgets & validators - some tickets fixed from the symfony trac From d6b9a33fb5f83b71766b7c442a594dd81b5dc3a8 Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Fri, 13 May 2016 18:06:56 +0200 Subject: [PATCH 23/29] running tests with memcache --- .travis.yml | 4 ++++ data/bin/check_configuration.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1857ea28b..b2d4d98f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,9 @@ matrix: # faster builds on new travis setup not using sudo sudo: false +services: + - memcached + # cache vendor dirs cache: directories: @@ -30,6 +33,7 @@ install: before_script: - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ] && [ $(php -r "echo PHP_MAJOR_VERSION;") -le 5 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - composer install script: diff --git a/data/bin/check_configuration.php b/data/bin/check_configuration.php index a1997d0cf..0315489ba 100644 --- a/data/bin/check_configuration.php +++ b/data/bin/check_configuration.php @@ -97,6 +97,8 @@ function_exists('xcache_set') check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false); check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false); +check(class_exists('Memcache'), 'Memcache is available', 'You must have memcache installed and enabled to use sfMemcacheCache class.', false); + if (!is_cli()) { echo ''; From daa8bd9a16a276721667bb3634e8e9ac558b4da8 Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Fri, 13 May 2016 18:53:52 +0200 Subject: [PATCH 24/29] travis does not use --remote on git submodule update pull swiftmailer 5.x branch as submodule travis default submodule command disabled trying the force to update submodules --- .gitmodules | 1 + .travis.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitmodules b/.gitmodules index 6a26f6148..f9e1e7496 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "lib/vendor/swiftmailer"] path = lib/vendor/swiftmailer url = https://github.com/swiftmailer/swiftmailer.git + branch = 5.x [submodule "lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine"] path = lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine url = https://github.com/LExpress/doctrine1.git diff --git a/.travis.yml b/.travis.yml index 1857ea28b..1fbcbbdd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,8 @@ install: - composer self-update before_script: + # by default, --remote is not used on travis + - git submodule update --remote --force - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ] && [ $(php -r "echo PHP_MAJOR_VERSION;") -le 5 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - composer install From 7ec73179a08ea2236823bee2e9b5f0a4df567b60 Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Fri, 13 May 2016 21:27:58 +0200 Subject: [PATCH 25/29] add memcache.so only for php 5.x --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b2d4d98f0..69ea242ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ install: before_script: - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ] && [ $(php -r "echo PHP_MAJOR_VERSION;") -le 5 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - - echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - sh -c 'if [ $(php -r "echo PHP_RELEASE_VERSION;") -le 98 ] && [ $(php -r "echo PHP_MAJOR_VERSION;") -le 5 ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - composer install script: From 37c1109e87196edf4add35eff944fb957fa59f04 Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Fri, 13 May 2016 22:07:58 +0200 Subject: [PATCH 26/29] sfMemcacheCache: have to check metadata, if memcache returns false --- lib/cache/sfMemcacheCache.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/cache/sfMemcacheCache.class.php b/lib/cache/sfMemcacheCache.class.php index 3bf28b694..385dfeeb1 100644 --- a/lib/cache/sfMemcacheCache.class.php +++ b/lib/cache/sfMemcacheCache.class.php @@ -92,7 +92,7 @@ public function get($key, $default = null) { $value = $this->memcache->get($this->getOption('prefix').$key); - return false === $value ? $default : $value; + return (false === $value && false === $this->getMetadata($key)) ? $default : $value; } /** @@ -100,7 +100,13 @@ public function get($key, $default = null) */ public function has($key) { - return !(false === $this->memcache->get($this->getOption('prefix').$key)); + if (false === $this->memcache->get($this->getOption('prefix') . $key)) + { + // if there is metadata, $key exists with a false value + return !(false === $this->getMetadata($key)); + } + + return true; } /** From fcb36453c06e50505eba6d86b4b3234bea72db0b Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Fri, 13 May 2016 22:37:39 +0200 Subject: [PATCH 27/29] memcache set() expire parameters should be consistent --- lib/cache/sfMemcacheCache.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cache/sfMemcacheCache.class.php b/lib/cache/sfMemcacheCache.class.php index 385dfeeb1..2b4ae9f7c 100644 --- a/lib/cache/sfMemcacheCache.class.php +++ b/lib/cache/sfMemcacheCache.class.php @@ -238,7 +238,7 @@ protected function getMetadata($key) */ protected function setMetadata($key, $lifetime) { - $this->memcache->set($this->getOption('prefix').'_metadata'.self::SEPARATOR.$key, array('lastModified' => time(), 'timeout' => time() + $lifetime), false, $lifetime); + $this->memcache->set($this->getOption('prefix').'_metadata'.self::SEPARATOR.$key, array('lastModified' => time(), 'timeout' => time() + $lifetime), false, time() + $lifetime); } /** From 8dfaeb24610e58477604d7d7b4991906455faeaf Mon Sep 17 00:00:00 2001 From: Zoltan Feher Date: Fri, 20 May 2016 23:34:18 +0200 Subject: [PATCH 28/29] submodule refs updated --- lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine | 2 +- lib/vendor/swiftmailer | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine b/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine index 3d95c7f50..3835027a7 160000 --- a/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine +++ b/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine @@ -1 +1 @@ -Subproject commit 3d95c7f506e8b29d8e1fd48573dd0d046b9e6ae6 +Subproject commit 3835027a776677c2e057bafc27521640cb8114b9 diff --git a/lib/vendor/swiftmailer b/lib/vendor/swiftmailer index 0697e6aa6..1460e98b5 160000 --- a/lib/vendor/swiftmailer +++ b/lib/vendor/swiftmailer @@ -1 +1 @@ -Subproject commit 0697e6aa65c83edf97bb0f23d8763f94e3f11421 +Subproject commit 1460e98b53d2f916f1b4123069c96c90844a1a4d From 48c7e3212ccddcdf7b7a8971f6e80b67063239cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Feh=C3=A9r=20Zolt=C3=A1n?= Date: Mon, 23 May 2016 18:33:34 +0200 Subject: [PATCH 29/29] sfAutoload include fix --- lib/autoload/sfAutoload.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/autoload/sfAutoload.class.php b/lib/autoload/sfAutoload.class.php index af86fdfb5..507287311 100644 --- a/lib/autoload/sfAutoload.class.php +++ b/lib/autoload/sfAutoload.class.php @@ -138,7 +138,15 @@ public function reloadClasses($force = false) $file = $configuration->getConfigCache()->checkConfig('config/autoload.yml'); - $this->classes = include($file); + if (defined('HHVM_VERSION')) + { + // workaround for https://github.com/facebook/hhvm/issues/1447 + $this->classes = eval(str_replace('classes = include $file; + } foreach ($this->overriden as $class => $path) {