Git Product home page Git Product logo

thinkphp's Issues

关于thinkphp Library

thinkphp的库目录结构命名空间怎么改来改去的?不知道这是闹哪样。。。。

RestController JSON 输出bug

$this->goodsinfo = M('Good')->where($map)->select();
$this->response($this->goodsinfo,'JSON');
输出的JSON字符串在SAE上,最后面永远少一个']'字符
在本地有goodsinfo里数据少的时候 正常,但返回结果比较多时,也会出现这个情况

ThinkPHP/Lib/Core/Db.class.php中pdo处理逻辑似乎不完善,导致config中pdo配置失效

在ThinkPHP/Lib/Core/Db.class.php中逻辑判断似乎不完善

源码

// 如果配置为空,读取配置文件设置
if( C('DB_DSN') && 'pdo' != strtolower(C('DB_TYPE')) ) { // 如果设置了DB_DSN 则优先
$db_config = $this->parseDSN(C('DB_DSN'));
}else{
$db_config = array (
'dbms' => C('DB_TYPE'),
'username' => C('DB_USER'),
'password' => C('DB_PWD'),
'hostname' => C('DB_HOST'),
'hostport' => C('DB_PORT'),
'database' => C('DB_NAME'),
'dsn' => C('DB_DSN'),
'params' => C('DB_PARAMS'),
);
}

正确逻辑

// 如果配置为空,读取配置文件设置
if( C('DB_DSN') && 'pdo' == strtolower(C('DB_TYPE')) ) { // 如果设置了DB_DSN 则优先
$db_config = $this->parseDSN(C('DB_DSN'));
}else{
$db_config = array (
'dbms' => C('DB_TYPE'),
'username' => C('DB_USER'),
'password' => C('DB_PWD'),
'hostname' => C('DB_HOST'),
'hostport' => C('DB_PORT'),
'database' => C('DB_NAME'),
'dsn' => C('DB_DSN'),
'params' => C('DB_PARAMS'),
);
}

丢失C('CACHE_PATH')导致的问题

6月21日的提交你们将 C('CACHE_PATH',CACHE_PATH.GROUP_NAME.'/'); 这句移动到了 Dispatcher.class.php 中,但是前面有一句 if(defined('GROUP_NAME'))
这样导致了如下问题,如果项目配置常量中没有 GROUP_NAME,则会把编译模板生成到项目的根目录中。

解决方法:必须强制在入口文件中定义 GROUP_NAME 。
请修复

Pgsql当字段为布尔值型的时候,转换出错

已经再这里提交过了
我使用的是Pgsql数据库,在使用
create方法创建数据的时候,会自动转换我的值,
比如:这里是POST到服务器的数据。这里的isshow是y

{"name":"hunmareg","title":"\u7ba1\u7406","isshow":"y","status":"1","remark":"","navTabId":"Group","callbackType":"closeCurrent","_URL_":["Group","insert","navTabId","Group","callbackType","closeCurrent"]}

但最后生成的sql却是

(name,title,isshow,status,create_user,create_time,update_time,update_user,sort) VALUES ('hunmareg','\u7ba1\u7406',1,1,1,'now','epoch',0,0)

这里的isshow就是(int)1了。。。。

pqsql9.2提示如下:
ERROR column "isshow" is of type boolean but expression is of type integer at character 119

,是我的问题么?

暂时的解决办法:
/Extend/Driver/Db/DbPgsql.class.php 第300行加入

/**
     * value分析
     * @access protected
     * @param mixed $value
     * @return string
     */
    protected function parseValue($value) {
        if(is_string($value)) {
            $value =  '\''.$this->escapeString($value).'\'';
        }elseif(isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp'){
            $value =  $this->escapeString($value[1]);
        }elseif(is_array($value)) {
            $value =  array_map(array($this, 'parseValue'),$value);
        }elseif(is_bool($value)){
            $value = $value ? 'TRUE' : 'FALSE'; //TOssP $value =  $value ? '1' : '0';
        }elseif(is_null($value)){
            $value =  'null';
        }
        return $value;
    }

关于单元测试

有配合使用的单元测试样例吗?
如果没有有相应的开发时间表吗?

谢谢~

ThinkException::_toString 的建议

ThinkException.class.php 63行: $traceInfo .= $t['class'].$t['type'].$t['function'].'(';

不是每一层调用都是方法调用。。。
栈中每一个函数调用都产生一个Notice级别的错误。
虽然这些notice在 Think::appError 中被忽略了,但是在有些情况下会产生奇怪的输出。
(忽略Notice错误对新手很不好。。。

应该改成
$traceInfo .= @$t['class'].@$t['type'].$t['function'].'(';
或者
$traceInfo .= (isset($t['class'])?$t['class'].$t['type']:'').$t['function'].'(';

最后还有…………明明叫做 _toString 却返回数组,各种意义上不科学……

视图模型ViewModel存在的一个BUG

    public $viewFields = array(
        'People' => array('*'),
        '`Group`' => array('name' => 'group_name', 'level' => 'level', '_on' => 'People.group_id=Group.group_id'),
    );

生成的SQL

SELECT
    People.people_id AS people_id,
    People.account AS account,
    People.PASSWORD AS PASSWORD,
    People.group_id AS group_id,
    GROUP.NAME AS group_name,
    GROUP.LEVEL AS LEVEL
FROM
    bpi_people People
JOIN bpi_group GROUP ON People.group_id = GROUP.group_id

看到最后面的GROUP ON就知道问题出在哪里了

U函数跨分组问题

教程里是这样写的
U('Home/index'); 前面没有/,表示调用HOME分组下的INDEX模块

但我在独立分组中调用出现这样的结果,我在Company分组下调用
U('Home/index'); 得到的结果是 /index.php/company/home/index

使用U('/Home/Index'); 得到的是正确的结果 /index.php/home/index

是文档教程有遗漏错误, 还是功能有缺陷?

是否考虑U方法增加一些简单的自定路由规则的反向解释,让U方法生成的网址更完美

U方法现在只针对URL模式生成简单的URL规则,但对于自定义的URL_ROUTE_RULES无能为力,是否考虑针对普通正则生成的自定义路由进行反向解释,例如如下URL规则

return array(
'URL_MODEL'=>2,
'URL_ROUTE_RULES' =>array(
        '/^c\/(\d+)\/g\/(\S+)$/' => 'cate/index?gid=:1&tag=:2',     
    )
);

/c/123/g/tagname 类似的网址重写成 /cate/index?gid=123&tag=tagname
但调用U方法 U("cate/index?gid=123&tag=tagname")实际上只能生成/cate/index/gid/123/tag/tagname 而不是最精简的结果。

我通过修改U方法实现了以上简单的反向正则功能,但暂时不支持类似于news/:year/:month/:day的反向解释
代码写在普通模式URL转换之后,代码如下:

if (C('URL_MODEL') == 2 && C('URL_ROUTER_ON')){ //存在路由时反向翻译
        $routes = C('URL_ROUTE_RULES');
        if (false === strpos('/', $url)) {
            $url    =   implode($depr,array_reverse($var));
        }
        $_url=array_merge(parseUrl($url), $vars);
        foreach ($routes as $rule=>$r_route){
            $r_route = str_replace('/', $depr, $r_route);
            $_route=parseUrl(str_replace(':', '~',$r_route));
            if(url_compare($_url, $_route))break;
        }
        if(url_compare($_url, $_route)){
            foreach ($_route as $key=>$val){
                if($key==C('VAR_MODULE')||$key==C('VAR_ACTION'))continue;
                if( preg_match("/~/",$val) ){
                    $rule=preg_replace("/(\(\\\[\w+]\+\))/",$_url[$key],$rule,1);
                }
            }
            //去掉最后的"/"
            $url = __APP__.'/'.ltrim(rtrim(trim($rule,'/'), '$'), '^');
            $url = str_replace('\\', '', $url);
            $flag = false;
        }
    }

默认使用Memcache,开启SQL缓存,SQL缓存无法成功建立

ThinkPHP 版本 3.1.2
前提:
'DATA_CACHE_TYPE'=>'Memcache', //默认缓存Memcache

"DB_SQL_BUILD_CACHE"=>true, //开启SQL缓存
'DB_SQL_BUILD_LENGTH' =>50, // SQL缓存的队列长度
'DB_SQL_BUILD_QUEUE' =>'file', // SQL缓存的队列存储方式

本地开启Memcahe服务端 ,浏览界面会报
[8] Undefined index: persistent E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 46 行.
[8] Undefined index: timeout E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 48 行.
[8] Undefined index: host E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 50 行.
[8] Undefined index: port E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 50 行.
[8] Undefined index: timeout E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 50 行.
[8] Memcache::connect() [memcache.connect]: Server (tcp 0) failed with: Failed to parse address "" (0) E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 50 行.
[2] Memcache::connect() [memcache.connect]: Can't connect to :0, Failed to parse address "" (0) E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 50 行.
[2] Memcache::set() [memcache.set]: Failed to extract 'connection' variable from object E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 78 行.
[2] Memcache::get() [memcache.get]: Failed to extract 'connection' variable from object E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 61 行.
[2] Memcache::set() [memcache.set]: Failed to extract 'connection' variable from object E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 78 行.
[2] Memcache::get() [memcache.get]: Failed to extract 'connection' variable from object E:\workspace\v5\ThinkPHP\Extend\Driver\Cache\CacheMemcache.class.php 第 61 行.
[2] Memcache::set() [memcache.set]: Failed to extract

查看代码发现开启SQL缓存后
Lib/Core/Db.class.php

if(isset($key)) { // 写入SQL创建缓存
S($key,$sql,array('expire'=>0,'length'=>C('DB_SQL_BUILD_LENGTH'),'queue'=>C('DB_SQL_BUILD_QUEUE')));
}

而在S方法中

static $cache = '';
if(is_array($options)){
// 缓存操作的同时初始化
$type = isset($options['type'])?$options['type']:'';
$cache = Cache::getInstance($type,$options);
}elseif(is_array($name)) { // 缓存初始化
$type = isset($name['type'])?$name['type']:'';
$cache = Cache::getInstance($type,$name);
return $cache;
}elseif(empty($cache)) { // 自动初始化
$cache = Cache::getInstance();
}
如果option 有值,直接传入Cache初始化参数中
CacheMemcache

if(empty($options)) {
$options = array (
'host' => C('MEMCACHE_HOST') ? C('MEMCACHE_HOST') : '127.0.0.1',
'port' => C('MEMCACHE_PORT') ? C('MEMCACHE_PORT') : 11211,
'timeout' => C('DATA_CACHE_TIMEOUT') ? C('DATA_CACHE_TIMEOUT') : false,
'persistent' => false,
);
}
$this->options = $options;
可见其判断 option不为空 ,就是用option
而上面的option里面 没有host,port,关键参数,导致memcache建立错误
我现在的临时改法是在CacheMemcache中 用 array_merge 合并参数

另外我还有个疑问

S 方法中使用的 static $cache ,会不会产生这样情况?
如果我第一次调用 S('key','value',array('type'=>'file');
第二次调用 S('key','value'); (不会使用我默认的Memcache),会使用CacheFile

只是初学,如果说错了,请指正。

graphviz与functons中layout函数名称冲突

graphviz是一个php扩展,分析性能的webgrind依赖这个扩展(linux - php5.4.13)。

我认为 functions.php 尽量不出现跟框架某个特定部分密切相关的东西(比如layout、load_ext_file ← 这货一辈子就被App::init调用一次有木有)
而是 halt、redirect、S 这类底层支持函数。

建议改成 View::layout ,因为调用layout函数会使View的行为发生改变。

模板引擎的问题

现在输出属性如果之前碰到符号"{"的时候就不能正常解析,虽然打个空格就可以了,但是还是属于bug的吧。

U函数子域名部署有bug

开启分组、子域名部署、没有定义路由、URL不去分大小写
U('Group/Action/Method')
输出
/action/Method
(/index.php/action/Method ; /index.php?s=/action/Method)

Group部分被忽略了

模版引擎解析问题

假如在Action中有assign两个变量,分别是a和b
那么在模版中 应该用{$a} 和{$b}来引用这两个变量
但是,当在{$a}所在的行前面有 { 的时候,模版将不把{$a}解析

举个例子:
jQuery.get('url', {'a':{$a}, 'b':{$b}}, function(data){}, "json");
这种情况{$a}将不会解析,而是直接输出字符串{$a}
但是将其与前一个 { 换行便可工作
jQuery.get('url', {
'a':{$a}, 'b':{$b}}, function(data){}, "json");

Can not use smarty with thinkphp group module.

When use thinkphp group module with ThinkTemplate, it works fine.

But when use smarty as replacement, it can not work as follow:

exception 'SmartyException' with message 'Unable to load template file 'Index/index.html'' in D:\www\ThinkPHP\Extend\Vendor\Smarty\sysplugins\smarty_internal_templatebase.php:127 Stack trace: #0

I check git lastest thinkphp core file, but still have that problem, can you check whether check out your lastest file to git server? or never slove that problem, please tell me when you slove that issue,thanks . my email: [email protected]

当post的值是一个数组的时候。就不能用I('post.var')?

程序

        var_export($_POST['json']);
        var_export(I('post.json'));

输出

array (
  0 => 
  array (
    'id' => '',
    'name' => 'xxxxxxxxxxx',
    'auth' => 
    array (
      0 => 'del_self',
    ),
  ),
  1 => 
  array (
    'id' => '',
    'name' => 'qqqqqq',
    'auth' => 
    array (
      0 => 'auth',
      1 => 'add_self',
    ),
  ),
  2 => 
  array (
    'name' => '',
  ),
)
array (
  0 => '',
  1 => '',
  2 => '',
)

使用关联模型MANY_TO_MANY关联不能获取关联表的字段

如果把RelationModel.class.php的180行

原来的:

$sql = "SELECT b.{$mappingFields} FROM {$mappingRelationTable} AS a, ".$model->getTableName()." AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}";

改为:

$sql = "SELECT {$mappingFields} FROM {$mappingRelationTable} AS a, ".$model->getTableName()." AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}";

自己定义$mappingFields来查询那个表那个字段。

DbPdo.class.php

Line:275 $val['dey']=> $val['key']

出现的问题: pdo链接无法获取主键, 关联模型定义foreign_key 不起作用

如何让ThinkPHP3支持ActionChain呢?

ThinkPHP2是直接通过修改源代码让其支持ActionChain的

3有什么通过扩展的办法让其支持ActionChain么?

看了下App::exec方法貌似给写死了。

SAE下部署出错

普通部署正常,在SAE下,非调试模式,无任何输错,调试模式时提示错误!

Fatal_error: print_r() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers in ThinkPHP/Extend/Engine/Sae/Common/common.php on line 613

地址:http://dyapi.sinaapp.com/

求解,前一个版本在SAE下也正常,本地和普通服务器也正常。

关于分组模式下URL路由解析的严重BUG

ThinkPHP/Lib/Core/Dispatcher.class.php第109行
$var[C('VAR_GROUP')] = in_array(strtolower($paths[0]),explode(',',strtolower(C('APP_GROUP_LIST'))))? array_shift($paths) : '';

$paths数组只有两个值而且$paths[0]存在于APP_GROUP_LIST的时候,会被误判为分组。例如:

假设我默认分组是Index,我要调用Index模块的add方法。
http://localhost/index.php/Index/add 这个URL是正确的
但是却是访问到了Index分组的add模块的index方法,希望能修正。

同时还有一个问题是,当我的URL_MODE = 0的时候,ACTION返回的格式并不是/index.php?g=xx&m=xx&a=xx这样的格式,而是index.php/xx/xx/xx

多对多关联模型自动写入时清空了中间表

增加时出现了这样一条语句, 清空了中间表, 不知如何解决?
SQL: DELETE FROM 中间表

写入的语句是这样的:
$this->model->relation(true)->add($_POST);

$_POST 数据编码成JSON如下,

{"name":"\u516b\u8fbe\u5cad\u957f\u57ce-\u5b9a\u96751\u65e5\u6e38\uff1c\u8d60\u5bcc\u6765\u5bab\u6e29\u6cc9\uff0c\u53e4\u795e\u9053\u5916\u666f\uff1e ","title":"\u8d60\u9001\u54c1\u5c1d\u8001\u5317\u4eac\u7279\u8272\u9910\uff0c\u54c1\u5c1d\u5730\u9053\u5317\u4eac\u5473\u513f\u3002","Categories":[{"id":"5"},{"id":"88"},{"id":"89"}],"Distributors":[{"id":"1"},{"id":"2"},{"id":"7"},{"id":"11"},{"id":"15"},{"id":"17"}],"Groups":[{"id":"12"},{"id":"13"},{"id":"15"},{"id":"17"},{"id":"19"}],"uid":"1","suid":"1","emergency_phone":"13468843724","reception":"\u5408\u80a5","serial_number":"864","is_direct_sale":"1","is_distribute_sale":"1","single_room_spread":"50","refer_price":"30","Prices":{"1":{"name":"\u6210\u4eba\u4ef7","price":"1000","peer_price":"900","cost":"800","description":"\u6210\u4eba\u4ef7","reserve_seat":"0","is_shuttle_fare":"1","available_to_distributor":"1"}},"department_transportation":"\u98de\u673a","renturn_transportation":"\u98de\u673a","Places":{"1":{"place":"\u9526\u6c5f\u5927\u53a6","time":"10:00","price":"10"}},"group_start_date":"2013-12-24","group_state":"1","group_end_date":"","departure_time":"06:00","return_time":"04:00","sale_inadvance":"10","duration":"1","max_number":"0","min_number":"1","begin":"10\u67081-4\u65e5\u5929\u5929\u53d1\u56e2","cancle_rule":"\u5927\u4e8e24\u5c0f\u65f6\u9000\u56e2\u4e0d\u6536\u8d39\uff0c24\u5c0f\u65f6\u5185\u6536\u53d610%\u56e2\u8d39 ","insurance":"\u65c5\u6e38\u610f\u5916\u9669 \u65c5\u884c\u793e\u8d23\u4efb\u9669","description":"","schedule":"","service":"","tips":"","remark":"","logo_image":"","seo_title":"","seo_keywords":"","seo_description":""}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.