Commit d8ae74ee by Antonio Ramirez

Merge remote-tracking branch 'upstream/master' into upstream

* upstream/master: gridview and listview use widget ID in base tag typo fix [skip ci] Update CHANGELOG.md made elasticsearch error messages more readable Spanish structure-views [skip ci] Fix filename Update README.md https://github.com/yiisoft/yii2/pull/4091#discussion_r14296860 Fix possibility of non-removed symlinked directory. Fixed typo. [skip ci] changed default for rotateByCopy of FileTarget
parents 392f2910 085f2c01
......@@ -20,10 +20,10 @@ which is the latest stable release of Yii.
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2/v/stable.png)](https://packagist.org/packages/yiisoft/yii2)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2/downloads.png)](https://packagist.org/packages/yiisoft/yii2)
[![Dependency Status](https://www.versioneye.com/php/yiisoft:yii2/dev-master/badge.png)](https://www.versioneye.com/php/yiisoft:yii2/dev-master)
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2)
[![HHVM Status](http://hhvm.h4cc.de/badge/yiisoft/yii2-dev.png)](http://hhvm.h4cc.de/package/yiisoft/yii2-dev)
[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/yii2/badges/coverage.png?s=31d80f1036099e9d6a3e4d7738f6b000b3c3d10e)](https://scrutinizer-ci.com/g/yiisoft/yii2/)
[![Dependency Status](https://www.versioneye.com/php/yiisoft:yii2/dev-master/badge.png)](https://www.versioneye.com/php/yiisoft:yii2/dev-master)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/yiisoft/yii2/badges/quality-score.png?s=b1074a1ff6d0b214d54fa5ab7abbb90fc092471d)](https://scrutinizer-ci.com/g/yiisoft/yii2/)
[![Code Climate](https://codeclimate.com/github/yiisoft/yii2.png)](https://codeclimate.com/github/yiisoft/yii2)
......
......@@ -24,7 +24,7 @@ Einstieg
* [Arbeiten mit Formularen](start-forms.md)
* [Arbeiten mit Datenbanken](start-databases.md)
* [Code generieren mit Gii](start-gii.md)
* [Ausblick](start-looking-head.md)
* [Ausblick](start-looking-ahead.md)
Application Struktur
......
......@@ -24,7 +24,7 @@ Primeros pasos
* [Trabajar con formularios](start-forms.md)
* [Trabajar con bases de datos](start-databases.md)
* [Generar códigos con Gii](start-gii.md)
* [Adentrarse en Yii](start-looking-head.md)
* [Adentrarse en Yii](start-looking-ahead.md)
Estructura de una aplicación
......
......@@ -24,7 +24,7 @@ Mise en Route
* [Travailler avec les formulaires](start-forms.md)
* [Travailler avec les bases de données](start-databases.md)
* [Générer du code avec Gii](start-gii.md)
* [En savoir plus](start-looking-head.md)
* [En savoir plus](start-looking-ahead.md)
Structure Application
......
......@@ -24,7 +24,7 @@ Primeiros Passos
* [Trabalhando com Formulários](start-forms.md)
* [Trabalhando com Banco de Dados](start-databases.md)
* [Gerando Código com Gii](start-gii.md)
* [Visão Geral](start-looking-head.md)
* [Visão Geral](start-looking-ahead.md)
Estrutura de uma Aplicação
......
......@@ -24,7 +24,7 @@ All Rights Reserved.
* [Работа с формами](start-forms.md)
* [Работа с базами данных](start-databases.md)
* [Генерация кода при помощи Gii](start-gii.md)
* [Что дальше?](start-looking-head.md)
* [Что дальше?](start-looking-ahead.md)
Структура приложения
......
......@@ -24,7 +24,7 @@ All Rights Reserved.
* [Робота з формами](start-forms.md)
* [Робота з базами даних](start-databases.md)
* [Генерація коду за допомогою Gii](start-gii.md)
* [Що далі?](start-looking-head.md)
* [Що далі?](start-looking-ahead.md)
Структура додатка
......
......@@ -23,7 +23,7 @@ Yii 2.0 权威指南
* **已定稿** [使用 Forms](start-forms.md)
* **已定稿** [玩转 Databases](start-databases.md)
* **已定稿** [用 Gii 生成代码](start-gii.md)
* **已定稿** [更上一层楼](start-looking-head.md)
* **已定稿** [更上一层楼](start-looking-ahead.md)
应用结构
--------
......
......@@ -24,7 +24,7 @@ Getting Started
* [Working with Forms](start-forms.md)
* [Working with Databases](start-databases.md)
* [Generating Code with Gii](start-gii.md)
* [Looking Ahead](start-looking-head.md)
* [Looking Ahead](start-looking-ahead.md)
Application Structure
......
......@@ -12,7 +12,7 @@ start-hello.md | Yes
start-forms.md | Yes
start-databases.md | Yes
start-gii.md | Yes
start-looking-head.md | Yes
start-looking-ahead.md | Yes
structure-overview.md | Yes
structure-entry-scripts.md | Yes
structure-applications.md | Yes
......@@ -102,8 +102,8 @@ tutorial-performance-tuning.md |
tutorial-shared-hosting.md |
tutorial-template-engines.md |
tutorial-core-validators.md | Yes
bootstrap-widgets.md |
jui-widgets.md |
widget-bootstrap.md |
widget-jui.md |
helper-overview.md |
helper-array.md |
helper-html.md |
......
......@@ -7,6 +7,7 @@ Yii Framework 2 elasticsearch extension Change Log
- Bug #3587: Fixed an issue with storing empty records (cebe)
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
- Enh #3527: Added `highlight` property to Query and ActiveRecord. (Borales)
- Enh: Make error messages more readable in HTML output (cebe)
- Chg: asArray in ActiveQuery is now equal to using the normal Query. This means, that the output structure has changed and `with` is supported anymore. (cebe)
- Chg: Deletion of a record is now also considered successful if the record did not exist. (cebe)
- Chg: Requirement changes: Yii now requires elasticsearch version 1.0 or higher (cebe)
......
......@@ -10,6 +10,7 @@ namespace yii\elasticsearch;
use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
use yii\helpers\Json;
/**
......@@ -381,7 +382,7 @@ class Connection extends Component
'requestUrl' => $url,
'requestBody' => $requestBody,
'responseHeaders' => $headers,
'responseBody' => $body,
'responseBody' => $this->decodeErrorBody($body),
]);
}
......@@ -403,7 +404,7 @@ class Connection extends Component
'requestBody' => $requestBody,
'responseCode' => $responseCode,
'responseHeaders' => $headers,
'responseBody' => $body,
'responseBody' => $this->decodeErrorBody($body),
]);
}
if (isset($headers['content-type']) && !strncmp($headers['content-type'], 'application/json', 16)) {
......@@ -415,7 +416,7 @@ class Connection extends Component
'requestBody' => $requestBody,
'responseCode' => $responseCode,
'responseHeaders' => $headers,
'responseBody' => $body,
'responseBody' => $this->decodeErrorBody($body),
]);
}
} elseif ($responseCode == 404) {
......@@ -427,11 +428,29 @@ class Connection extends Component
'requestBody' => $requestBody,
'responseCode' => $responseCode,
'responseHeaders' => $headers,
'responseBody' => $body,
'responseBody' => $this->decodeErrorBody($body),
]);
}
}
/**
* Try to decode error information if it is valid json, return it if not.
* @param $body
* @return mixed
*/
protected function decodeErrorBody($body)
{
try {
$decoded = Json::decode($body);
if (isset($decoded['error'])) {
$decoded['error'] = preg_replace('/\b\w+?Exception\[/', "<span style=\"color: red;\">\\0</span>\n ", $decoded['error']);
}
return $decoded;
} catch(InvalidParamException $e) {
return $body;
}
}
public function getNodeInfo()
{
return $this->get([]);
......
......@@ -134,6 +134,7 @@ Yii Framework 2 Change Log
- Enh: Added param `hideOnSinglePage` to `yii\widgets\LinkPager` (arturf)
- Enh: Added support for array attributes in `in` validator (creocoder)
- Enh: Improved `yii\helpers\Inflector::slug` to support more cases for Russian, Hebrew and special characters (samdark)
- Enh: ListView now uses the widget ID in the base tag, consistent to gridview (cebe)
- Chg #2287: Split `yii\db\ColumnSchema::typecast()` into two methods `phpTypecast()` and `dbTypecast()` to allow specifying PDO type explicitly (cebe)
- Chg #2898: `yii\console\controllers\AssetController` is now using hashes instead of timestamps (samdark)
- Chg #2913: RBAC `DbManager` is now initialized via migration (samdark)
......@@ -150,6 +151,7 @@ Yii Framework 2 Change Log
- Chg #3897: Raised visibility of `yii\web\View::registerAssetFiles()` to protected (samdark)
- Chg #3899: Moved `MailEvent` class to `yii\mail` namespace (cebe)
- Chg #3956: Flash messages set via `Yii::$app->session->setFlash()` will be removed only if they are accessed (qiangxue)
- Chg #3989: The default value for `yii\log\FileTarget::$rotateByCopy` now defaults to true to work on windows by default (cebe)
- Chg #4071: `mail` component renamed to `mailer`, `yii\log\EmailTarget::$mail` renamed to `yii\log\EmailTarget::$mailer` (samdark)
- Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue)
- Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue)
......
......@@ -160,7 +160,7 @@ class Module extends ServiceLocator
public static function setInstance($instance)
{
if ($instance === null) {
unset(self::$_instances[get_class()]);
unset(self::$_instances[get_called_class()]);
} else {
self::$_instances[get_class($instance)] = $instance;
}
......
......@@ -219,9 +219,6 @@ class GridView extends BaseListView
if (!$this->formatter instanceof Formatter) {
throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.');
}
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
if (!isset($this->filterRowOptions['id'])) {
$this->filterRowOptions['id'] = $this->options['id'] . '-filters';
}
......
......@@ -277,10 +277,11 @@ class BaseFileHelper
*/
public static function removeDirectory($dir, $options = [])
{
if (!isset($options['traverseSymlinks'])) {
$options['traverseSymlinks'] = false;
if (!is_dir($dir)) {
return;
}
if (!is_dir($dir) || !($handle = opendir($dir))) {
if (!is_link($dir) || isset($options['traverseSymlinks']) && $options['traverseSymlinks']) {
if (!($handle = opendir($dir))) {
return;
}
while (($file = readdir($handle)) !== false) {
......@@ -288,21 +289,17 @@ class BaseFileHelper
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_link($path)) {
if ($options['traverseSymlinks'] && is_dir($path)) {
if (is_dir($path)) {
static::removeDirectory($path, $options);
}
unlink($path);
} else {
if (is_file($path)) {
unlink($path);
} else {
static::removeDirectory($path, $options);
}
}
}
closedir($handle);
if (!is_link($dir)) {
}
if (is_link($dir)) {
unlink($dir);
} else {
rmdir($dir);
}
}
......
......@@ -52,16 +52,18 @@ class FileTarget extends Target
*/
public $dirMode = 0775;
/**
* @var boolean Whether to rotate primary log by copy and truncate
* which is more compatible with log tailers. Defaults to `false`.
* @var boolean Whether to rotate log files by copy and truncate in contrast to rotation by
* renaming files. Defaults to `true` to be more compatible with log tailers and is windows
* systems which do not play well with rename on open files. Rotation by renaming however is
* a bit faster.
*
* This property can also be useful on windows systems where the
* [rename()](http://www.php.net/manual/en/function.rename.php) function has some problems.
* See the [comment by Martin Pelletier](http://www.php.net/manual/en/function.rename.php#102274) in
* the PHP documentation for details. By setting rotateByCopy to `true` you can work
* The problem with windows systems where the [rename()](http://www.php.net/manual/en/function.rename.php)
* function does not work with files that are opened by some process is described in a
* [comment by Martin Pelletier](http://www.php.net/manual/en/function.rename.php#102274) in
* the PHP documentation. By setting rotateByCopy to `true` you can work
* around this problem.
*/
public $rotateByCopy = false;
public $rotateByCopy = true;
/**
......
......@@ -101,6 +101,9 @@ abstract class BaseListView extends Widget
if ($this->emptyText === null) {
$this->emptyText = Yii::t('yii', 'No results found.');
}
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment