mirror of
https://github.com/mrclay/minify.git
synced 2025-08-15 10:34:02 +02:00
Allow sources to have null contentType if serve is given one
This commit is contained in:
@@ -652,9 +652,24 @@ class Minify {
|
|||||||
|
|
||||||
$type = null;
|
$type = null;
|
||||||
foreach ($this->sources as $source) {
|
foreach ($this->sources as $source) {
|
||||||
|
$sourceType = $source->getContentType();
|
||||||
|
|
||||||
|
if (!empty($options['contentType'])) {
|
||||||
|
// just verify sources have null content type or match the options
|
||||||
|
if ($sourceType !== null && $sourceType !== $options['contentType']) {
|
||||||
|
// TODO better logging
|
||||||
|
Minify_Logger::log('ContentType mismatch');
|
||||||
|
|
||||||
|
$this->sources = array();
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($type === null) {
|
if ($type === null) {
|
||||||
$type = $source->getContentType();
|
$type = $sourceType;
|
||||||
} elseif ($source->getContentType() !== $type) {
|
} elseif ($sourceType !== $type) {
|
||||||
|
|
||||||
// TODO better logging
|
// TODO better logging
|
||||||
Minify_Logger::log('ContentType mismatch');
|
Minify_Logger::log('ContentType mismatch');
|
||||||
@@ -663,10 +678,13 @@ class Minify {
|
|||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null === $type) {
|
|
||||||
$type = 'text/plain';
|
if (empty($options['contentType'])) {
|
||||||
|
if (null === $type) {
|
||||||
|
$type = 'text/plain';
|
||||||
|
}
|
||||||
|
$options['contentType'] = $type;
|
||||||
}
|
}
|
||||||
$options['contentType'] = $type;
|
|
||||||
|
|
||||||
// last modified is needed for caching, even if setExpires is set
|
// last modified is needed for caching, even if setExpires is set
|
||||||
if (!isset($options['lastModifiedTime'])) {
|
if (!isset($options['lastModifiedTime'])) {
|
||||||
|
@@ -47,7 +47,7 @@ interface Minify_SourceInterface {
|
|||||||
/**
|
/**
|
||||||
* Get the content type
|
* Get the content type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function getContentType();
|
public function getContentType();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user