diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index d8be4cfa9..723b8e594 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -1,5 +1,11 @@ CHANGELOG +3.7.1 (30. Dezember 2019) +* Base->build: Add support for brace-enclosed route tokens +* Base->reroute, fix duplicate fragment issue on non-alias routes +* DB\SQL\Mapper: fix empty check for pkey when reloading after insert +* Web->minify: fix minification with multiple files, [bcosca/fatfree#1152](https://github.com/bcosca/fatfree/issues/1152), [#bcosca/fatfree#1169](https://github.com/bcosca/fatfree/issues/1169) + 3.7.0 (26. November 2019) * NEW: Matrix, added select and walk methods for array processing and validation tools * NEW: Added configurable file locking via LOCK var diff --git a/lib/base.php b/lib/base.php index 18219a42a..e8234d6ba 100644 --- a/lib/base.php +++ b/lib/base.php @@ -45,7 +45,7 @@ final class Base extends Prefab implements ArrayAccess { //@{ Framework details const PACKAGE='Fat-Free Framework', - VERSION='3.7.0-Release'; + VERSION='3.7.1-Release'; //@} //@{ HTTP status codes (RFC 2616) @@ -177,17 +177,17 @@ function build($url,$args=[]) { } else { $i=0; - $url=preg_replace_callback('/@(\w+)|(\*)/', + $url=preg_replace_callback('/(\{)?@(\w+)(?(1)\})|(\*)/', function($match) use(&$i,$args) { - if (isset($match[1]) && - array_key_exists($match[1],$args)) - return $args[$match[1]]; if (isset($match[2]) && - array_key_exists($match[2],$args)) { - if (!is_array($args[$match[2]])) - return $args[$match[2]]; + array_key_exists($match[2],$args)) + return $args[$match[2]]; + if (isset($match[3]) && + array_key_exists($match[3],$args)) { + if (!is_array($args[$match[3]])) + return $args[$match[3]]; $i++; - return $args[$match[2]][$i-1]; + return $args[$match[3]][$i-1]; } return $match[0]; },$url); @@ -1486,12 +1486,11 @@ function reroute($url=NULL,$permanent=FALSE,$die=TRUE) { $url=$this->hive['REALM']; if (is_array($url)) $url=call_user_func_array([$this,'alias'],$url); - elseif (preg_match('/^(?:@?([^\/()?#]+)(?:\((.+?)\))*(\?[^#]+)*(#.+)*)/', - $url,$parts) && - isset($this->hive['ALIASES'][$parts[1]])) - $url=$this->hive['ALIASES'][$parts[1]]; - $url=$this->build($url,isset($parts[2])?$this->parse($parts[2]):[]). - (isset($parts[3])?$parts[3]:'').(isset($parts[4])?$parts[4]:''); + elseif (preg_match('/^(?:@([^\/()?#]+)(?:\((.+?)\))*(\?[^#]+)*(#.+)*)/', + $url,$parts) && isset($this->hive['ALIASES'][$parts[1]])) + $url=$this->build($this->hive['ALIASES'][$parts[1]], + isset($parts[2])?$this->parse($parts[2]):[]). + (isset($parts[3])?$parts[3]:'').(isset($parts[4])?$parts[4]:''); if (($handler=$this->hive['ONREROUTE']) && $this->call($handler,[$url,$permanent,$die])!==FALSE) return; @@ -2888,7 +2887,7 @@ protected function sandbox(array $hive=NULL,$mime=NULL) { function render($file,$mime='text/html',array $hive=NULL,$ttl=0) { $fw=$this->fw; $cache=Cache::instance(); - foreach (array_unique($fw->split($fw->UI)) as $dir) { + foreach ($fw->split($fw->UI) as $dir) { if ($cache->exists($hash=$fw->hash($dir.$file),$data)) return $data; if (is_file($this->file=$fw->fixslashes($dir.$file))) { @@ -3100,7 +3099,7 @@ function render($file,$mime='text/html',array $hive=NULL,$ttl=0) { $cache=Cache::instance(); if (!is_dir($tmp=$fw->TEMP)) mkdir($tmp,Base::MODE,TRUE); - foreach (array_unique($fw->split($fw->UI)) as $dir) { + foreach ($fw->split($fw->UI) as $dir) { if ($cache->exists($hash=$fw->hash($dir.$file),$data)) return $data; if (is_file($view=$fw->fixslashes($dir.$file))) { diff --git a/lib/db/sql/mapper.php b/lib/db/sql/mapper.php index 930f6e57c..ea041de88 100644 --- a/lib/db/sql/mapper.php +++ b/lib/db/sql/mapper.php @@ -447,7 +447,7 @@ function insert() { if ($field['pkey']) { $field['previous']=$field['value']; if (!$inc && $field['pdo_type']==\PDO::PARAM_INT && - empty($field['value']) && !$field['nullable']) + is_null($field['value']) && !$field['nullable']) $inc=$key; $filter.=($filter?' AND ':'').$this->db->quotekey($key).'=?'; $nkeys[$nctr+1]=[$field['value'],$field['pdo_type']]; diff --git a/lib/web.php b/lib/web.php index 8f6ddf70c..373954bc3 100644 --- a/lib/web.php +++ b/lib/web.php @@ -694,10 +694,11 @@ function minify($files,$mime=NULL,$header=TRUE,$path=NULL) { if (!isset($path)) $path=$fw->UI.';./'; foreach (array_unique($fw->split($path,FALSE)) as $dir) - foreach ($files as $file) + foreach ($files as $i=>$file) if (is_file($save=$fw->fixslashes($dir.$file)) && is_bool(strpos($save,'../')) && preg_match('/\.(css|js)$/i',$file)) { + unset($files[$i]); if ($fw->CACHE && ($cached=$cache->exists( $hash=$fw->hash($save).'.'.$ext[0],$data)) && @@ -815,7 +816,6 @@ function minify($files,$mime=NULL,$header=TRUE,$path=NULL) { $cache->set($hash,$data); $dst.=$data; } - break; } if (PHP_SAPI!='cli' && $header) header('Content-Type: '.$mime.'; charset='.$fw->ENCODING);