Permalink
Browse files

merge from 1.0

  • Loading branch information...
1 parent be477fc commit 9b1337d7f65d7244d815cc2289675b5f9902576d qiang.xue committed Aug 9, 2009
Showing with 112 additions and 27 deletions.
  1. +4 −1 CHANGELOG
  2. +2 −0 UPGRADE
  3. +106 −26 framework/yiilite.php
View
@@ -13,7 +13,10 @@ Version 1.1a to be released
- Chg: Changed AR table aliasing so that it uses relation names as default table aliases (Qiang)
- Chg: Changed the default value of allowEmpty to be false for CCompareValidator. (Qiang)
-Version 1.0.8 To be released
+Version 1.0.9 to be released
+----------------------------
+
+Version 1.0.8 August 9, 2009
----------------------------
- Bug #435: Setting charset for PostgreSQL database connection may fail to work on some servers (Qiang)
- Bug #440: typo in COciColumnSchema (Qiang)
View
@@ -17,6 +17,8 @@ In 1.0.x, they are case-insensitive.
- Please read the Guide for further details on how to upgrade from v1.0.x to v1.1.
+Upgrading from v1.0.8
+---------------------
Upgrading from v1.0.7
---------------------
View
@@ -33,6 +33,7 @@ class YiiBase
private static $_aliases=array('system'=>YII_PATH); // alias => path
private static $_imports=array(); // alias => class name or directory
private static $_classes=array();
+ private static $_includePaths; // list of include paths
private static $_app;
private static $_logger;
public static function getVersion()
@@ -135,7 +136,14 @@ public static function import($alias,$forceInclude=false)
}
else // a directory
{
- set_include_path(get_include_path().PATH_SEPARATOR.$path);
+ if(self::$_includePaths===null)
+ {
+ self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
+ if(($pos=array_search('.',self::$_includePaths,true))!==false)
+ unset(self::$_includePaths[$pos]);
+ }
+ array_unshift(self::$_includePaths,$path);
+ set_include_path('.'.PATH_SEPARATOR.implode(PATH_SEPARATOR,self::$_includePaths));
return self::$_imports[$alias]=$path;
}
}
@@ -764,7 +772,11 @@ public function getParams()
if($this->_params!==null)
return $this->_params;
else
- return $this->_params=new CAttributeCollection;
+ {
+ $this->_params=new CAttributeCollection;
+ $this->_params->caseSensitive=true;
+ return $this->_params;
+ }
}
public function setParams($value)
{
@@ -939,6 +951,7 @@ public function __construct($config=null)
$this->setBasePath('protected');
Yii::setPathOfAlias('application',$this->getBasePath());
Yii::setPathOfAlias('webroot',dirname($_SERVER['SCRIPT_FILENAME']));
+ Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions');
$this->preinit();
$this->initSystemHandlers();
$this->registerCoreComponents();
@@ -1008,12 +1021,16 @@ public function setRuntimePath($path)
array('{path}'=>$path)));
$this->_runtimePath=$runtimePath;
}
- final public function getExtensionPath()
+ public function getExtensionPath()
{
- if($this->_extensionPath!==null)
- return $this->_extensionPath;
- else
- return $this->_extensionPath=$this->getBasePath().DIRECTORY_SEPARATOR.'extensions';
+ return Yii::getPathOfAlias('ext');
+ }
+ public function setExtensionPath($path)
+ {
+ if(($extensionPath=realpath($path))===false || !is_dir($extensionPath))
+ throw new CException(Yii::t('yii','Extension path "{path}" does not exist.',
+ array('{path}'=>$path)));
+ Yii::setPathOfAlias('ext',$extensionPath);
}
public function getLanguage()
{
@@ -1158,9 +1175,26 @@ public function handleError($code,$message,$file,$line)
// disable error capturing to avoid recursive errors
restore_error_handler();
restore_exception_handler();
- $log="$message ($file:$line)";
+ $log="$message ($file:$line)\nStack trace:\n";
+ $trace=debug_backtrace();
+ // skip the first 3 stacks as they do not tell the error position
+ if(count($trace)>3)
+ $trace=array_slice($trace,3);
+ foreach($trace as $i=>$t)
+ {
+ if(!isset($t['file']))
+ $t['file']='unknown';
+ if(!isset($t['line']))
+ $t['line']=0;
+ if(!isset($t['function']))
+ $t['function']='unknown';
+ $log.="#$i {$t['file']}({$t['line']}): ";
+ if(isset($t['object']) && is_object($t['object']))
+ $log.=get_class($t['object']).'->';
+ $log.="{$t['function']}()\n";
+ }
if(isset($_SERVER['REQUEST_URI']))
- $log.=' REQUEST_URI='.$_SERVER['REQUEST_URI'];
+ $log.='REQUEST_URI='.$_SERVER['REQUEST_URI'];
Yii::log($log,CLogger::LEVEL_ERROR,'php');
try
{
@@ -1962,6 +1996,8 @@ public function getScriptUrl()
$this->_scriptUrl=$_SERVER['ORIG_SCRIPT_NAME'];
else if(($pos=strpos($_SERVER['PHP_SELF'],'/'.$scriptName))!==false)
$this->_scriptUrl=substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$scriptName;
+ else if(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT'])===0)
+ $this->_scriptUrl=str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME']));
else
throw new CException(Yii::t('yii','CHttpRequest is unable to determine the entry script URL.'));
}
@@ -2291,6 +2327,7 @@ public function createUrl($route,$params=array(),$ampersand='&')
}
else
$anchor='';
+ $route=trim($route,'/');
foreach($this->_rules as $rule)
{
if(($url=$rule->createUrl($this,$route,$params,$ampersand))!==false)
@@ -2305,11 +2342,13 @@ protected function createUrlDefault($route,$params,$ampersand)
$url=rtrim($this->getBaseUrl().'/'.$route,'/');
if($this->appendParams)
{
- $url.='/'.$this->createPathInfo($params,'/','/');
- return rtrim($url,'/').$this->urlSuffix;
+ $url=rtrim($url.'/'.$this->createPathInfo($params,'/','/'),'/');
+ return $route==='' ? $url : $url.$this->urlSuffix;
}
else
{
+ if($route!=='')
+ $url.=$this->urlSuffix;
$query=$this->createPathInfo($params,'=',$ampersand);
return $query==='' ? $url : $url.'?'.$query;
}
@@ -2422,6 +2461,7 @@ class CUrlRule extends CComponent
{
public $urlSuffix;
public $caseSensitive;
+ public $defaultParams=array();
public $route;
public $references=array();
public $routePattern;
@@ -2437,6 +2477,8 @@ public function __construct($route,$pattern)
$this->urlSuffix=$route['urlSuffix'];
if(isset($route['caseSensitive']))
$this->caseSensitive=$route['caseSensitive'];
+ if(isset($route['defaultParams']))
+ $this->defaultParams=$route['defaultParams'];
$route=$this->route=$route[0];
}
else
@@ -2529,6 +2571,11 @@ public function parseUrl($manager,$pathInfo,$rawPathInfo)
$pathInfo.='/';
if(preg_match($this->pattern.$case,$pathInfo,$matches))
{
+ foreach($this->defaultParams as $name=>$value)
+ {
+ if(!isset($_GET[$name]))
+ $_GET[$name]=$value;
+ }
$tr=array();
foreach($matches as $key=>$value)
{
@@ -3705,7 +3752,8 @@ public static function endForm()
}
public static function statefulForm($action='',$method='post',$htmlOptions=array())
{
- return self::form($action,$method,$htmlOptions)."\n".self::pageStateField('');
+ return self::form($action,$method,$htmlOptions)."\n".
+ self::tag('div',array('style'=>'visibility:hidden'),self::pageStateField(''));
}
public static function pageStateField($value)
{
@@ -3741,6 +3789,17 @@ public static function button($label='button',$htmlOptions=array())
self::clientChange('click',$htmlOptions);
return self::tag('input',$htmlOptions);
}
+ public static function htmlButton($label='button',$htmlOptions=array())
+ {
+ if(!isset($htmlOptions['name']))
+ $htmlOptions['name']=self::ID_PREFIX.self::$count++;
+ if(!isset($htmlOptions['type']))
+ $htmlOptions['type']='button';
+ if(!isset($htmlOptions['value']))
+ $htmlOptions['value']=$label;
+ self::clientChange('click',$htmlOptions);
+ return self::tag('button',$htmlOptions);
+ }
public static function submitButton($label='submit',$htmlOptions=array())
{
$htmlOptions['type']='submit';
@@ -4013,7 +4072,8 @@ public static function activeLabel($model,$attribute,$htmlOptions=array())
$for=self::getIdByName(self::resolveName($model,$attribute));
if(isset($htmlOptions['label']))
{
- $label=$htmlOptions['label'];
+ if(($label=$htmlOptions['label'])===false)
+ return '';
unset($htmlOptions['label']);
}
else
@@ -5419,9 +5479,13 @@ public function __construct($scenario='insert')
$this->setScenario($scenario);
$this->setIsNewRecord(true);
$this->_attributes=$this->getMetaData()->attributeDefaults;
+ $this->init();
$this->attachBehaviors($this->behaviors());
$this->afterConstruct();
}
+ public function init()
+ {
+ }
public function __sleep()
{
$this->_md=null;
@@ -5443,7 +5507,12 @@ public function __get($name)
public function __set($name,$value)
{
if($this->setAttribute($name,$value)===false)
- parent::__set($name,$value);
+ {
+ if(isset($this->getMetaData()->relations[$name]))
+ $this->_related[$name]=$value;
+ else
+ parent::__set($name,$value);
+ }
}
public function __isset($name)
{
@@ -5564,6 +5633,13 @@ public function getMetaData()
else
return $this->_md=self::model(get_class($this))->_md;
}
+ public function refreshMetaData()
+ {
+ $finder=self::model(get_class($this));
+ $finder->_md=new CActiveRecordMetaData($finder);
+ if($this!==$finder)
+ $this->_md=$finder->_md;
+ }
public function tableName()
{
return get_class($this);
@@ -6125,14 +6201,6 @@ class CActiveRelation extends CBaseActiveRelation
public $with=array();
public function mergeWith($criteria)
{
- if(isset($criteria['condition']) && $this->on!==$criteria['condition'])
- {
- if($this->on==='')
- $this->on=$criteria['condition'];
- else if($criteria['condition']!=='')
- $this->on="({$this->on}) AND ({$criteria['condition']})";
- }
- unset($criteria['condition']);
parent::mergeWith($criteria);
if(isset($criteria['joinType']))
$this->joinType=$criteria['joinType'];
@@ -6307,10 +6375,7 @@ protected function initConnection($pdo)
if($this->charset!==null)
{
if(strcasecmp($pdo->getAttribute(PDO::ATTR_DRIVER_NAME),'sqlite'))
- {
- $stmt=$pdo->prepare('SET NAMES ?');
- $stmt->execute(array($this->charset));
- }
+ $pdo->exec('SET NAMES '.$pdo->quote($this->charset));
}
}
public function getPdoInstance()
@@ -6555,7 +6620,19 @@ public function getCommandBuilder()
}
public function refresh()
{
+ if(($duration=$this->_connection->schemaCachingDuration)>0 && ($cache=Yii::app()->getCache())!==null)
+ {
+ foreach(array_keys($this->_tables) as $name)
+ {
+ if(!isset($this->_cacheExclude[$name]))
+ {
+ $key='yii:dbschema'.$this->_connection->connectionString.':'.$this->_connection->username.':'.$name;
+ $cache->delete($key);
+ }
+ }
+ }
$this->_tables=array();
+ $this->_tableNames=array();
$this->_builder=null;
}
public function quoteTableName($name)
@@ -6766,6 +6843,7 @@ public function bindParam($name, &$value, $dataType=null, $length=null)
$this->_statement->bindParam($name,$value,$dataType,$length);
if($this->_connection->enableParamLogging)
$this->_params[]=$name.'=['.gettype($value).']';
+ return $this;
}
public function bindValue($name, $value, $dataType=null)
{
@@ -6776,6 +6854,7 @@ public function bindValue($name, $value, $dataType=null)
$this->_statement->bindValue($name,$value,$dataType);
if($this->_connection->enableParamLogging)
$this->_params[]=$name.'='.var_export($value,true);
+ return $this;
}
public function execute()
{
@@ -6940,6 +7019,7 @@ public function getIsInitialized();
interface ICache
{
public function get($id);
+ public function mget($ids);
public function set($id,$value,$expire=0,$dependency=null);
public function add($id,$value,$expire=0,$dependency=null);
public function delete($id);

0 comments on commit 9b1337d

Please sign in to comment.