Skip to content

Commit

Permalink
Merge branch 'hotfix/4.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Dec 22, 2016
2 parents 87ae8c6 + 330dfdd commit f09929c
Show file tree
Hide file tree
Showing 123 changed files with 12,995 additions and 247 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,13 @@
# Contao core bundle change log

### 4.3.1 (2016-12-22)

* Preserve uppercase characters in custom sections IDs (see #639).
* Always show the section title instead of its ID (see #640).
* Correctly handle DropZone file uploads (see #637).
* Fix the markup of the CSV importers (see #645).
* Correctly symlink the logs directory under Windows (see #634).

### 4.3.0 (2016-11-25)

* Do not cache pages if a back end user is logged in (see #628).
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -25,6 +25,7 @@
"sensio/framework-extra-bundle": "^3.0.2",
"psr/log": "~1.0",
"twig/twig": "~1.20",
"doctrine/dbal": "~2.5",
"doctrine/doctrine-bundle": "~1.6",
"doctrine/doctrine-cache-bundle": "~1.3",
"swiftmailer/swiftmailer": "^5.2.1",
Expand Down
93 changes: 71 additions & 22 deletions src/Cache/ContaoCacheWarmer.php
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;

Expand Down Expand Up @@ -116,8 +117,8 @@ private function generateConfigCache($cacheDir)
{
$dumper = new CombinedFileDumper($this->filesystem, new PhpFileLoader(), $cacheDir.'/contao', true);

$dumper->dump($this->locator->locate('config/autoload.php', null, false), 'config/autoload.php');
$dumper->dump($this->locator->locate('config/config.php', null, false), 'config/config.php');
$dumper->dump($this->findConfigFiles('autoload.php'), 'config/autoload.php');
$dumper->dump($this->findConfigFiles('config.php'), 'config/config.php');
}

/**
Expand All @@ -129,9 +130,7 @@ private function generateDcaCache($cacheDir)
{
$dumper = new CombinedFileDumper($this->filesystem, new PhpFileLoader(), $cacheDir.'/contao', true);
$processed = [];

/** @var SplFileInfo[] $files */
$files = $this->finder->findIn('dca')->files()->name('*.php');
$files = $this->findDcaFiles();

foreach ($files as $file) {
if (in_array($file->getBasename(), $processed)) {
Expand Down Expand Up @@ -164,14 +163,8 @@ private function generateLanguageCache($cacheDir)

foreach ($this->getLanguagesInUse() as $language) {
$processed = [];
$files = $this->findLanguageFiles($language);

try {
$files = $this->finder->findIn('languages/'.$language)->files()->name('/\.(php|xlf)$/');
} catch (\InvalidArgumentException $e) {
continue; // the language does not exist
}

/** @var SplFileInfo[] $files */
foreach ($files as $file) {
$name = substr($file->getBasename(), 0, -4);

Expand Down Expand Up @@ -204,9 +197,7 @@ private function generateLanguageCache($cacheDir)
private function generateDcaExtracts($cacheDir)
{
$processed = [];

/** @var SplFileInfo[] $files */
$files = $this->finder->findIn('dca')->files()->name('*.php');
$files = $this->findDcaFiles();

foreach ($files as $file) {
if (in_array($file->getBasename(), $processed)) {
Expand Down Expand Up @@ -244,15 +235,13 @@ private function generateDcaExtracts($cacheDir)
private function generateTemplateMapper($cacheDir)
{
$mapper = [];

try {
$files = $this->finder->findIn('templates')->name('*.html5');
} catch (\InvalidArgumentException $e) {
$files = [];
}
$files = $this->findTemplateFiles();

foreach ($files as $file) {
$mapper[$file->getBasename('.html5')] = strtr($file->getPath(), '\\', '/');
$mapper[$file->getBasename('.html5')] = rtrim(
$this->filesystem->makePathRelative($file->getPath(), dirname($this->rootDir)),
'/'
);
}

$this->filesystem->dumpFile(
Expand Down Expand Up @@ -312,4 +301,64 @@ private function isCompleteInstallation()

return true;
}

/**
* Returns the config files.
*
* @param string $name
*
* @return string|array
*/
private function findConfigFiles($name)
{
try {
return $this->locator->locate('config/'.$name, null, false);
} catch (\InvalidArgumentException $e) {
return [];
}
}

/**
* Returns the DCA files.
*
* @return Finder|SplFileInfo[]
*/
private function findDcaFiles()
{
try {
return $this->finder->findIn('dca')->files()->name('*.php');
} catch (\InvalidArgumentException $e) {
return [];
}
}

/**
* Returns the language files.
*
* @param string $language
*
* @return Finder|SplFileInfo[]
*/
private function findLanguageFiles($language)
{
try {
return $this->finder->findIn('languages/'.$language)->files()->name('/\.(php|xlf)$/');
} catch (\InvalidArgumentException $e) {
return [];
}
}

/**
* Returns the template files.
*
* @return Finder|SplFileInfo[]
*/
private function findTemplateFiles()
{
try {
return $this->finder->findIn('templates')->name('*.html5');
} catch (\InvalidArgumentException $e) {
return [];
}
}
}
7 changes: 1 addition & 6 deletions src/Command/InstallCommand.php
Expand Up @@ -185,15 +185,10 @@ private function addInitializePhp()
die('Your script is not compatible with Contao 4.');
}
/**
* @var Composer\Autoload\ClassLoader
*/
/** @var Composer\Autoload\ClassLoader */
$loader = require __DIR__ . '/../app/autoload.php';
include_once __DIR__ . '/../app/bootstrap.php.cache';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$response = $kernel->handle(Request::create('/_contao/initialize', 'GET', [], [], [], $_SERVER));
// Send the response if not generated by the InitializeController
Expand Down
19 changes: 14 additions & 5 deletions src/Command/SymlinksCommand.php
Expand Up @@ -108,10 +108,7 @@ private function generateSymlinks()
$this->symlink('system/themes', $this->webDir.'/system/themes');

// Symlinks the logs directory
$this->symlink(
str_replace($this->rootDir.'/', '', $this->getContainer()->getParameter('kernel.logs_dir')),
'system/logs'
);
$this->symlink($this->getRelativePath($this->getContainer()->getParameter('kernel.logs_dir')), 'system/logs');
}

/**
Expand Down Expand Up @@ -151,7 +148,7 @@ private function symlinkThemes()
$themes = $this->getContainer()->get('contao.resource_finder')->findIn('themes')->depth(0)->directories();

foreach ($themes as $theme) {
$path = str_replace(strtr($this->rootDir, '\\', '/').'/', '', strtr($theme->getPathname(), '\\', '/'));
$path = $this->getRelativePath($theme->getPathname());

if (0 === strpos($path, 'system/modules/')) {
continue;
Expand Down Expand Up @@ -284,4 +281,16 @@ private function filterNestedPaths(Finder $finder, $prepend)

return array_values($files);
}

/**
* Returns the path relative to the root directory.
*
* @param string $path
*
* @return string
*/
private function getRelativePath($path)
{
return str_replace(strtr($this->rootDir, '\\', '/').'/', '', strtr($path, '\\', '/'));
}
}
46 changes: 31 additions & 15 deletions src/Config/Loader/XliffFileLoader.php
Expand Up @@ -76,11 +76,40 @@ private function convertXlfToPhp($name, $language)
$xml = $this->getDomDocumentFromFile($name);

$return = "\n// ".str_replace(strtr(dirname($this->rootDir), '\\', '/').'/', '', strtr($name, '\\', '/'))."\n";
$units = $xml->getElementsByTagName('trans-unit');
$fileNodes = $xml->getElementsByTagName('file');
$language = strtolower($language);

/** @var \DOMElement[] $fileNodes */
foreach ($fileNodes as $fileNode) {
$tagName = 'target';

// Use the source tag if the source language matches
if (strtolower($fileNode->getAttribute('source-language')) === $language) {
$tagName = 'source';
}

$return .= $this->getPhpFromFileNode($fileNode, $tagName);
}

return $return;
}

/**
* Converts an XLIFF file node into PHP code.
*
* @param \DOMElement $fileNode
* @param string $tagName
*
* @return string
*/
private function getPhpFromFileNode(\DOMElement $fileNode, $tagName)
{
$return = '';
$units = $fileNode->getElementsByTagName('trans-unit');

/** @var \DOMElement[] $units */
foreach ($units as $unit) {
$node = $this->getNodeByLanguage($unit, $language);
$node = $unit->getElementsByTagName($tagName);

if (null === $node || null === $node->item(0)) {
continue;
Expand Down Expand Up @@ -117,19 +146,6 @@ private function getDomDocumentFromFile($name)
return $xml;
}

/**
* Returns a DOM node list depending on the language.
*
* @param \DOMElement $unit
* @param string $language
*
* @return \DOMNodeList
*/
private function getNodeByLanguage(\DOMElement $unit, $language)
{
return ('en' === $language) ? $unit->getElementsByTagName('source') : $unit->getElementsByTagName('target');
}

/**
* Removes extra spaces in closing tags.
*
Expand Down
17 changes: 13 additions & 4 deletions src/Image/ImageFactory.php
Expand Up @@ -130,7 +130,7 @@ public function create($path, $size = null, $targetPath = null)

if (!is_object($path) || !($path instanceof ImageInterface)) {
if (null === $importantPart) {
$importantPart = $this->createImportantPart($image->getPath());
$importantPart = $this->createImportantPart($image);
}

$image->setImportantPart($importantPart);
Expand Down Expand Up @@ -244,20 +244,29 @@ private function createConfig($size, ImageInterface $image)
/**
* Fetches the important part from the database.
*
* @param string $path
* @param ImageInterface $image
*
* @return ImportantPart|null
*/
private function createImportantPart($path)
private function createImportantPart(ImageInterface $image)
{
/** @var FilesModel $filesModel */
$filesModel = $this->framework->getAdapter(FilesModel::class);
$file = $filesModel->findByPath($path);
$file = $filesModel->findByPath($image->getPath());

if (null === $file || !$file->importantPartWidth || !$file->importantPartHeight) {
return null;
}

$imageSize = $image->getDimensions()->getSize();

if (
$file->importantPartX + $file->importantPartWidth > $imageSize->getWidth()
|| $file->importantPartY + $file->importantPartHeight > $imageSize->getHeight()
) {
return null;
}

return new ImportantPart(
new Point((int) $file->importantPartX, (int) $file->importantPartY),
new Box((int) $file->importantPartWidth, (int) $file->importantPartHeight)
Expand Down
5 changes: 3 additions & 2 deletions src/Resources/contao/classes/Ajax.php
Expand Up @@ -10,6 +10,7 @@

namespace Contao;

use Contao\CoreBundle\Exception\InternalServerErrorHttpException;
use Contao\CoreBundle\Exception\NoContentResponseException;
use Contao\CoreBundle\Exception\ResponseException;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -432,8 +433,8 @@ public function executePostActions(DataContainer $dc)

// DropZone file upload
case 'fileupload':
$dc->move();
throw new NoContentResponseException();
$dc->move(true);
throw new InternalServerErrorHttpException();

// HOOK: pass unknown actions to callback functions
default:
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/contao/classes/StyleSheets.php
Expand Up @@ -1325,8 +1325,10 @@ public function importStyleSheet()
<input type="hidden" name="MAX_FILE_SIZE" value="'.\Config::get('maxFileSize').'">
<div class="tl_tbox">
<h3>'.$GLOBALS['TL_LANG']['tl_style_sheet']['source'][0].'</h3>'.$objUploader->generateMarkup().(isset($GLOBALS['TL_LANG']['tl_style_sheet']['source'][1]) ? '
<p class="tl_help tl_tip">'.$GLOBALS['TL_LANG']['tl_style_sheet']['source'][1].'</p>' : '').'
<div class="widget">
<h3>'.$GLOBALS['TL_LANG']['tl_style_sheet']['source'][0].'</h3>'.$objUploader->generateMarkup().(isset($GLOBALS['TL_LANG']['tl_style_sheet']['source'][1]) ? '
<p class="tl_help tl_tip">'.$GLOBALS['TL_LANG']['tl_style_sheet']['source'][1].'</p>' : '').'
</div>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/Resources/contao/classes/Theme.php
Expand Up @@ -121,8 +121,10 @@ public function importTheme()
<input type="hidden" name="MAX_FILE_SIZE" value="'.\Config::get('maxFileSize').'">
<div class="tl_tbox">
<h3>'.$GLOBALS['TL_LANG']['tl_theme']['source'][0].'</h3>'.$objUploader->generateMarkup().(isset($GLOBALS['TL_LANG']['tl_theme']['source'][1]) ? '
<p class="tl_help tl_tip">'.$GLOBALS['TL_LANG']['tl_theme']['source'][1].'</p>' : '').'
<div class="widget">
<h3>'.$GLOBALS['TL_LANG']['tl_theme']['source'][0].'</h3>'.$objUploader->generateMarkup().(isset($GLOBALS['TL_LANG']['tl_theme']['source'][1]) ? '
<p class="tl_help tl_tip">'.$GLOBALS['TL_LANG']['tl_theme']['source'][1].'</p>' : '').'
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/config/constants.php
Expand Up @@ -10,7 +10,7 @@

// Core version
define('VERSION', '4.3');
define('BUILD', '0');
define('BUILD', '1');
define('LONG_TERM_SUPPORT', false);

// Link constants
Expand Down
6 changes: 1 addition & 5 deletions src/Resources/contao/config/default.php
Expand Up @@ -89,7 +89,7 @@
$GLOBALS['TL_CONFIG']['loginCount'] = 3;
$GLOBALS['TL_CONFIG']['resultsPerPage'] = 30;
$GLOBALS['TL_CONFIG']['maxResultsPerPage'] = 500;
$GLOBALS['TL_CONFIG']['maxImageWidth'] = '';
$GLOBALS['TL_CONFIG']['maxImageWidth'] = 0;
$GLOBALS['TL_CONFIG']['defaultUser'] = 0;
$GLOBALS['TL_CONFIG']['defaultGroup'] = 0;
$GLOBALS['TL_CONFIG']['defaultChmod'] = ['u1', 'u2', 'u3', 'u4', 'u5', 'u6', 'g4', 'g5', 'g6'];
Expand All @@ -102,10 +102,6 @@
. 'mp3,mp4,m4a,m4v,webm,ogg,ogv,wma,wmv,ram,rm,mov,'
. 'zip,rar,7z';
$GLOBALS['TL_CONFIG']['installPassword'] = '';
$GLOBALS['TL_CONFIG']['liveUpdateBase'] = 'https://update.contao.org/service/';
$GLOBALS['TL_CONFIG']['repository_wsdl'] = 'https://contao.org/services/repository.wsdl';
$GLOBALS['TL_CONFIG']['repository_languages'] = 'en,de';
$GLOBALS['TL_CONFIG']['repository_listsize'] = 10;
$GLOBALS['TL_CONFIG']['backendTheme'] = 'flexible';
$GLOBALS['TL_CONFIG']['disableInsertTags'] = false;
$GLOBALS['TL_CONFIG']['rootFiles'] = [];
Expand Down

0 comments on commit f09929c

Please sign in to comment.