7 changes: 7 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ return PhpCsFixer\Config::create()
'@Symfony:risky' => true,
'@PHPUnit60Migration:risky' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'comment_to_phpdoc' => true,
'compact_nullable_typehint' => true,
'general_phpdoc_annotation_remove' => [
'expectedException',
Expand All @@ -47,6 +49,11 @@ return PhpCsFixer\Config::create()
],
'strict_comparison' => true,
'strict_param' => true,
// Remove when https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3222 has been merged
'LeoFeyer/optimize_native_functions' => true,
])
->registerCustomFixers([
new LeoFeyer\PhpCsFixer\OptimizeNativeFunctionsFixer()
])
->setFinder($finder)
->setRiskyAllowed(true)
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## 4.4.17 (2018-04-04)

* Correctly hide empty custom layout sections (see #1115).

## 4.4.16 (2018-03-08)

* Correctly link to the picker from the TinyMCE link menu (see #1415).
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
"doctrine/doctrine-migrations-bundle": "<1.1",
"doctrine/orm": "<2.4",
"lexik/maintenance-bundle": "2.1.4",
"symfony/finder": "3.4.7|4.0.7",
"symfony/security": "3.4.7|4.0.7",
"symfony/swiftmailer-bundle": "2.6.* <2.6.2"
},
"require-dev": {
Expand All @@ -83,7 +85,8 @@
"contao/manager-plugin": "^2.0",
"doctrine/doctrine-migrations-bundle": "^1.1",
"doctrine/orm": "^2.5",
"friendsofphp/php-cs-fixer": "^2.0",
"friendsofphp/php-cs-fixer": "^2.11",
"leofeyer/optimize-native-functions-fixer": "^1.1",
"lexik/maintenance-bundle": "^2.1.3",
"monolog/monolog": "^1.22",
"php-http/guzzle6-adapter": "^1.1",
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/contao/.php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ return PhpCsFixer\Config::create()
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'yoda_style' => false,
// Remove when https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3222 has been merged
'LeoFeyer/optimize_native_functions' => true,
])
->registerCustomFixers([
new LeoFeyer\PhpCsFixer\OptimizeNativeFunctionsFixer()
])
->setFinder($finder)
->setRiskyAllowed(true)
Expand Down
8 changes: 7 additions & 1 deletion src/Resources/contao/classes/FrontendTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,19 @@ public function sections($key=null, $template=null)

foreach ($this->positions[$key] as $id=>$section)
{
if (isset($this->sections[$id]))
if (!empty($this->sections[$id]))
{
$section['content'] = $this->sections[$id];
$matches[$id] = $section;
}
}

// Return if the section is empty (see #1115)
if (empty($matches))
{
return;
}

$this->matches = $matches;

if ($template === null)
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/config/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Core version
\define('VERSION', '4.4');
\define('BUILD', '16');
\define('BUILD', '17');
\define('LONG_TERM_SUPPORT', true);

// Link constants
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/contao/drivers/DC_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5549,27 +5549,27 @@ protected function filterMenu($intFilterPanel)
$arrValues[] = $this->ptable;
}

$what = $field;
$what = \Database::quoteIdentifier($field);

// Optimize the SQL query (see #8485)
if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag']))
{
// Sort by day
if (\in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(5, 6)))
{
$what = "UNIX_TIMESTAMP(FROM_UNIXTIME($field , '%%Y-%%m-%%d')) AS $field";
$what = "UNIX_TIMESTAMP(FROM_UNIXTIME($what , '%%Y-%%m-%%d')) AS $what";
}

// Sort by month
elseif (\in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(7, 8)))
{
$what = "UNIX_TIMESTAMP(FROM_UNIXTIME($field , '%%Y-%%m-01')) AS $field";
$what = "UNIX_TIMESTAMP(FROM_UNIXTIME($what , '%%Y-%%m-01')) AS $what";
}

// Sort by year
elseif (\in_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['flag'], array(9, 10)))
{
$what = "UNIX_TIMESTAMP(FROM_UNIXTIME($field , '%%Y-01-01')) AS $field";
$what = "UNIX_TIMESTAMP(FROM_UNIXTIME($what , '%%Y-01-01')) AS $what";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/library/Contao/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ public static function addImageToTemplate($objTemplate, $arrItem, $intMaxWidth=n
$picture['alt'] = \StringUtil::specialchars($arrItem['alt']);

// Move the title to the link tag so it is shown in the lightbox
if ($arrItem['fullsize'] && $arrItem['imageTitle'] && !$arrItem['linkTitle'])
if (($arrItem['fullsize'] || $arrItem['imageUrl']) && $arrItem['imageTitle'] && !$arrItem['linkTitle'])
{
$arrItem['linkTitle'] = $arrItem['imageTitle'];
unset($arrItem['imageTitle']);
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/contao/library/Contao/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function generateRss()
foreach ($this->arrItems as $objItem)
{
$xml .= '<item>';
$xml .= '<title>' . \StringUtil::specialchars(strip_tags($objItem->title)) . '</title>';
$xml .= '<title>' . \StringUtil::specialchars(strip_tags(\StringUtil::stripInsertTags($objItem->title))) . '</title>';
$xml .= '<description><![CDATA[' . preg_replace('/[\n\r]+/', ' ', $objItem->description) . ']]></description>';
$xml .= '<link>' . \StringUtil::specialchars($objItem->link) . '</link>';
$xml .= '<pubDate>' . date('r', $objItem->published) . '</pubDate>';
Expand Down Expand Up @@ -211,7 +211,7 @@ public function generateAtom()
foreach ($this->arrItems as $objItem)
{
$xml .= '<entry>';
$xml .= '<title>' . \StringUtil::specialchars($objItem->title) . '</title>';
$xml .= '<title>' . \StringUtil::specialchars(strip_tags(\StringUtil::stripInsertTags($objItem->title))) . '</title>';
$xml .= '<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">' . preg_replace('/[\n\r]+/', ' ', \StringUtil::toXhtml($objItem->description)) . '</div></content>';
$xml .= '<link rel="alternate" href="' . \StringUtil::specialchars($objItem->link) . '" />';
$xml .= '<updated>' . preg_replace('/00$/', ':00', date('Y-m-d\TH:i:sO', $objItem->published)) . '</updated>';
Expand Down
10 changes: 7 additions & 3 deletions src/Resources/contao/library/Contao/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,7 @@ public function setInputCallback(callable $callback=null)
*/
public function validate()
{
$varValue = (\is_callable($this->inputCallback) ? \call_user_func($this->inputCallback) : $this->getPost($this->strName));
$varValue = $this->validator($varValue);
$varValue = $this->validator($this->getPost($this->strName));

if ($this->hasErrors())
{
Expand All @@ -797,6 +796,11 @@ public function validate()
*/
protected function getPost($strKey)
{
if (\is_callable($this->inputCallback))
{
return \call_user_func($this->inputCallback);
}

if ($this->useRawRequestData === true)
{
/** @var Request $request */
Expand Down Expand Up @@ -1309,7 +1313,7 @@ protected function isValidOption($varInput)
*/
public static function getAttributesFromDca($arrData, $strName, $varValue=null, $strField='', $strTable='', $objDca=null)
{
$arrAttributes = isset($arrData['eval']) ? $arrData['eval'] : array();
$arrAttributes = $arrData['eval'];

$arrAttributes['id'] = $strName;
$arrAttributes['name'] = $strName;
Expand Down
16 changes: 12 additions & 4 deletions src/Resources/views/Error/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>{% block title %}{{ statusCode }} Error{% endblock %}</title>
<meta name="generator" content="Contao Open Source CMS">
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300">
<link rel="stylesheet" href="{{ asset('system/themes/flexible/fonts.css') }}">
{% block style %}
<style>
html {
Expand All @@ -16,9 +16,14 @@
body {
margin: 0;
padding: 0;
font: 16px "Open Sans", Helvetica, sans-serif;
font: 1rem/1.25 Lato,sans-serif;
font-weight: 300;
color: #333;
color: #222;
}
@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi) {
body {
font-family: "Lato Retina", Lato, sans-serif;
}
}
a, a:visited {
text-decoration: none;
Expand All @@ -38,6 +43,9 @@
h2, h3 {
font-size: 1.5em;
}
pre, code {
font: 300 .75rem/1.25 "Roboto Mono", monospace;
}
#header {
padding: 12px 0 10px;
}
Expand All @@ -49,7 +57,7 @@
font-size: 0.75em;
text-align: center;
padding: .5em 0;
color: #999;
color: #808080;
}
.wrap {
width: 60%;
Expand Down
2 changes: 1 addition & 1 deletion tests/Contao/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function getComputeResizeDataWithoutImportantPart()
],
'Mode box portrait 1' => [
[100, 100, 50, 100, 'box'],
[
[
'width' => 50,
'height' => 100,
'target_x' => 0,
Expand Down
7 changes: 1 addition & 6 deletions tests/Contao/WidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function testValidatesThePostData()
$widget = $this
->getMockBuilder(Widget::class)
->disableOriginalConstructor()
->setMethods(['validator', 'getPost'])
->setMethods(['validator'])
->getMockForAbstractClass()
;

Expand All @@ -125,11 +125,6 @@ public function testValidatesThePostData()
->willReturnArgument(0)
;

$widget
->expects($this->once())
->method('getPost')
;

$widget
->setInputCallback(
function () {
Expand Down
3 changes: 1 addition & 2 deletions tests/Session/Attribute/ArrayAttributeBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ public function testCanModifyTheOffset()
$bag['bar']['baz'] = 'foo';

++$bag['foo'];
$bag['foo'] += 1;
$bag['bar']['baz'] .= 'bar';

$this->assertSame(3, $bag['foo']);
$this->assertSame(2, $bag['foo']);
$this->assertSame(['baz' => 'foobar'], $bag['bar']);
}

Expand Down