Skip to content
This repository
Browse code

merge from 1.0

  • Loading branch information...
commit 9b1337d7f65d7244d815cc2289675b5f9902576d 1 parent be477fc
qiang.xue authored

Showing 3 changed files with 112 additions and 27 deletions. Show diff stats Hide diff stats

  1. +4 1 CHANGELOG
  2. +2 0  UPGRADE
  3. +106 26 framework/yiilite.php
5 CHANGELOG
@@ -13,7 +13,10 @@ Version 1.1a to be released
13 13 - Chg: Changed AR table aliasing so that it uses relation names as default table aliases (Qiang)
14 14 - Chg: Changed the default value of allowEmpty to be false for CCompareValidator. (Qiang)
15 15
16   -Version 1.0.8 To be released
  16 +Version 1.0.9 to be released
  17 +----------------------------
  18 +
  19 +Version 1.0.8 August 9, 2009
17 20 ----------------------------
18 21 - Bug #435: Setting charset for PostgreSQL database connection may fail to work on some servers (Qiang)
19 22 - Bug #440: typo in COciColumnSchema (Qiang)
2  UPGRADE
@@ -17,6 +17,8 @@ In 1.0.x, they are case-insensitive.
17 17
18 18 - Please read the Guide for further details on how to upgrade from v1.0.x to v1.1.
19 19
  20 +Upgrading from v1.0.8
  21 +---------------------
20 22
21 23 Upgrading from v1.0.7
22 24 ---------------------
132 framework/yiilite.php
@@ -33,6 +33,7 @@ class YiiBase
33 33 private static $_aliases=array('system'=>YII_PATH); // alias => path
34 34 private static $_imports=array(); // alias => class name or directory
35 35 private static $_classes=array();
  36 + private static $_includePaths; // list of include paths
36 37 private static $_app;
37 38 private static $_logger;
38 39 public static function getVersion()
@@ -135,7 +136,14 @@ public static function import($alias,$forceInclude=false)
135 136 }
136 137 else // a directory
137 138 {
138   - set_include_path(get_include_path().PATH_SEPARATOR.$path);
  139 + if(self::$_includePaths===null)
  140 + {
  141 + self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
  142 + if(($pos=array_search('.',self::$_includePaths,true))!==false)
  143 + unset(self::$_includePaths[$pos]);
  144 + }
  145 + array_unshift(self::$_includePaths,$path);
  146 + set_include_path('.'.PATH_SEPARATOR.implode(PATH_SEPARATOR,self::$_includePaths));
139 147 return self::$_imports[$alias]=$path;
140 148 }
141 149 }
@@ -764,7 +772,11 @@ public function getParams()
764 772 if($this->_params!==null)
765 773 return $this->_params;
766 774 else
767   - return $this->_params=new CAttributeCollection;
  775 + {
  776 + $this->_params=new CAttributeCollection;
  777 + $this->_params->caseSensitive=true;
  778 + return $this->_params;
  779 + }
768 780 }
769 781 public function setParams($value)
770 782 {
@@ -939,6 +951,7 @@ public function __construct($config=null)
939 951 $this->setBasePath('protected');
940 952 Yii::setPathOfAlias('application',$this->getBasePath());
941 953 Yii::setPathOfAlias('webroot',dirname($_SERVER['SCRIPT_FILENAME']));
  954 + Yii::setPathOfAlias('ext',$this->getBasePath().DIRECTORY_SEPARATOR.'extensions');
942 955 $this->preinit();
943 956 $this->initSystemHandlers();
944 957 $this->registerCoreComponents();
@@ -1008,12 +1021,16 @@ public function setRuntimePath($path)
1008 1021 array('{path}'=>$path)));
1009 1022 $this->_runtimePath=$runtimePath;
1010 1023 }
1011   - final public function getExtensionPath()
  1024 + public function getExtensionPath()
1012 1025 {
1013   - if($this->_extensionPath!==null)
1014   - return $this->_extensionPath;
1015   - else
1016   - return $this->_extensionPath=$this->getBasePath().DIRECTORY_SEPARATOR.'extensions';
  1026 + return Yii::getPathOfAlias('ext');
  1027 + }
  1028 + public function setExtensionPath($path)
  1029 + {
  1030 + if(($extensionPath=realpath($path))===false || !is_dir($extensionPath))
  1031 + throw new CException(Yii::t('yii','Extension path "{path}" does not exist.',
  1032 + array('{path}'=>$path)));
  1033 + Yii::setPathOfAlias('ext',$extensionPath);
1017 1034 }
1018 1035 public function getLanguage()
1019 1036 {
@@ -1158,9 +1175,26 @@ public function handleError($code,$message,$file,$line)
1158 1175 // disable error capturing to avoid recursive errors
1159 1176 restore_error_handler();
1160 1177 restore_exception_handler();
1161   - $log="$message ($file:$line)";
  1178 + $log="$message ($file:$line)\nStack trace:\n";
  1179 + $trace=debug_backtrace();
  1180 + // skip the first 3 stacks as they do not tell the error position
  1181 + if(count($trace)>3)
  1182 + $trace=array_slice($trace,3);
  1183 + foreach($trace as $i=>$t)
  1184 + {
  1185 + if(!isset($t['file']))
  1186 + $t['file']='unknown';
  1187 + if(!isset($t['line']))
  1188 + $t['line']=0;
  1189 + if(!isset($t['function']))
  1190 + $t['function']='unknown';
  1191 + $log.="#$i {$t['file']}({$t['line']}): ";
  1192 + if(isset($t['object']) && is_object($t['object']))
  1193 + $log.=get_class($t['object']).'->';
  1194 + $log.="{$t['function']}()\n";
  1195 + }
1162 1196 if(isset($_SERVER['REQUEST_URI']))
1163   - $log.=' REQUEST_URI='.$_SERVER['REQUEST_URI'];
  1197 + $log.='REQUEST_URI='.$_SERVER['REQUEST_URI'];
1164 1198 Yii::log($log,CLogger::LEVEL_ERROR,'php');
1165 1199 try
1166 1200 {
@@ -1962,6 +1996,8 @@ public function getScriptUrl()
1962 1996 $this->_scriptUrl=$_SERVER['ORIG_SCRIPT_NAME'];
1963 1997 else if(($pos=strpos($_SERVER['PHP_SELF'],'/'.$scriptName))!==false)
1964 1998 $this->_scriptUrl=substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$scriptName;
  1999 + else if(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT'])===0)
  2000 + $this->_scriptUrl=str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME']));
1965 2001 else
1966 2002 throw new CException(Yii::t('yii','CHttpRequest is unable to determine the entry script URL.'));
1967 2003 }
@@ -2291,6 +2327,7 @@ public function createUrl($route,$params=array(),$ampersand='&')
2291 2327 }
2292 2328 else
2293 2329 $anchor='';
  2330 + $route=trim($route,'/');
2294 2331 foreach($this->_rules as $rule)
2295 2332 {
2296 2333 if(($url=$rule->createUrl($this,$route,$params,$ampersand))!==false)
@@ -2305,11 +2342,13 @@ protected function createUrlDefault($route,$params,$ampersand)
2305 2342 $url=rtrim($this->getBaseUrl().'/'.$route,'/');
2306 2343 if($this->appendParams)
2307 2344 {
2308   - $url.='/'.$this->createPathInfo($params,'/','/');
2309   - return rtrim($url,'/').$this->urlSuffix;
  2345 + $url=rtrim($url.'/'.$this->createPathInfo($params,'/','/'),'/');
  2346 + return $route==='' ? $url : $url.$this->urlSuffix;
2310 2347 }
2311 2348 else
2312 2349 {
  2350 + if($route!=='')
  2351 + $url.=$this->urlSuffix;
2313 2352 $query=$this->createPathInfo($params,'=',$ampersand);
2314 2353 return $query==='' ? $url : $url.'?'.$query;
2315 2354 }
@@ -2422,6 +2461,7 @@ class CUrlRule extends CComponent
2422 2461 {
2423 2462 public $urlSuffix;
2424 2463 public $caseSensitive;
  2464 + public $defaultParams=array();
2425 2465 public $route;
2426 2466 public $references=array();
2427 2467 public $routePattern;
@@ -2437,6 +2477,8 @@ public function __construct($route,$pattern)
2437 2477 $this->urlSuffix=$route['urlSuffix'];
2438 2478 if(isset($route['caseSensitive']))
2439 2479 $this->caseSensitive=$route['caseSensitive'];
  2480 + if(isset($route['defaultParams']))
  2481 + $this->defaultParams=$route['defaultParams'];
2440 2482 $route=$this->route=$route[0];
2441 2483 }
2442 2484 else
@@ -2529,6 +2571,11 @@ public function parseUrl($manager,$pathInfo,$rawPathInfo)
2529 2571 $pathInfo.='/';
2530 2572 if(preg_match($this->pattern.$case,$pathInfo,$matches))
2531 2573 {
  2574 + foreach($this->defaultParams as $name=>$value)
  2575 + {
  2576 + if(!isset($_GET[$name]))
  2577 + $_GET[$name]=$value;
  2578 + }
2532 2579 $tr=array();
2533 2580 foreach($matches as $key=>$value)
2534 2581 {
@@ -3705,7 +3752,8 @@ public static function endForm()
3705 3752 }
3706 3753 public static function statefulForm($action='',$method='post',$htmlOptions=array())
3707 3754 {
3708   - return self::form($action,$method,$htmlOptions)."\n".self::pageStateField('');
  3755 + return self::form($action,$method,$htmlOptions)."\n".
  3756 + self::tag('div',array('style'=>'visibility:hidden'),self::pageStateField(''));
3709 3757 }
3710 3758 public static function pageStateField($value)
3711 3759 {
@@ -3741,6 +3789,17 @@ public static function button($label='button',$htmlOptions=array())
3741 3789 self::clientChange('click',$htmlOptions);
3742 3790 return self::tag('input',$htmlOptions);
3743 3791 }
  3792 + public static function htmlButton($label='button',$htmlOptions=array())
  3793 + {
  3794 + if(!isset($htmlOptions['name']))
  3795 + $htmlOptions['name']=self::ID_PREFIX.self::$count++;
  3796 + if(!isset($htmlOptions['type']))
  3797 + $htmlOptions['type']='button';
  3798 + if(!isset($htmlOptions['value']))
  3799 + $htmlOptions['value']=$label;
  3800 + self::clientChange('click',$htmlOptions);
  3801 + return self::tag('button',$htmlOptions);
  3802 + }
3744 3803 public static function submitButton($label='submit',$htmlOptions=array())
3745 3804 {
3746 3805 $htmlOptions['type']='submit';
@@ -4013,7 +4072,8 @@ public static function activeLabel($model,$attribute,$htmlOptions=array())
4013 4072 $for=self::getIdByName(self::resolveName($model,$attribute));
4014 4073 if(isset($htmlOptions['label']))
4015 4074 {
4016   - $label=$htmlOptions['label'];
  4075 + if(($label=$htmlOptions['label'])===false)
  4076 + return '';
4017 4077 unset($htmlOptions['label']);
4018 4078 }
4019 4079 else
@@ -5419,9 +5479,13 @@ public function __construct($scenario='insert')
5419 5479 $this->setScenario($scenario);
5420 5480 $this->setIsNewRecord(true);
5421 5481 $this->_attributes=$this->getMetaData()->attributeDefaults;
  5482 + $this->init();
5422 5483 $this->attachBehaviors($this->behaviors());
5423 5484 $this->afterConstruct();
5424 5485 }
  5486 + public function init()
  5487 + {
  5488 + }
5425 5489 public function __sleep()
5426 5490 {
5427 5491 $this->_md=null;
@@ -5443,7 +5507,12 @@ public function __get($name)
5443 5507 public function __set($name,$value)
5444 5508 {
5445 5509 if($this->setAttribute($name,$value)===false)
5446   - parent::__set($name,$value);
  5510 + {
  5511 + if(isset($this->getMetaData()->relations[$name]))
  5512 + $this->_related[$name]=$value;
  5513 + else
  5514 + parent::__set($name,$value);
  5515 + }
5447 5516 }
5448 5517 public function __isset($name)
5449 5518 {
@@ -5564,6 +5633,13 @@ public function getMetaData()
5564 5633 else
5565 5634 return $this->_md=self::model(get_class($this))->_md;
5566 5635 }
  5636 + public function refreshMetaData()
  5637 + {
  5638 + $finder=self::model(get_class($this));
  5639 + $finder->_md=new CActiveRecordMetaData($finder);
  5640 + if($this!==$finder)
  5641 + $this->_md=$finder->_md;
  5642 + }
5567 5643 public function tableName()
5568 5644 {
5569 5645 return get_class($this);
@@ -6125,14 +6201,6 @@ class CActiveRelation extends CBaseActiveRelation
6125 6201 public $with=array();
6126 6202 public function mergeWith($criteria)
6127 6203 {
6128   - if(isset($criteria['condition']) && $this->on!==$criteria['condition'])
6129   - {
6130   - if($this->on==='')
6131   - $this->on=$criteria['condition'];
6132   - else if($criteria['condition']!=='')
6133   - $this->on="({$this->on}) AND ({$criteria['condition']})";
6134   - }
6135   - unset($criteria['condition']);
6136 6204 parent::mergeWith($criteria);
6137 6205 if(isset($criteria['joinType']))
6138 6206 $this->joinType=$criteria['joinType'];
@@ -6307,10 +6375,7 @@ protected function initConnection($pdo)
6307 6375 if($this->charset!==null)
6308 6376 {
6309 6377 if(strcasecmp($pdo->getAttribute(PDO::ATTR_DRIVER_NAME),'sqlite'))
6310   - {
6311   - $stmt=$pdo->prepare('SET NAMES ?');
6312   - $stmt->execute(array($this->charset));
6313   - }
  6378 + $pdo->exec('SET NAMES '.$pdo->quote($this->charset));
6314 6379 }
6315 6380 }
6316 6381 public function getPdoInstance()
@@ -6555,7 +6620,19 @@ public function getCommandBuilder()
6555 6620 }
6556 6621 public function refresh()
6557 6622 {
  6623 + if(($duration=$this->_connection->schemaCachingDuration)>0 && ($cache=Yii::app()->getCache())!==null)
  6624 + {
  6625 + foreach(array_keys($this->_tables) as $name)
  6626 + {
  6627 + if(!isset($this->_cacheExclude[$name]))
  6628 + {
  6629 + $key='yii:dbschema'.$this->_connection->connectionString.':'.$this->_connection->username.':'.$name;
  6630 + $cache->delete($key);
  6631 + }
  6632 + }
  6633 + }
6558 6634 $this->_tables=array();
  6635 + $this->_tableNames=array();
6559 6636 $this->_builder=null;
6560 6637 }
6561 6638 public function quoteTableName($name)
@@ -6766,6 +6843,7 @@ public function bindParam($name, &$value, $dataType=null, $length=null)
6766 6843 $this->_statement->bindParam($name,$value,$dataType,$length);
6767 6844 if($this->_connection->enableParamLogging)
6768 6845 $this->_params[]=$name.'=['.gettype($value).']';
  6846 + return $this;
6769 6847 }
6770 6848 public function bindValue($name, $value, $dataType=null)
6771 6849 {
@@ -6776,6 +6854,7 @@ public function bindValue($name, $value, $dataType=null)
6776 6854 $this->_statement->bindValue($name,$value,$dataType);
6777 6855 if($this->_connection->enableParamLogging)
6778 6856 $this->_params[]=$name.'='.var_export($value,true);
  6857 + return $this;
6779 6858 }
6780 6859 public function execute()
6781 6860 {
@@ -6940,6 +7019,7 @@ public function getIsInitialized();
6940 7019 interface ICache
6941 7020 {
6942 7021 public function get($id);
  7022 + public function mget($ids);
6943 7023 public function set($id,$value,$expire=0,$dependency=null);
6944 7024 public function add($id,$value,$expire=0,$dependency=null);
6945 7025 public function delete($id);

0 comments on commit 9b1337d

Please sign in to comment.
Something went wrong with that request. Please try again.