Code Monkey home page Code Monkey logo

yii's Introduction

Yii Web Programming Framework

Thank you for choosing Yii - a high-performance component-based PHP framework.

Build Status

Note that Yii 1.1 has reached end of life and will only receive necessary security fixes and fixes to adjust the code for compatibility with PHP 7 and 8 if they do not cause breaking changes. This allows you to keep your servers PHP version up to date in the environments where old Yii 1.1 applications are hosted and stay within the version ranges supported by the PHP team.

Currently tested and supported up to PHP 8.2.

INSTALLATION

Please make sure the release file is unpacked under a Web-accessible directory. You shall see the following files and directories:

  demos/               demos
  framework/           framework source files
  requirements/        requirement checker
  CHANGELOG            describing changes in every Yii release
  LICENSE              license of Yii
  README               this file
  UPGRADE              upgrading instructions

REQUIREMENTS

The minimum requirement by Yii is that your Web server supports PHP 5.1.0 or above. Yii has been tested with Apache HTTP server on Windows and Linux operating systems.

Please access the following URL to check if your Web server reaches the requirements by Yii, assuming "YiiPath" is where Yii is installed:

  http://hostname/YiiPath/requirements/index.php

QUICK START

Yii comes with a command line tool called "yiic" that can create a skeleton Yii application for you to start with.

On command line, type in the following commands:

    $ cd YiiPath/framework                (Linux)
    cd YiiPath\framework                  (Windows)

    $ ./yiic webapp ../testdrive          (Linux)
    yiic webapp ..\testdrive              (Windows)

The new Yii application will be created at "YiiPath/testdrive". You can access it with the following URL:

    http://hostname/YiiPath/testdrive/index.php

WHAT'S NEXT

Please visit the project website for tutorials, class reference and join discussions with other Yii users.

The Yii Developer Team https://www.yiiframework.com

yii's People

Contributors

acorncom avatar arhell avatar borales avatar cebe avatar creocoder avatar dasourcerer avatar davidhrbac avatar emanwebdev avatar gregmolnar avatar janisto avatar joujiahe avatar kidol avatar klimov-paul avatar lightglitch avatar lubosdz avatar marcovtwout avatar mdomba avatar nineinchnick avatar nsanden avatar phpnode avatar qiangxue avatar resurtm avatar samdark avatar sebathi avatar softark avatar sonkodmitry avatar suralc avatar tom-- avatar wtommyw avatar yiivgeny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii's Issues

isset() && empty() - expression

Regarding the spontaneous code review of revision 1589 I identified 4 more
occurences in the 1.0 branch if you are interested.

[CViewAction.php at line 82]
if(isset($_GET[$this->viewParam]) && !empty($_GET[$this->viewParam]))

[CController.php at line 1041]
if(isset($_POST[self::STATE_INPUT_NAME]) &&
!empty($_POST[self::STATE_INPUT_NAME]))

[CActiveFinder.php at line 256]
if(isset($scopes) && !empty($scopes))

[CLogFilter.php at line 97]
if(isset($GLOBALS[$name]) && !empty($GLOBALS[$name]))

Migrated from http://code.google.com/p/yii/issues/detail?id=729


earlier comments

qiang.xue said, at 2009-12-15T16:06:01.000Z:

This issue was closed by revision r1592.

qiang.xue said, at 2012-02-15T18:36:29.000Z:

Migrated to http://github.com//issues/8

Fatal Errors in zii.widgets.menus.CListMenu

What steps will reproduce the problem?

  1. Using CListMenu

What is the expected output?
A nested <ul> based menu

What do you see instead?

  1. YiiBase::include(CBaseMenu.php) [<a
    href='yiibase.include'>yiibase.include</a>]: failed to open stream: No such
    file or directory

Fix is to add the line:
Yii::import('zii.widgets.menus.CBaseMenu');
before the CListMenu class declaration

Having solved 1
2. Fatal error: Call to protected method CHtml::renderattributes() from
context 'CListMenu' in C:.....\zii\widgets\menus\CListMenu.php on line 53

Fix is to change the line in renderMenu() from
echo '<ul'.CHtml::renderAttributes($htmlOptions).'>';
to
echo Chtml::openTag('ul', $htmlOptions);

Migrated from http://code.google.com/p/yii/issues/detail?id=753


earlier comments

qiang.xue said, at 2009-12-22T15:16:25.000Z:

CListMenu is not completed yet.

[email protected] said, at 2009-12-22T18:46:39.000Z:

Couple of questions on this: 1. How are users to know what is and isn't complete? There is nothing in the file to let us know. and 2. Do the dev team not want issues raised no matter what the release status? The only reason for raising this issue was to help make Yii and Zii as great as possible.

Would be useful to know so we can follow the correct process and not waste the dev
team's time.

Thanks

qiang.xue said, at 2009-12-22T18:52:46.000Z:

Sorry, I should have removed the files from "menu" from the release file (I did so when generating the documentation, but forgot when generating the source bundle).

Your bug report for our code is always welcome. But for this report, since we are
fully aware the code is incomplete, I am closing it to avoid confusion. In future, we
will be careful not to include incomplete code in the release.

Thanks.

[email protected] said, at 2009-12-23T12:08:14.000Z:

Hi Qiang, Thanks for the clarification.

CActiveFinder memory leak

What steps will reproduce the problem?

  1. Create two model classes(T1 and T2), and add a relation(T1->T2)
  2. Do some T2::model()->with('t1s')->findAll();
  3. The memory usage grows(too much) even if you don't store the results

The test controller, the two model classes and the database SQL are attached.

What is the expected output? What do you see instead?

The memory usage should not change too much.

Instead of this in a 30 steps iteration(actionTest method):

Memory usage(emalloc/real): 1 906 860 / 2 097 152
Memory usage(emalloc/real): 6 033 812 / 6 553 600
Memory usage(emalloc/real): 8 223 364 / 8 912 896
Memory usage(emalloc/real): 10 365 480 / 11 010 048
Memory usage(emalloc/real): 12 606 692 / 13 107 200
Memory usage(emalloc/real): 14 749 884 / 15 466 496
Memory usage(emalloc/real): 16 893 104 / 17 563 648
Memory usage(emalloc/real): 19 036 284 / 19 660 800
Memory usage(emalloc/real): 21 377 860 / 22 020 096
Memory usage(emalloc/real): 23 523 956 / 24 117 248
Memory usage(emalloc/real): 25 670 428 / 26 476 544
Memory usage(emalloc/real): 27 817 060 / 28 573 696
Memory usage(emalloc/real): 29 963 944 / 30 670 848
Memory usage(emalloc/real): 32 110 996 / 32 768 000
Memory usage(emalloc/real): 34 258 140 / 35 127 296
Memory usage(emalloc/real): 36 833 808 / 38 010 880
Memory usage(emalloc/real): 39 016 576 / 39 845 888
Memory usage(emalloc/real): 41 199 520 / 41 943 040
Memory usage(emalloc/real): 43 382 536 / 44 302 336
Memory usage(emalloc/real): 45 564 276 / 46 399 488
Memory usage(emalloc/real): 47 747 116 / 48 758 784
Memory usage(emalloc/real): 49 929 600 / 50 855 936
Memory usage(emalloc/real): 52 113 196 / 52 953 088
Memory usage(emalloc/real): 54 296 264 / 55 312 384
Memory usage(emalloc/real): 56 480 360 / 57 409 536
Memory usage(emalloc/real): 58 664 120 / 59 768 832
Memory usage(emalloc/real): 60 846 224 / 61 865 984
Memory usage(emalloc/real): 63 029 520 / 63 963 136
Memory usage(emalloc/real): 65 213 268 / 66 322 432
Memory usage(emalloc/real): 67 397 152 / 68 419 584
Memory usage(emalloc/real): 70 368 012 / 71 827 456

What version of the product are you using? On what operating system?

Yii 1.0.11 r1579, but I've tested with 1.1rc r1585 and the problem still
exists.

Migrated from http://code.google.com/p/yii/issues/detail?id=780


earlier comments

qiang.xue said, at 2010-01-05T02:08:34.000Z:

@sebastián: could you help with this? We need to reproduce the issue first.

mazan.robert said, at 2010-01-05T10:19:50.000Z:

The whole VirtualBox image can be downloaded from here: http://www.ritek.hu/letoltesek/yii/TurnKey.vdi.zip

It runs PHP + MySQL + Apache + XDebug.

Just set network type to bridged in the VirtualBox config, and you can use it
immediately.

If you need xdebug you need to configure it to your needs of course.

mazan.robert said, at 2010-01-05T10:24:17.000Z:

I've almost forgot:

User: root
Password: xxx111

sebathi said, at 2010-01-05T18:18:47.000Z:

What version of PHP do you use?

mazan.robert said, at 2010-01-06T08:25:40.000Z:

5.2.4-2ubuntu5.9

But you can access the whole running configuration in the VirtualBox image I
mentioned before.

sebathi said, at 2010-01-12T04:06:12.000Z:

PHP has a bug with its garbage collector that is fixed in PHP 5.3.0+ (http://bugs.php.net/bug.php?id=33595)

We tried this and this is the output with PHP 5.3.1:

Memory usage(emalloc/real): 1 990 432 / 2 097 152
Memory usage(emalloc/real): 3 798 152 / 3 932 160
Memory usage(emalloc/real): 4 244 704 / 4 456 448
Memory usage(emalloc/real): 6 095 472 / 6 553 600
Memory usage(emalloc/real): 7 982 416 / 8 388 608
Memory usage(emalloc/real): 9 804 704 / 10 223 616
Memory usage(emalloc/real): 5 508 368 / 8 126 464
Memory usage(emalloc/real): 7 330 904 / 8 126 464
Memory usage(emalloc/real): 9 155 008 / 9 699 328
Memory usage(emalloc/real): 5 658 656 / 10 485 760
Memory usage(emalloc/real): 7 481 800 / 10 485 760
Memory usage(emalloc/real): 9 300 728 / 10 485 760
Memory usage(emalloc/real): 5 663 256 / 11 796 480
Memory usage(emalloc/real): 7 491 440 / 11 796 480
Memory usage(emalloc/real): 9 293 840 / 11 796 480
Memory usage(emalloc/real): 5 662 008 / 11 796 480
Memory usage(emalloc/real): 7 492 128 / 11 796 480
Memory usage(emalloc/real): 9 307 104 / 11 796 480
Memory usage(emalloc/real): 5 648 376 / 11 796 480
Memory usage(emalloc/real): 7 466 144 / 11 796 480
Memory usage(emalloc/real): 9 288 336 / 11 796 480
Memory usage(emalloc/real): 11 072 808 / 11 796 480
Memory usage(emalloc/real): 5 689 952 / 12 582 912
Memory usage(emalloc/real): 7 484 480 / 12 582 912
Memory usage(emalloc/real): 9 273 416 / 12 582 912
Memory usage(emalloc/real): 5 682 088 / 12 582 912
Memory usage(emalloc/real): 7 500 888 / 12 582 912
Memory usage(emalloc/real): 9 304 448 / 12 582 912
Memory usage(emalloc/real): 5 663 912 / 12 582 912
Memory usage(emalloc/real): 7 478 064 / 12 582 912
Memory usage(emalloc/real): 9 300 792 / 12 582 912

It seems there is no memory leak because the memory usage stays flat after certain
point. As we know, the internal logging will take some memory. The new version
implements the auto message flushing feature, which may explain why the memory no
longer increases.

mazan.robert said, at 2010-01-12T08:11:26.000Z:

Thanks for investigation, you've helped a lot!

keyboard.idol said, at 2010-01-12T15:38:35.000Z:

Funny to see how the "PHP team" selected a new namespace operator in a quick irc session but to fix this bug they needed 3 years... *SCNR*

alexander.makarow said, at 2010-06-15T22:29:36.000Z:

Should be solved by http://code.google.com/p/yii/source/detail?r=2196

Possible unserialize() error in CWebUser

What steps will reproduce the problem?

  1. Switch on $enableCookieValidation of the request component.
  2. Switch on $allowAutoLogin of the user component.
  3. Login a user and make sure a cookie is set ($duration > 0)
  4. Disable $enableCookieValidation in the config.
  5. Reload the page and make sure something like
    Yii::app()->user->getIsGuest() gets called.

What is the expected output?

Yii::app()->user->getIsGuest() should either return true or false.


What do you see instead?

PHP Error
Beschreibung

unserialize() [<a href='function.unserialize'>function.unserialize</a>]:
Error at offset 0 of 89 bytes
Quelldatei

Y:\xampplite\htdocs\Example.com\yii\framework\web\auth\CWebUser.php(323)

00311: * Populates the current user object with the information
obtained from cookie.
00312: * This method is used when automatic login ({@link
allowAutoLogin}) is enabled.
00313: * The user identity information is recovered from cookie.
00314: * Sufficient security measures are used to prevent cookie data
from being tampered.
00315: * @see saveToCookie
00316: */
00317: protected function restoreFromCookie()
00318: {
00319: $app=Yii::app();
00320:
$cookie=$app->getRequest()->getCookies()->itemAt($this->getStateKeyPrefix());
00321: if($cookie && !empty($cookie->value) &&
($data=$app->getSecurityManager()->validateData($cookie->value))!==false)
00322: {
00323: $data=unserialize($data);
00324: if(isset($data[0],$data[1],$data[2],$data[3]))
00325: {
00326: list($id,$name,$duration,$states)=$data;
00327: $this->changeIdentity($id,$name,$states);
00328: if($this->autoRenewCookie)
00329: {
00330: $cookie->expire=time()+$duration;
00331:
$app->getRequest()->getCookies()->add($cookie->name,$cookie);
00332: }
00333: }
00334: }
00335: }


What version of the product are you using? On what operating system?

Using Latest from trunk on Windows/PHP 5.3


Since a cookie is stored client-side and may be valid for a long time, I
suggest to change the above error-line to:

$data=@unserialize($data);

Otherwise a user may get an error when $enableCookieValidation property
gets changed in a production environment.

Migrated from http://code.google.com/p/yii/issues/detail?id=776


earlier comments

a.jilkin said, at 2010-01-01T18:50:30.000Z:

using of @ is not good idea, because it can cause problems in future w/o any output

keyboard.idol said, at 2010-01-01T23:49:24.000Z:

Normally I don't use @ at all, but in this case I see no other solution. What you mean with "problems in future w/o any output"?

keyboard.idol said, at 2010-01-11T17:06:12.000Z:

Also take a look at this: http://www.suspekt.org/2009/12/09/advisory-032009-piwik-cookie-unserialize-vulnerability/

As far as I can tell there is no Yii class that is vulnerable. Still, 3rd party
extension could be. Look how Piwik was fixed: http://dev.piwik.org/trac/changeset/1637

I think it would be good to apply such a preg_match to all core components in order
to make sure no objects are "created" by an unserialized cookie. Or optional
implement it into CHttpRequest/CSecurityManager in some way so that all cookies are safe?

a.jilkin said, at 2010-01-17T21:04:47.000Z:

"problems in future w/o any output" -- I mean, that using of @ will block all errors, warnings and notices

also I know, that unserialize() has a problem with UTF strings
(http://www.php.net/manual/en/function.unserialize.php#93606)

qiang.xue said, at 2010-02-20T03:17:22.000Z:

This issue was closed by revision r1831.

CHttpRequest.sendFile invalid Content-Length when output_handler is ob_gzhandler

The content length in header will be larger than the real size of the data
sent if gzip(or some other output buffer handler) is enabled.

In my opinion in this case the Content-Length part of the header should be
omitted.

So in CHttpRequest sendFile() method:

header('Content-Length: '.strlen($content));

should be replaced with:

if (strlen(ini_get("output_handler")) == 0)
header('Content-Length: '.strlen($content));

Migrated from http://code.google.com/p/yii/issues/detail?id=788


earlier comments

qiang.xue said, at 2010-01-05T02:05:46.000Z:

@sebastián: could you take a look at this? Please double check to make sure this IS an issue. Thanks.

qiang.xue said, at 2010-02-19T21:47:21.000Z:

This issue was closed by revision r1822.

Can't change criteria from behaviour's beforeFind() when using with()

public function beforeFind($event) {
$criteria = $this->getOwner()->getDbCriteria();
// only find models with status = 0
$criteria->addCondition('status = 0');
}

there are two use cases:

  1. $articles = Article::model()->find($criteria);
  2. $articles = Article::model()->with($withOption)->find($criteria);

In both cases beforeFind() is triggered but in the second case criteria
changes
are not applied.

Migrated from http://code.google.com/p/yii/issues/detail?id=730


earlier comments

qiang.xue said, at 2009-12-15T16:01:10.000Z:

This issue was closed by revision r1591.

alexander.makarow said, at 2009-12-15T17:07:01.000Z:

Confirmed. Works.

Premature end of data in tag definitions in SoapClient

I am using SoapClient to get wsdl generated by CWebService.

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://example.com/service/remote' : Premature end of data in tag
definitions line 2

This error connected with this bug http://bugs.php.net/bug.php?id=49226

I have found solution using comments on php.net page.

Line header('Content-Length: '.strlen($wsdl)); have to add in renderWsdl()
method of CWebService.

Migrated from http://code.google.com/p/yii/issues/detail?id=731


earlier comments

qiang.xue said, at 2009-12-17T22:13:32.000Z:

This issue was closed by revision r1597.

qiang.xue said, at 2012-02-15T18:36:31.000Z:

Migrated to http://github.com//issues/10

add function: CUploadedFile::setName()

this api function, can modify the uploaded's name,
is usual to upload the "chinese" filename file, we can dynamic to modify
the filename will be save into database

add code on line: 191

[php]
public function setName($value)
{
$this->_name = $value;
}
[/php]

our controller code sample:
[php]
if(isset($_POST['Pack']))
{
unset($_POST['Pack']['pack_img']);

$pack_img = CUploadedFile::getInstance($model, 'pack_img');

if(! is_null($pack_img))
{
    $pack_img-&gt;name =

md5(Yii::app()->name.$pack_img->name.time()).'.'.$pack_img->extensionName;
$model->pack_img = $pack_img;
}

$model-&gt;attributes = $_POST['Pack'];

if($model-&gt;save())
{
    if(! is_null($pack_img))

$pack_img->saveAs(Html::frontMediaPath('upload/packimg/'.$pack_img->name));
$this->redirect(array('.'));
}
}
[/php]

our model code:
[php]
array('pack_img', 'file', 'types'=>'jpg, gif, png', 'allowEmpty'=>true),
[/php]

Migrated from http://code.google.com/p/yii/issues/detail?id=793


earlier comments

qiang.xue said, at 2010-01-07T22:24:16.000Z:

Why not generate the name when you call saveAs()? The name property of CUploadedFile represents the name of the file on the user's machine. Conceptually, we should not allow this to be changed because it doesn't make sense.

raphael.klein said, at 2010-06-23T15:38:15.000Z:

Actually, something like CUploadedFile::setName() would be quiet useful. Even if you save the file choosing a custom filename with CUploadedFile::saveAs(), the (file)name saved to the Database still is the original file-name of the user's machine - which has no use at all anymore since the file was saved with a different name.

This simple code leads to the problem:

$model->file = CUploadedFile::getInstance($model, 'file');
if($model->save())
{
if( $model->file!=null and !$model->file->getHasError())
{
$model->file->saveAs('/myfolder/'.'file.ext');
}
$this->redirect(array('view','id'=>$model->id));
}

after this the filenames are like this:
original filename on users machine: myfile.ext
newly created file on the server: file.ext
filename saved to the database on the server: myfile.ext (!)

because the filename saved to the database does not match the file on the server there is no working reference.

Of course one could easily avoid or fix this problem, yet the behavior of CUploadedFile in this case just does not seem right.

blindmoe said, at 2010-06-30T23:24:00.000Z:

I would love to see this added as well. The only thing I can think of to get around this problem is to essentially save the record, then use ->saveAs to save the thumbnail with a new name, then reload the model, update the filename column with the new name and then resave it. This is a waste of resources but I cannot think of another way to do this.

blindmoe said, at 2010-06-30T23:31:23.000Z:

I found a small work-around. You have to use the ->saveAs() method of the CUploadedFile object _before_ you call $model->save(). This will save the file even if the model doesn't save correctly, but if your rules are setup right then this should not be a problem.

Here is a quick example:

$model->attributes=$_POST['UserAvatars'];

if (CUploadedFile::getInstance($model,'filename')) {
$model->filename=CUploadedFile::getInstance($model,'filename');
$newfname = Yii::app()->user->id . '-' . $model->filename;
$model->filename->saveAs(dirname(Yii::app()->request->scriptFile) . '/assets/uploads/avatars/' . $newfname);
$model->filename = $newfname;
}

if($model->save()) {

You will probably want to incorporate a timestamp as well as or instead of the user's id just in case the user uploads two images with the same name.

Ron9.GOL said, at 2010-07-23T12:41:48.000Z:

$model->image=CUploadedFile::getInstance($model,'image');

        if($model->validate())
        {
            $name = mt_rand(000000000, 999999999).'.png';
            $model->image->saveAs(Yii::app()->params['pathToAssortimentImages'].$name);
            $model->image = $name;
            if($model->save(false))
            {
                $this->redirect(array('admin'));
            }
            else @unlink(Yii::app()->params['pathToAssortimentImages'].$name);
        }</p><p><strong>qiang.xue said, at 2012-02-15T18:36:24.000Z:</strong></p>

Migrated to http://github.com//issues/2

SQL - url query problems.

What steps will reproduce the problem?

$db=Yii::app()->db;
$id = Yii::app()->user->id;
$page = Yii::app()->getRequest()->getUrl();
$sql="UPDATE table SET page=:page, time=:time WHERE id=:id";

$cmd = $db->createCommand($sql);
$cmd->bindParam(":page", $page, PDO::PARAM_STR);
$cmd->bindParam(":time",time(),PDO::PARAM_INT);
$cmd->bindParam(":id", $id, PDO::PARAM_INT);
$cmd->execute();

What is the expected output? What do you see instead?

It should write the values in the database. The time value was updated all
the time, but the page value should be e.g.
"/project/index.php?r=module/user/show&user=kenci", but it has been saved
as "/project/". On Firefox 3.5 all works fine, but this issue happens only
on Internet Explorer 8!?

What version of the product are you using? On what operating system?
Yii-1.1rc, PHP 5.2.9, Windows Xp Pro, XAMPP 1.7.1

Migrated from http://code.google.com/p/yii/issues/detail?id=761


earlier comments

qiang.xue said, at 2009-12-25T17:09:46.000Z:

Are you saying that Yii::app()->getRequest()->getUrl() returns different values for different browsers? I couldn't reproduce this issue.

coxxirani said, at 2009-12-25T22:47:45.000Z:

No, Yii::app()->getRequest()->getUrl() returns allways the same value "/project/index.php?r=module/user/show&user=kenci".

If i save this into the mySQL database, on IE8(IE7) it allways writes "/project/" in
the page column. On Firefox, Safari, it writes
"/project/index.php?r=module/user/show&user=kenci" as it should be.

I really dont know why.

coxxirani said, at 2009-12-25T23:39:29.000Z:

Now i have done this:

$sql="INSERT INTO table (id, time, page) VALUES (:id, :time, :page)";
$cmd = $db->createCommand($sql);
$cmd->bindParam(":time",time(),PDO::PARAM_INT);
$cmd->bindParam(":page", $page, PDO::PARAM_STR);
$cmd->bindParam(":id", rand(0, 200), PDO::PARAM_INT);
$cmd->execute();

So it creates me an random "id" value. If i execute this code in IE it writes two
rows, one with '/project/', one with 'project/index.php?r=module/user/show&user=kenci'.

On Firefox it writes one column with
'project/index.php?r=module/user/show&user=kenci'. Really strange.

qiang.xue said, at 2009-12-26T02:36:10.000Z:

It seems in IE, the same action is executed twice. Try to enable file-based logging and verify this.

Anyway, this should not be a problem of SQL query.

coxxirani said, at 2009-12-26T10:20:20.000Z:

##On Internet Explorer## 2009/12/26 11:16:01 [trace] [system.db.CDbConnection] Opening DB connection 2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Executing SQL: UPDATE table SET time=:time, page=:page WHERE id=:id. Bind with parameter :time=[integer], :page=[string], :id=[string] 2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM `users` 2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE `users` 2009/12/26 11:16:01 [trace] [system.db.ar.CActiveRecord] Users.find() 2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `users` WHERE username=:username LIMIT 1. Bind with parameter :username='kenci' 2009/12/26 11:16:01 [trace] [system.db.CDbConnection] Opening DB connection 2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Executing SQL: UPDATE table SET time=:time, page=:page WHERE id=:id. Bind with parameter :time=[integer], :page=[string], :id=[string]

On Firefox

2009/12/26 11:16:40 [trace] [system.db.CDbConnection] Opening DB connection
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Executing SQL: UPDATE table SET
time=:time, page=:page WHERE id=:id. Bind with parameter :time=[integer],
:page=[string], :id=[string]
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM
users
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE
users
2009/12/26 11:16:40 [trace] [system.db.ar.CActiveRecord] Users.find()
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM
users WHERE username=:username LIMIT 1. Bind with parameter :username='kenci'

coxxirani said, at 2009-12-26T10:41:49.000Z:

I have found out that this has to do something with the html code. http://bugs.php.net/bug.php?id=19326

I used the Yii 'classic' theme, and now it updates the row only one time.

Possible unserialize() error in CWebUser

What steps will reproduce the problem?

  1. Switch on $enableCookieValidation of the request component.
  2. Switch on $allowAutoLogin of the user component.
  3. Login a user and make sure a cookie is set ($duration > 0)
  4. Disable $enableCookieValidation in the config.
  5. Reload the page and make sure something like
    Yii::app()->user->getIsGuest() gets called.

What is the expected output?

Yii::app()->user->getIsGuest() should either return true or false.


What do you see instead?

PHP Error
Beschreibung

unserialize() [<a href='function.unserialize'>function.unserialize</a>]:
Error at offset 0 of 89 bytes
Quelldatei

Y:\xampplite\htdocs\Example.com\yii\framework\web\auth\CWebUser.php(323)

00311: * Populates the current user object with the information
obtained from cookie.
00312: * This method is used when automatic login ({@link
allowAutoLogin}) is enabled.
00313: * The user identity information is recovered from cookie.
00314: * Sufficient security measures are used to prevent cookie data
from being tampered.
00315: * @see saveToCookie
00316: */
00317: protected function restoreFromCookie()
00318: {
00319: $app=Yii::app();
00320:
$cookie=$app->getRequest()->getCookies()->itemAt($this->getStateKeyPrefix());
00321: if($cookie && !empty($cookie->value) &&
($data=$app->getSecurityManager()->validateData($cookie->value))!==false)
00322: {
00323: $data=unserialize($data);
00324: if(isset($data[0],$data[1],$data[2],$data[3]))
00325: {
00326: list($id,$name,$duration,$states)=$data;
00327: $this->changeIdentity($id,$name,$states);
00328: if($this->autoRenewCookie)
00329: {
00330: $cookie->expire=time()+$duration;
00331:
$app->getRequest()->getCookies()->add($cookie->name,$cookie);
00332: }
00333: }
00334: }
00335: }


What version of the product are you using? On what operating system?

Using Latest from trunk on Windows/PHP 5.3


Since a cookie is stored client-side and may be valid for a long time, I
suggest to change the above error-line to:

$data=@unserialize($data);

Otherwise a user may get an error when $enableCookieValidation property
gets changed in a production environment.

Migrated from http://code.google.com/p/yii/issues/detail?id=776


earlier comments

a.jilkin said, at 2010-01-01T18:50:30.000Z:

using of @ is not good idea, because it can cause problems in future w/o any output

keyboard.idol said, at 2010-01-01T23:49:24.000Z:

Normally I don't use @ at all, but in this case I see no other solution. What you mean with "problems in future w/o any output"?

keyboard.idol said, at 2010-01-11T17:06:12.000Z:

Also take a look at this: http://www.suspekt.org/2009/12/09/advisory-032009-piwik-cookie-unserialize-vulnerability/

As far as I can tell there is no Yii class that is vulnerable. Still, 3rd party
extension could be. Look how Piwik was fixed: http://dev.piwik.org/trac/changeset/1637

I think it would be good to apply such a preg_match to all core components in order
to make sure no objects are "created" by an unserialized cookie. Or optional
implement it into CHttpRequest/CSecurityManager in some way so that all cookies are safe?

a.jilkin said, at 2010-01-17T21:04:47.000Z:

"problems in future w/o any output" -- I mean, that using of @ will block all errors, warnings and notices

also I know, that unserialize() has a problem with UTF strings
(http://www.php.net/manual/en/function.unserialize.php#93606)

qiang.xue said, at 2010-02-20T03:17:22.000Z:

This issue was closed by revision r1831.

qiang.xue said, at 2012-02-15T18:36:28.000Z:

Migrated to http://github.com//issues/6

CEmailValidator must also validate uppercase characters

What steps will reproduce the problem?

  1. Use an e-mail validator rule.
  2. Use addresses that contain uppercase characters before the @ character.
  3. Validation fails.

I'm using 1.0.11 in Linux and Windows.

I'm not sure if there's a RFC or something similar that mandates that e-
mail addresses should only contain lowercase characters. At work, we are
using e-mails in the form [email protected], where the first character is
the initial character from the first name and the part after the . and
before the @ is the last name (first character uppercase).

Migrated from http://code.google.com/p/yii/issues/detail?id=742


earlier comments

yii%[email protected] said, at 2009-12-17T16:45:40.000Z:

I'm attaching a patch to fix this.

qiang.xue said, at 2009-12-17T21:39:17.000Z:

This issue was closed by revision r1593.

yii%[email protected] said, at 2009-12-17T21:46:12.000Z:

Thanks for fixing this Qiang. You were quick.

APC mget() error

cache->mget() with APC driver, APC return array with only stored values =>
we get array_combine() error: "Both parameters should have an equal number
of elements"

CApcCache.php:
protected function getValues($keys)
{
-- return array_combine($keys,apc_fetch($keys));
++ return apc_fetch($keys);
}

Migrated from http://code.google.com/p/yii/issues/detail?id=843


earlier comments

qiang.xue said, at 2010-02-01T21:17:45.000Z:

This issue was closed by revision r1784.

Relations generated incorrectly when table prefix is used

What steps will reproduce the problem?

if you have two tables etc test_user and test_profile

then try to generate corresponding models like

model Tuser user

model TProfile profile

the relations generated will look like this:

for user

    return array(
        'test_profile' =&gt; array(self::HAS_ONE, 

'TestProfile', 'userId'),
);

and like this for profile

    return array(
        'user' =&gt; array(self::BELONGS_TO, 'TestUser', 

'userId'),
);

as you can see, the model names specified in the relations are incorrect,
they should be TUser and TProfile, also the relation name in user should
be 'profile' and not test_profile.

I'm using the latest code from the svn on windows XP sp3 with php 5.3.1
and mysql 5.1

Migrated from http://code.google.com/p/yii/issues/detail?id=745


earlier comments

waprave said, at 2009-12-30T04:19:51.000Z:

Any chance you can have a look at this soon?

qiang.xue said, at 2009-12-30T04:59:58.000Z:

This is expected since the related class name is deducted solely from the table name. It has no knowledge of your previously generated model classes. You will need to manually fix the generated code.

Remove square brackets from generated crud views

Can we remove the square brackets in the actionBar menu for automatically
generated crud views? The first thing I do with every app is go through
and manually delete them - the actionBar can be nicely styled with CSS -
there's no need for hardcoded styling.

Migrated from http://code.google.com/p/yii/issues/detail?id=756


earlier comments

qiang.xue said, at 2009-12-24T01:47:58.000Z:

Please refer to http://www.yiiframework.com/doc/cookbook/41/ on how to customize the code generator to fit for your needs.

SQLite default value for integer incorrect when NULL

I discussed this problem in a forum thread:
http://www.yiiframework.com/forum/index.php?/topic/6105-default-
values-0-and-null-in-ar/

Basically, when an integer field is specified with DEFAULT NULL, the default
value of the attribute in the corresponding CActiveRecord is 0 instead of NULL.
According to someone else in the forum thread, this issue doesn't occur when
using MySQL.

Migrated from http://code.google.com/p/yii/issues/detail?id=741


earlier comments

qiang.xue said, at 2009-12-17T21:58:06.000Z:

I couldn't reproduce the issue. The default value is correctly loaded by the schema as a null.

sanderb said, at 2009-12-18T10:02:41.000Z:

Hmm. Well, something strange is going on. I have a model based on this table (command generated by SQLite itself):

CREATE TABLE relation (
"relation_id" INTEGER PRIMARY KEY NOT NULL,
"relation_type_id" INTEGER NOT NULL,
"active_entity_id" INTEGER NOT NULL,
"passive_entity_id" INTEGER NOT NULL,
"annotation_entity_id" INTEGER DEFAULT NULL)

Then, this code:

attributes); ?>

outputs the following:

array (
'annotation_entity_id' => 0,
'relation_id' => NULL,
'relation_type_id' => NULL,
'active_entity_id' => NULL,
'passive_entity_id' => NULL,
)

I tried completely blanking out all the class methods to ensure I didn't accidentally
overwrite anything. It didn't help. I tried dropping/re-adding the column, and
dropping/re-adding the entire table. Nothing seems to work..

I'm using 1.1rc, by the way. Can you reproduce anything similar with this info?

qiang.xue said, at 2009-12-18T12:12:16.000Z:

will check again. Thanks.

sanderb said, at 2009-12-18T12:49:08.000Z:

Meh, I just found out the problem was with the app I used for DB management. It actually wrote the string 'NULL' as default value for the column, which I guess when transformed to an integer would result in 0. Sorry for wasting your time.

Make CUrlManager better extendable

Currently it's not possible to access CUrlManager::$_rules because it's a
private property. I suggest to make it a protected property or add special
methods in order to access the private property.

The actual problem is for example when passing a fresh array of rules to
CUrlManager::$rules and then call the protected method
CUrlManager::processRules(), the already compiled rules are still active
and working. There should be a way to have access to the already compiled
rules - complex, preloaded components will benefit.

Thanks.

Migrated from http://code.google.com/p/yii/issues/detail?id=766


earlier comments

qiang.xue said, at 2009-12-29T13:36:54.000Z:

I don't see the needs for cleaning up existing compiled rules. Could you please elaborate the scenario in which you need this support?

keyboard.idol said, at 2009-12-29T19:39:25.000Z:

As you can see in my other ticket (http://code.google.com/p/yii/issues/detail?id=767), I have problems generating independent url's when the route (controller/action) is the same. To solve this problem in my custom I18n component, I parse out specific rules in order to make it work. See attached file in createUrl() method were I create a new urlManager instance instead of just using Yii::app()->urlMananager. With a protected $_rules property I could just backup the original compiled rules, proccess the temporary rules + create the url and then set back the original compiled rules.

I really think this is an important feature, especially for any preloaded component
that has to do with dynamic loading of url rules.

qiang.xue said, at 2009-12-29T19:59:47.000Z:

I just added CUrlManager::createUrlRule(). Now you can write your own url rule class to support more advanced/customized url creation/parsing.

We usually only change private variables to protected or public per user request with
sufficient reasons. We may choose to refactor the code, instead, if that works better.

keyboard.idol said, at 2009-12-29T20:39:19.000Z:

A good step to make things more extendable. Thanks!

typo error "It can be customized via CController::getViewPath."

I suppose id should be:
CController::viewPath
and it's just a typo

Migrated from http://code.google.com/p/yii/issues/detail?id=734


earlier comments

qiang.xue said, at 2009-12-17T22:09:52.000Z:

Which file are you referring to?

PKrawczak said, at 2009-12-17T22:24:22.000Z:

http://www.yiiframework.com/doc/guide/basics.convention

"WebRoot/protected/views/ControllerID: this directory holds view files for a single
controller class. Here ControllerID stands for the ID of the controller. It can be
customized via CController::getViewPath."

Nothing can be customized with a getter method. (it's so minor error that I feel
guilty for reporting it almost)

qiang.xue said, at 2009-12-18T02:20:35.000Z:

This issue was closed by revision r1600.

CJavaScript::quote

What steps will reproduce the problem?

  1. go to http://validator.aborla.net/
  2. validate http://www.yiiframework.com/demos/blog/index.php/site/contact
  3. 94 line

"</" should be escaped in JS with backslash, with end result like "</"

Yii Framework 1.0.11

Fix is simple:

1)class CJavaScript
2)public static function quote
3)add additional array element ( '</'=>'</' ) for second array ( $forUrl
== false )

Migrated from http://code.google.com/p/yii/issues/detail?id=832


earlier comments

qiang.xue said, at 2010-02-01T21:12:11.000Z:

This issue was closed by revision r1783.

CHttpRequest.sendFile invalid Content-Length when output_handler is ob_gzhandler

The content length in header will be larger than the real size of the data
sent if gzip(or some other output buffer handler) is enabled.

In my opinion in this case the Content-Length part of the header should be
omitted.

So in CHttpRequest sendFile() method:

header('Content-Length: '.strlen($content));

should be replaced with:

if (strlen(ini_get("output_handler")) == 0)
header('Content-Length: '.strlen($content));

Migrated from http://code.google.com/p/yii/issues/detail?id=788


earlier comments

qiang.xue said, at 2010-01-05T02:05:46.000Z:

@sebastián: could you take a look at this? Please double check to make sure this IS an issue. Thanks.

qiang.xue said, at 2010-02-19T21:47:21.000Z:

This issue was closed by revision r1822.

qiang.xue said, at 2012-02-15T18:36:26.000Z:

Migrated to http://github.com//issues/4

findByPk() should bind its argument

I noticed that (at least with the SQLite driver), queries generated by
CActiveRecord::findByPk() aren't prepared with a bound parameter. Since a
primary key is typically something that is passed to an app via the query
string, doing something like this will be potentially vulnerable to SQL
injections:

SomeClass::model()->findByPk($_GET['id']);

I think it would be a good idea to use parameter binding here in order to
avoid this problem.

(I also posted this in the bug forum but I'm not sure it'll get noticed there, so I
copied it here.)

Migrated from http://code.google.com/p/yii/issues/detail?id=744


earlier comments

qiang.xue said, at 2009-12-29T18:11:27.000Z:

It is fine because internally, the value is properly escaped to avoid SQL injection.

Zii Grid CRudColumn does not support csrf

What steps will reproduce the problem?

  1. Turn CHttpRequest::enableCsrfValidation on.
  2. Use the Zii grid widget to manage an admin page.
  3. Create a CRudColumn using
    array(
    'class'=>'CRudColumn',
    'deleteButtonOptions'=>array('class'=>'delete','csrf'=>true)
    ),
  4. Try to delete an item.

What is the expected output? What do you see instead?
Expect the item to be deleted using the CSRF token.
Instead, you get an error "The CSRF token could not be verified".

What version of the product are you using?
yii-1.1rc.r1585

Please provide any additional information below.
I have attached a diff file that fixes the issue. Please review and update
accordingly. Thanks.

Migrated from http://code.google.com/p/yii/issues/detail?id=733


earlier comments

qiang.xue said, at 2009-12-16T15:32:53.000Z:

You may enclose the whole grid with CHtml::beginForm() and endForm(). This will generate the needed CSRF token.

scythah said, at 2009-12-16T15:39:49.000Z:

Ok, thanks.

Missing structure of tables witch are used by CDbAuthManager

I cant find initial structures for tables witch are used in CDbAuthManager
(assignmentTable, itemChildTable and itemTable) in Yii giude...

I may only be so blind and cant find it, but i think it should be shown in
Authentication and Authorization Sepecial Topic of giude

cheers, and sorry for bad english
canni

Migrated from http://code.google.com/p/yii/issues/detail?id=749


earlier comments

qiang.xue said, at 2009-12-19T22:40:35.000Z:

It's described here: http://www.yiiframework.com/doc/api/CDbAuthManager

CAuthManager don't use table prefix feature from db component

What steps will reproduce the problem?

  1. configure default values for assigmentTable, itemChildTable and
    itemtable, without table prefix defined in db component

What is the expected output? What do you see instead?
authManager should chceck if db component have tablePrefix defined, and add
it to table names

What version of the product are you using? On what operating system?
1.1b

Migrated from http://code.google.com/p/yii/issues/detail?id=751


earlier comments

darek.krk said, at 2009-12-21T14:06:53.000Z:

Little mistake, not CAuthManager, but CDbAuthManager

darek.krk said, at 2009-12-21T19:47:24.000Z:

Partial (Unclear, but without rewriting all sql query in object) resolve of this issuie is to add this 3 lines to init() method of CDbAuthManager:

$this->itemTable = $this->getDbConnection()->tablePrefix.$this->itemTable;
$this->itemChildTable = $this->getDbConnection()->tablePrefix.$this->itemChildTable;
$this->assignmentTable = $this->getDbConnection()->tablePrefix.$this->assignmentTable;

Or we can rewrite all query definitions in object, to use not {$this->tableName} but
{{$this->tableName}} this should take native tablePrefix functionality bring to work?
(didn't checked this)

waprave said, at 2010-01-06T21:27:08.000Z:

You can do this in your config file if you want to avoid editing the framework.

'authManager'=>array(
'class'=>'CDbAuthManager',
'itemTable'=>'{{AuthItem}}',
'itemChildTable'=>'{{AuthItemChild}}',
'assignmentTable'=>'{{AuthAssignment}}',
...
),

qiang.xue said, at 2010-01-09T19:40:14.000Z:

Please use the workaround suggested by waprave. It would be very cumbersome to respect the table prefix in every component that needs a table.

add function: CUploadedFile::setName()

this api function, can modify the uploaded's name,
is usual to upload the "chinese" filename file, we can dynamic to modify
the filename will be save into database

add code on line: 191

[php]
public function setName($value)
{
$this->_name = $value;
}
[/php]

our controller code sample:
[php]
if(isset($_POST['Pack']))
{
unset($_POST['Pack']['pack_img']);

$pack_img = CUploadedFile::getInstance($model, 'pack_img');

if(! is_null($pack_img))
{
    $pack_img-&gt;name =

md5(Yii::app()->name.$pack_img->name.time()).'.'.$pack_img->extensionName;
$model->pack_img = $pack_img;
}

$model-&gt;attributes = $_POST['Pack'];

if($model-&gt;save())
{
    if(! is_null($pack_img))

$pack_img->saveAs(Html::frontMediaPath('upload/packimg/'.$pack_img->name));
$this->redirect(array('.'));
}
}
[/php]

our model code:
[php]
array('pack_img', 'file', 'types'=>'jpg, gif, png', 'allowEmpty'=>true),
[/php]

Migrated from http://code.google.com/p/yii/issues/detail?id=793


earlier comments

qiang.xue said, at 2010-01-07T22:24:16.000Z:

Why not generate the name when you call saveAs()? The name property of CUploadedFile represents the name of the file on the user's machine. Conceptually, we should not allow this to be changed because it doesn't make sense.

raphael.klein said, at 2010-06-23T15:38:15.000Z:

Actually, something like CUploadedFile::setName() would be quiet useful. Even if you save the file choosing a custom filename with CUploadedFile::saveAs(), the (file)name saved to the Database still is the original file-name of the user's machine - which has no use at all anymore since the file was saved with a different name.

This simple code leads to the problem:

$model->file = CUploadedFile::getInstance($model, 'file');
if($model->save())
{
if( $model->file!=null and !$model->file->getHasError())
{
$model->file->saveAs('/myfolder/'.'file.ext');
}
$this->redirect(array('view','id'=>$model->id));
}

after this the filenames are like this:
original filename on users machine: myfile.ext
newly created file on the server: file.ext
filename saved to the database on the server: myfile.ext (!)

because the filename saved to the database does not match the file on the server there is no working reference.

Of course one could easily avoid or fix this problem, yet the behavior of CUploadedFile in this case just does not seem right.

blindmoe said, at 2010-06-30T23:24:00.000Z:

I would love to see this added as well. The only thing I can think of to get around this problem is to essentially save the record, then use ->saveAs to save the thumbnail with a new name, then reload the model, update the filename column with the new name and then resave it. This is a waste of resources but I cannot think of another way to do this.

blindmoe said, at 2010-06-30T23:31:23.000Z:

I found a small work-around. You have to use the ->saveAs() method of the CUploadedFile object _before_ you call $model->save(). This will save the file even if the model doesn't save correctly, but if your rules are setup right then this should not be a problem.

Here is a quick example:

$model->attributes=$_POST['UserAvatars'];

if (CUploadedFile::getInstance($model,'filename')) {
$model->filename=CUploadedFile::getInstance($model,'filename');
$newfname = Yii::app()->user->id . '-' . $model->filename;
$model->filename->saveAs(dirname(Yii::app()->request->scriptFile) . '/assets/uploads/avatars/' . $newfname);
$model->filename = $newfname;
}

if($model->save()) {

You will probably want to incorporate a timestamp as well as or instead of the user's id just in case the user uploads two images with the same name.

Ron9.GOL said, at 2010-07-23T12:41:48.000Z:

$model->image=CUploadedFile::getInstance($model,'image');

        if($model->validate())
        {
            $name = mt_rand(000000000, 999999999).'.png';
            $model->image->saveAs(Yii::app()->params['pathToAssortimentImages'].$name);
            $model->image = $name;
            if($model->save(false))
            {
                $this->redirect(array('admin'));
            }
            else @unlink(Yii::app()->params['pathToAssortimentImages'].$name);
        }</p>

CDbCriteria::addColumnCondition incorrectly handles NULL value

$criteria->addColumnCondition(array('someCol'=>null));
SomeClass::model()->count($criteria);

Generates the query:

SELECT count(*) FROM 'Table' WHERE somecol=:ycp0

And binds NULL to :ycp0. While this query doesn't fail (at least not in
SQLite), it generates an incorrect result, I believe it always returns 0 rows.

My fix looks like this:

public function
addColumnCondition($columns,$columnOperator='AND',$operator='AND')
{
$params=array();
foreach($columns as $name=>$value)
{
if($value===null)
$params[]=$name.' IS NULL';
else
{
$params[]=$name.'='.self::PARAM_PREFIX.$this-
>_paramCount;
$this->params[self::PARAM_PREFIX.$this-
>_paramCount++]=$value;
}
}
return $this->addCondition(implode(" $columnOperator
",$params), $operator);
}

Migrated from http://code.google.com/p/yii/issues/detail?id=740


earlier comments

qiang.xue said, at 2009-12-17T22:02:13.000Z:

This issue was closed by revision r1595.

sanderb said, at 2009-12-18T09:06:59.000Z:

Thanks. I assume this will also be merged into 1.1 later?

Doc error: guide test.functional.txt

What is the expected output?
"the functional test file may be stored"

What do you see instead?
"the unit test file may be stored"

Please provide any additional information below.
Third paragraph in the file.

Also, I recall this: in test.unit.txt there is a "straightfoward" instead
of "straightforward".

Migrated from http://code.google.com/p/yii/issues/detail?id=759


earlier comments

triboe said, at 2009-12-24T19:35:47.000Z:

Also in both files mentioned there is the word "wherer" instead of "where".

qiang.xue said, at 2010-01-02T13:24:54.000Z:

This issue was closed by revision r1648.

about the framework application paht

hi,qiang,
我在使用yiic创建的application框架,感觉生成的路径名称有点乱:

├─assets
│ └─f0bd997
│ ├─autocomplete
│ ├─rating
│ ├─treeview
│ │ └─images
│ └─yiitab
├─css
├─images
├─protected
│ ├─commands
│ │ └─shell
│ ├─components
│ │ └─views
│ ├─config
│ ├─controllers
│ ├─extensions
│ ├─messages
│ ├─models
│ ├─runtime
│ └─views
│ ├─layouts
│ ├─mytest
│ ├─site
│ ├─system
│ └─user
└─themes
└─classic
└─views
├─layouts
├─site
└─system

如果改成这样:

├─app << 原来是 protected
│ ├─commands
│ │ └─shell
│ ├─components
│ │ └─views
│ ├─config
│ ├─controllers
│ ├─extensions
│ ├─messages
│ ├─models
│ ├─runtime
│ └─views
│ ├─layouts
│ ├─mytest
│ ├─site
│ ├─system
│ └─user

├─www << 新建,把protected 目录以外的 www相关的都放到 www目录下
│ │
│ ├─assets
│ │ └─f0bd997
│ │ ├─autocomplete
│ │ ├─rating
│ │ ├─treeview
│ │ │ └─images
│ │ └─yiitab
│ ├─css
│ ├─images
│ └─themes
│ └─classic
│ └─views
│ ├─layouts
│ ├─site
│ └─system

这样的话,所有通过web访问的静态资源文件,都放在 www目录下,其他php应用程序都在 app目录下,感觉这样就更清楚明白。

个人建议,仅供参考。

Migrated from http://code.google.com/p/yii/issues/detail?id=765


earlier comments

qiang.xue said, at 2009-12-29T13:38:32.000Z:

你这样的路径yii是支持的,你只要在main.php里指明basePath即可。

Super minor error!

From the Definitive Guide:

What is Yii

Yii is a high-performance component-based PHP framework for developing
large-scale Web applications. It enables maximum reusability in Web
programming and can significantly accelerate the development process. The
name Yii (pronounced as Yee or [ji:]) stands for easy, efficient and
extensible.

But in the Project Home in Google Code:

Yii is a high-performance programming framework for developing Web
applications in PHP 5. It enables maximum reusability in Web programming
and can significantly accelerate the development process. The name Yii
(pronounced as i:) stands for easy, efficient and extensible.

Note that the pronunciation is different!
I know that is irrelevant... but...

Migrated from http://code.google.com/p/yii/issues/detail?id=739


earlier comments

qiang.xue said, at 2009-12-17T22:03:48.000Z:

Thanks.

LoginForm.php is missing a rememberMe rule

What steps will reproduce the problem?

  1. Using either the example code (blog) or generated code through yiic, try
    login in and checking "Remember me" checkbox.
  2. Close the website
  3. Go to the website again, and you will be logged out

What is the expected output? What do you see instead?
Expected is to still be logged in for 30 days. Instead we are logged out.

What version of the product are you using? On what operating system?
Yii 1.1b

Please provide any additional information below.
See http://www.yiiframework.com/forum/index.php?/topic/5884-allowautologin/
In rules() in LoginForm.php, a line is missing:
array('rememberMe','boolean'),

Migrated from http://code.google.com/p/yii/issues/detail?id=724


earlier comments

w3b0id3 said, at 2009-12-12T14:18:28.000Z:

The milestone needs to be changed to the last yii 1.1 milestone.

qiang.xue said, at 2009-12-12T17:48:31.000Z:

This issue was closed by revision r1577.

Premature end of data in tag definitions in SoapClient

I am using SoapClient to get wsdl generated by CWebService.

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://example.com/service/remote' : Premature end of data in tag
definitions line 2

This error connected with this bug http://bugs.php.net/bug.php?id=49226

I have found solution using comments on php.net page.

Line header('Content-Length: '.strlen($wsdl)); have to add in renderWsdl()
method of CWebService.

Migrated from http://code.google.com/p/yii/issues/detail?id=731


earlier comments

qiang.xue said, at 2009-12-17T22:13:32.000Z:

This issue was closed by revision r1597.

CActiveFinder memory leak

What steps will reproduce the problem?

  1. Create two model classes(T1 and T2), and add a relation(T1->T2)
  2. Do some T2::model()->with('t1s')->findAll();
  3. The memory usage grows(too much) even if you don't store the results

The test controller, the two model classes and the database SQL are attached.

What is the expected output? What do you see instead?

The memory usage should not change too much.

Instead of this in a 30 steps iteration(actionTest method):

Memory usage(emalloc/real): 1 906 860 / 2 097 152
Memory usage(emalloc/real): 6 033 812 / 6 553 600
Memory usage(emalloc/real): 8 223 364 / 8 912 896
Memory usage(emalloc/real): 10 365 480 / 11 010 048
Memory usage(emalloc/real): 12 606 692 / 13 107 200
Memory usage(emalloc/real): 14 749 884 / 15 466 496
Memory usage(emalloc/real): 16 893 104 / 17 563 648
Memory usage(emalloc/real): 19 036 284 / 19 660 800
Memory usage(emalloc/real): 21 377 860 / 22 020 096
Memory usage(emalloc/real): 23 523 956 / 24 117 248
Memory usage(emalloc/real): 25 670 428 / 26 476 544
Memory usage(emalloc/real): 27 817 060 / 28 573 696
Memory usage(emalloc/real): 29 963 944 / 30 670 848
Memory usage(emalloc/real): 32 110 996 / 32 768 000
Memory usage(emalloc/real): 34 258 140 / 35 127 296
Memory usage(emalloc/real): 36 833 808 / 38 010 880
Memory usage(emalloc/real): 39 016 576 / 39 845 888
Memory usage(emalloc/real): 41 199 520 / 41 943 040
Memory usage(emalloc/real): 43 382 536 / 44 302 336
Memory usage(emalloc/real): 45 564 276 / 46 399 488
Memory usage(emalloc/real): 47 747 116 / 48 758 784
Memory usage(emalloc/real): 49 929 600 / 50 855 936
Memory usage(emalloc/real): 52 113 196 / 52 953 088
Memory usage(emalloc/real): 54 296 264 / 55 312 384
Memory usage(emalloc/real): 56 480 360 / 57 409 536
Memory usage(emalloc/real): 58 664 120 / 59 768 832
Memory usage(emalloc/real): 60 846 224 / 61 865 984
Memory usage(emalloc/real): 63 029 520 / 63 963 136
Memory usage(emalloc/real): 65 213 268 / 66 322 432
Memory usage(emalloc/real): 67 397 152 / 68 419 584
Memory usage(emalloc/real): 70 368 012 / 71 827 456

What version of the product are you using? On what operating system?

Yii 1.0.11 r1579, but I've tested with 1.1rc r1585 and the problem still
exists.

Migrated from http://code.google.com/p/yii/issues/detail?id=780


earlier comments

qiang.xue said, at 2010-01-05T02:08:34.000Z:

@sebastián: could you help with this? We need to reproduce the issue first.

mazan.robert said, at 2010-01-05T10:19:50.000Z:

The whole VirtualBox image can be downloaded from here: http://www.ritek.hu/letoltesek/yii/TurnKey.vdi.zip

It runs PHP + MySQL + Apache + XDebug.

Just set network type to bridged in the VirtualBox config, and you can use it
immediately.

If you need xdebug you need to configure it to your needs of course.

mazan.robert said, at 2010-01-05T10:24:17.000Z:

I've almost forgot:

User: root
Password: xxx111

sebathi said, at 2010-01-05T18:18:47.000Z:

What version of PHP do you use?

mazan.robert said, at 2010-01-06T08:25:40.000Z:

5.2.4-2ubuntu5.9

But you can access the whole running configuration in the VirtualBox image I
mentioned before.

sebathi said, at 2010-01-12T04:06:12.000Z:

PHP has a bug with its garbage collector that is fixed in PHP 5.3.0+ (http://bugs.php.net/bug.php?id=33595)

We tried this and this is the output with PHP 5.3.1:

Memory usage(emalloc/real): 1 990 432 / 2 097 152
Memory usage(emalloc/real): 3 798 152 / 3 932 160
Memory usage(emalloc/real): 4 244 704 / 4 456 448
Memory usage(emalloc/real): 6 095 472 / 6 553 600
Memory usage(emalloc/real): 7 982 416 / 8 388 608
Memory usage(emalloc/real): 9 804 704 / 10 223 616
Memory usage(emalloc/real): 5 508 368 / 8 126 464
Memory usage(emalloc/real): 7 330 904 / 8 126 464
Memory usage(emalloc/real): 9 155 008 / 9 699 328
Memory usage(emalloc/real): 5 658 656 / 10 485 760
Memory usage(emalloc/real): 7 481 800 / 10 485 760
Memory usage(emalloc/real): 9 300 728 / 10 485 760
Memory usage(emalloc/real): 5 663 256 / 11 796 480
Memory usage(emalloc/real): 7 491 440 / 11 796 480
Memory usage(emalloc/real): 9 293 840 / 11 796 480
Memory usage(emalloc/real): 5 662 008 / 11 796 480
Memory usage(emalloc/real): 7 492 128 / 11 796 480
Memory usage(emalloc/real): 9 307 104 / 11 796 480
Memory usage(emalloc/real): 5 648 376 / 11 796 480
Memory usage(emalloc/real): 7 466 144 / 11 796 480
Memory usage(emalloc/real): 9 288 336 / 11 796 480
Memory usage(emalloc/real): 11 072 808 / 11 796 480
Memory usage(emalloc/real): 5 689 952 / 12 582 912
Memory usage(emalloc/real): 7 484 480 / 12 582 912
Memory usage(emalloc/real): 9 273 416 / 12 582 912
Memory usage(emalloc/real): 5 682 088 / 12 582 912
Memory usage(emalloc/real): 7 500 888 / 12 582 912
Memory usage(emalloc/real): 9 304 448 / 12 582 912
Memory usage(emalloc/real): 5 663 912 / 12 582 912
Memory usage(emalloc/real): 7 478 064 / 12 582 912
Memory usage(emalloc/real): 9 300 792 / 12 582 912

It seems there is no memory leak because the memory usage stays flat after certain
point. As we know, the internal logging will take some memory. The new version
implements the auto message flushing feature, which may explain why the memory no
longer increases.

mazan.robert said, at 2010-01-12T08:11:26.000Z:

Thanks for investigation, you've helped a lot!

keyboard.idol said, at 2010-01-12T15:38:35.000Z:

Funny to see how the "PHP team" selected a new namespace operator in a quick irc session but to fix this bug they needed 3 years... *SCNR*

alexander.makarow said, at 2010-06-15T22:29:36.000Z:

Should be solved by http://code.google.com/p/yii/source/detail?r=2196

qiang.xue said, at 2012-02-15T18:36:23.000Z:

Migrated to http://github.com//issues/1

CActiveRecord::find/find/findbysql and most other finds eat memory

What steps will reproduce the problem?

  1. Do anytype of 'find' over 1500 times and -out of memory- if allowed
    memory=16MB. Specific example is here:
    $model=Account::model()->find('code=:code AND companyId=:companyId',
    array(':code'=>$accountCode,':companyId'=> $companyId));
  2. Have tried all the different find functions in CActiveRecord with the
    same result. Even going to queryScaler does the crash.
    3.

What is the expected output? What do you see instead?
The error I get is typically(varies):
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to
allocate 72 bytes) in /var/www/yii/framework/db/CDbCommand.php on line 115

What version of the product are you using? On what operating system?
1.10 RC 1 January 1

Please provide any additional information below.

Migrated from http://code.google.com/p/yii/issues/detail?id=781


earlier comments

qiang.xue said, at 2010-01-03T01:37:09.000Z:

Please try it with higher memory limit, such as 32MB. The size 16MB is a bit small if you have enabled many PHP extensions. We have tested the similar function call before without observing any memory leak issue.

dormlock said, at 2010-01-03T02:19:27.000Z:

If your using i think it was XAMPP on Mac OS X there was a bug that would cause this type of problem. I was going to convert my windows and mac development servers to XAMPP before I discovered the bug in the Mac version. increasing the memory didn't help and the problem was actually related to the memory for threads in MySQL. You could change the memory allocated to the threads but the value was never respected and seemed to have a hard coded value it used.

alexander.makarow said, at 2010-06-15T22:29:45.000Z:

Should be solved by http://code.google.com/p/yii/source/detail?r=2196

qiang.xue said, at 2012-02-15T18:36:29.000Z:

Migrated to http://github.com//issues/7

Wron LT localization

Index: lt_lt.php

--- lt_lt.php (revision 1586)
+++ yii\framework\i18n\data\lt_lt.php (working copy)
@@ -308,8 +308,8 @@
),
'wide' =>
array (

  •  0 =&gt; 'prieš Kristus',
    
  •  1 =&gt; 'po Kristus',
    
  •  0 =&gt; 'prieš Kristų',
    
  •  1 =&gt; 'po Kristaus',
    
    ),
    'narrow' =>
    array (

    Migrated from http://code.google.com/p/yii/issues/detail?id=725


    earlier comments

    qiang.xue said, at 2009-12-13T20:22:14.000Z:

    Which version are you referring to?

    projektas said, at 2009-12-13T20:24:30.000Z:

    revision 1586 I was looking in latest svn repository

    qiang.xue said, at 2009-12-13T20:28:47.000Z:

    The data you saw is obtained from CLDR project. We can't change it because we don't have the expertise and if we change it, it would cause big trouble when we upgrade it in future. Thanks.

Can't change criteria from behaviour's beforeFind() when using with()

public function beforeFind($event) {
$criteria = $this->getOwner()->getDbCriteria();
// only find models with status = 0
$criteria->addCondition('status = 0');
}

there are two use cases:

  1. $articles = Article::model()->find($criteria);
  2. $articles = Article::model()->with($withOption)->find($criteria);

In both cases beforeFind() is triggered but in the second case criteria
changes
are not applied.

Migrated from http://code.google.com/p/yii/issues/detail?id=730


earlier comments

qiang.xue said, at 2009-12-15T16:01:10.000Z:

This issue was closed by revision r1591.

alexander.makarow said, at 2009-12-15T17:07:01.000Z:

Confirmed. Works.

qiang.xue said, at 2012-02-15T18:36:30.000Z:

Migrated to http://github.com//issues/9

CDbCriteria::addInCondition() return null on non empty array

What steps will reproduce the problem?
1.Create a new CDbCriteria
$item = new CdbCriteria;
$Items = $model->findAll($item->addInCondition('id',array(2 => 7)))

What is the expected output? What do you see instead?
in this case $item->addInCondition return 'IS NULL'
findAll return empty array

What version of the product are you using? On what operating system?
Ubuntu 8.04 LTS
lighttpd/1.4.19
PHP Version 5.2.4-2ubuntu5.9
yii-1.0.11
Firefox/3.0.16

Please provide any additional information below.
My patch

public function addInCondition($column,$values,$operator='AND')
{
if(($n=count($values))<1)
return $this->addCondition('0=1',$operator);
if($n===1)
{
+++ $value=array_values($values);
--- if($values[0]===null)
+++ if($value[0]===null)
return $this->addCondition($column.' IS NULL');
$condition=$column.'='.self::PARAM_PREFIX.$this->_paramCount;
--- $this->params[self::PARAM_PREFIX.$this->_paramCount++]=$values[0];
+++ $this->params[self::PARAM_PREFIX.$this->_paramCount++]=$value[0];
}
else
...

Migrated from http://code.google.com/p/yii/issues/detail?id=757


earlier comments

qiang.xue said, at 2010-02-01T21:46:44.000Z:

This issue was closed by revision r1786.

qiang.xue said, at 2012-02-15T18:36:27.000Z:

Migrated to http://github.com//issues/5

Parameterizing Hostnames subfolder bug

What steps will reproduce the problem?

  1. Create a Yii blog inside a subfolder (www.example.com/blog)
  2. Use CUrlManager with a Parameterizing Hostnames
    ('http://<user:\w+>.example.com/<lang:\w+>/profile' => 'user/profile',)
  3. Notice you don't need the subfolder inside the rule

What is the expected output? What do you see instead?
You should be able to add the subfolder
(http://<user:\w+>.example.com/blog/<lang:\w+>/profile). It's not working
this way. Otherwise, you should highly warn on the documentation you only
use the address without the subfolder!!!

What version of the product are you using? On what operating system?
Last stable version (1.0.11) on Windows XP, Apache 2 and Firefox

Please provide any additional information below.

Migrated from http://code.google.com/p/yii/issues/detail?id=786


earlier comments

qiang.xue said, at 2010-01-07T22:19:38.000Z:

This issue was closed by revision r1680.

CListView YII version 1.1

Using the 'zii.widgets.grid.CListView' widget generate an arror.
That was fixed by moving the file "CListView.php" from the /widget/ folder
to its /grid/ subfolder .

I am new on yii, and i have a question, i was wondering what part of the
version 1.1 is considered as "STABLE" so far?
And what is not backward compatible in the 1.1 version. For example this:
'condition'=>'tagFilter.name=:tag'),
have replaced this
'condition'=>'??.name=:tag'),

what are all the other compatibilty issues?
i hope you will answer me, because i have 3 website to build on yii in the
next weeks and i have to chose between the 1.0 and the 1.1
Regards

Migrated from http://code.google.com/p/yii/issues/detail?id=769


earlier comments

qiang.xue said, at 2009-12-29T16:12:35.000Z:

This is a documentation error that was already fixed in SVN. Do not move the file. Please check the Guide regarding major BC-breaking changes introduced in 1.1. We plan to release 1.1 formal version in early Jaunary. Since you just start your projects, it should be fine that you go with 1.1.

about enum datatype of crud

What steps will reproduce the problem?

  1. crud command get the 0 size and 0 maxlength input field of mysql .enum
    datatype.

Migrated from http://code.google.com/p/yii/issues/detail?id=656


earlier comments

qiang.xue said, at 2010-01-05T02:10:37.000Z:

@sebastián: could you take care of this? To be honest, I don't know how to deal with this. I think we should treat enum as string type. But what should be the max size?

sebathi said, at 2010-01-05T03:46:02.000Z:

["test"]=> object(CMysqlColumnSchema)#20 (13) { ["name"]=> string(4) "test" ["rawName"]=> string(6) "`test`" ["allowNull"]=> bool(false) ["dbType"]=> string(17) "enum('asd','dsa')" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(0) ["precision"]=> int(0) ["scale"]=> int(0) ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["_e:private"]=> NULL ["_m:private"]=> NULL }

We can use the dbType (enum 'asd', 'dsa') and extend the
extractLimit method in CMysqlColumnSchema with something like this:

protected function extractLimit($dbType)
{
    if ($dbType is enmu){
                 $this->size = 0;
                 foreach($enumPossibilites as $enumOption)
                     $this->size = max($this->size, $enumOption);
            else
                 parent::extractLimit($dbType);
    }

qiang.xue said, at 2010-01-05T13:59:15.000Z:

Is it possible to get $enumPossibilites? If so, I agree with this solution.

sebathi said, at 2010-01-05T14:05:55.000Z:

Yes, the $dbType will be as follows - all the line:

enum('asd', 'test', 'veryLongEnum')

sebathi said, at 2010-01-05T14:24:40.000Z:

Fixed r1664

qiang.xue said, at 2012-02-15T18:36:25.000Z:

Migrated to http://github.com//issues/3

CActiveRecord::find/find/findbysql and most other finds eat memory

What steps will reproduce the problem?

  1. Do anytype of 'find' over 1500 times and -out of memory- if allowed
    memory=16MB. Specific example is here:
    $model=Account::model()->find('code=:code AND companyId=:companyId',
    array(':code'=>$accountCode,':companyId'=> $companyId));
  2. Have tried all the different find functions in CActiveRecord with the
    same result. Even going to queryScaler does the crash.
    3.

What is the expected output? What do you see instead?
The error I get is typically(varies):
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to
allocate 72 bytes) in /var/www/yii/framework/db/CDbCommand.php on line 115

What version of the product are you using? On what operating system?
1.10 RC 1 January 1

Please provide any additional information below.

Migrated from http://code.google.com/p/yii/issues/detail?id=781


earlier comments

qiang.xue said, at 2010-01-03T01:37:09.000Z:

Please try it with higher memory limit, such as 32MB. The size 16MB is a bit small if you have enabled many PHP extensions. We have tested the similar function call before without observing any memory leak issue.

dormlock said, at 2010-01-03T02:19:27.000Z:

If your using i think it was XAMPP on Mac OS X there was a bug that would cause this type of problem. I was going to convert my windows and mac development servers to XAMPP before I discovered the bug in the Mac version. increasing the memory didn't help and the problem was actually related to the memory for threads in MySQL. You could change the memory allocated to the threads but the value was never respected and seemed to have a hard coded value it used.

alexander.makarow said, at 2010-06-15T22:29:45.000Z:

Should be solved by http://code.google.com/p/yii/source/detail?r=2196

PHP5.0 or above codes encrypt

Hi xueqiang,
I use the yii for our web develpment, so I have to update the PHP4.3 to
PHP5.0, but the encrypt code tools only work at PHP4.3.
Do you have some idea about the encrypt code? of cause for free. The
zender gurder need 2000$ each year.

best regards!

Migrated from http://code.google.com/p/yii/issues/detail?id=771


earlier comments

qiang.xue said, at 2009-12-30T04:57:37.000Z:

Sorry, I have no experience with encryption tools. Please discuss this on our forum. Thanks.

about enum datatype of crud

What steps will reproduce the problem?

  1. crud command get the 0 size and 0 maxlength input field of mysql .enum
    datatype.

Migrated from http://code.google.com/p/yii/issues/detail?id=656


earlier comments

qiang.xue said, at 2010-01-05T02:10:37.000Z:

@sebastián: could you take care of this? To be honest, I don't know how to deal with this. I think we should treat enum as string type. But what should be the max size?

sebathi said, at 2010-01-05T03:46:02.000Z:

["test"]=> object(CMysqlColumnSchema)#20 (13) { ["name"]=> string(4) "test" ["rawName"]=> string(6) "`test`" ["allowNull"]=> bool(false) ["dbType"]=> string(17) "enum('asd','dsa')" ["type"]=> string(6) "string" ["defaultValue"]=> NULL ["size"]=> int(0) ["precision"]=> int(0) ["scale"]=> int(0) ["isPrimaryKey"]=> bool(false) ["isForeignKey"]=> bool(false) ["_e:private"]=> NULL ["_m:private"]=> NULL }

We can use the dbType (enum 'asd', 'dsa') and extend the
extractLimit method in CMysqlColumnSchema with something like this:

protected function extractLimit($dbType)
{
    if ($dbType is enmu){
                 $this->size = 0;
                 foreach($enumPossibilites as $enumOption)
                     $this->size = max($this->size, $enumOption);
            else
                 parent::extractLimit($dbType);
    }

qiang.xue said, at 2010-01-05T13:59:15.000Z:

Is it possible to get $enumPossibilites? If so, I agree with this solution.

sebathi said, at 2010-01-05T14:05:55.000Z:

Yes, the $dbType will be as follows - all the line:

enum('asd', 'test', 'veryLongEnum')

sebathi said, at 2010-01-05T14:24:40.000Z:

Fixed r1664

Id's generated for Ajax button/link etc only unique per view

What steps will reproduce the problem?
1.Use CJuiTabs etc.
2.Load different forms with Ajax, and CHtml::ajaxXX() functions

What is the expected output? What do you see instead?
expected: The id's generated for Ajax buttons/links etc are unique. Instead
they are only unique for that view.

What version of the product are you using? On what operating system?
1.1RC

Please provide any additional information below.
Perhaps it is better to generate really unique id's for all generated HTML
code (not just per view), especially when there is a JQuery/HTML part
generated. This saves time defining id's in htmlOptions(), and will give
less debugging hassle when using extensive Ajax renderpartials.

Migrated from http://code.google.com/p/yii/issues/detail?id=762


earlier comments

qiang.xue said, at 2009-12-26T22:47:46.000Z:

The only possible way of using unique IDs across different requests is to use session, which will have side effects that we do not like to see.

I would suggest you use jquery's live() method to attach event handlers. I will
change CHtml accordingly to use live() as well.

maxximus007 said, at 2009-12-26T23:15:08.000Z:

Ok, but was thinking a bit simpler: use something like uniqid('yb_'). Live() will not solve the problem with 2 of the same id's in the DOM I suppose.

qiang.xue said, at 2009-12-27T02:19:23.000Z:

Sorry, I didn't read your issue report carefully. You are right that live() doesn't solve your problem since you are referring to different views.

Yes, uniqid could solve the problem as well, but I'm not sure if it will cause any
side effect. Sometimes, we do hope the ID is unchanged.

vuliad said, at 2009-12-27T09:22:15.000Z:

Why not generate random IDs? 'id'=>mt_rand(...) ?

maxximus007 said, at 2009-12-27T11:05:42.000Z:

If you want the ID to be a fixed one, it's easy to define in htmlOptions(). One should not look at a generated ID, expecting it stays the same.

Sure, it's possible already to add your own unique ID with htmlOptions(), but it took
me several hours finding out why things weren't working as expected. Since it's
generated framework code ppl will look at their own code first, before suspecting FW
code. Just trying to prevent others loosing the same hours in the future.

[email protected] said, at 2010-02-11T09:57:06.000Z:

In cases where the author needs the ID to remain the same it seems that it can always be explicitly set, so I would think that switching to uniqid() would be safe (with some easily fixable breakage for apps that don’t expect it). Worst-case, a parameter could be used to specify whether to use uniqid or the current incremental method, though I would worry that such an option would end up reducing performance for no good reason.

Re comment #4: Random IDs are not the same as unique IDs; uniqid is guaranteed to be
unique, since it is based on time. You could conceivably end up with two identical
values from mt_rand.

Add scenario for afterFind method

Is it possible to add the support of scenarios in afterFind method?
In this case it's possible to realize flexible data post processing for different scenarios.

For example to do additional data processing of gotten data.

$authHistoryList = AuthHistory::model()
->setScenario('admin_list')
->findAll($criteria);

protected function afterFind()
{
if ($this->scenario === 'admin_list') {
// geocoding by IP
$this->country_code = ...
}
return parent::afterFind();
}

What version of the product are you using? On what operating system?
latest 1.1

Migrated from http://code.google.com/p/yii/issues/detail?id=799


earlier comments

qiang.xue said, at 2010-01-08T17:58:25.000Z:

You can do the following: AuthHistory::model()->scenario='admin_list'; AuthHistory::model()->findAll();

in afterFind(), you can check self::model()->scenario (instead of $this->scenario)

victorovsky said, at 2010-01-08T18:50:59.000Z:

Thanks for tip!

victorovsky said, at 2010-09-08T07:47:35.000Z:

Doesn't work in latest yii.

victorovsky said, at 2010-09-08T17:53:34.000Z:

I updated framework and everything works.

CUrlManager::createUrl() does not support multidimensional params

What steps will reproduce the problem?

$url = '?r=controller/action&a[b][c]=&a[r][g]=';
$params['a']['b']['c'] = '';
$params['a']['r']['g'] = '';
$url = $controller->createUrl('controller/action', $params);
echo $url;//should be ?r=controller/action&a%5Bb%5D%5Bc%5D=&a%5Br%5D%5Bg
%5D=
/*but we get

PHP Error
Description

urlencode() expects parameter 1 to be string, array given

web/CUrlManager.php(373)
00364: public function createPathInfo($params,$equal,$ampersand)
00365: {
00366: //$params = self::flattenAssocArray($params);
00367: $pairs=array();
00368: foreach($params as $key=>$value)
00369: {
00370: if(is_array($value))
00371: {
00372: foreach($value as $k=>$v)
00373: $pairs[]=urlencode($key).'['.urlencode($k).']'.
$equal.urlencode($v);
00374: }
00375: else
00376: $pairs[]=urlencode($key).$equal.urlencode($value);
00377: }
00378: return implode($ampersand,$pairs);
00379: }
*/

What version of the product are you using? On what operating system?
yii-1.0.11.r1579 linux

Please provide any additional information below.
Solution is attached. It is generic enough for me for now, but the problem
needs more attention.

Migrated from http://code.google.com/p/yii/issues/detail?id=737


earlier comments

marciodicksmiderle said, at 2009-12-17T13:47:53.000Z:

This issue has to do with http://www.yiiframework.com/forum/index.php?/topic/762-extension-xreturnable- wasideas-for-storage-of-click-path-visited-pages/page__view__findpost__p__27928

qiang.xue said, at 2009-12-24T05:40:10.000Z:

This issue was closed by revision r1614.

isset() && empty() - expression

Regarding the spontaneous code review of revision 1589 I identified 4 more
occurences in the 1.0 branch if you are interested.

[CViewAction.php at line 82]
if(isset($_GET[$this->viewParam]) && !empty($_GET[$this->viewParam]))

[CController.php at line 1041]
if(isset($_POST[self::STATE_INPUT_NAME]) &&
!empty($_POST[self::STATE_INPUT_NAME]))

[CActiveFinder.php at line 256]
if(isset($scopes) && !empty($scopes))

[CLogFilter.php at line 97]
if(isset($GLOBALS[$name]) && !empty($GLOBALS[$name]))

Migrated from http://code.google.com/p/yii/issues/detail?id=729


earlier comments

qiang.xue said, at 2009-12-15T16:06:01.000Z:

This issue was closed by revision r1592.

make the CController PAGE_SIZE constant a property

In a controller class one defines the PAGE_SIZE constant.
I'd like, however, that the user can choose himself how many items he'd
like to see on a page.

Can this constant be replaced by a property?

(I'm using Yii 1.0.11r1579)

Migrated from http://code.google.com/p/yii/issues/detail?id=763


earlier comments

qiang.xue said, at 2009-12-27T02:20:54.000Z:

Sure you can. The code generated by yiic is only meant to be a good starting point. You have full freedom to change the code as you want.

Error in Using Form Builder document

return array(
'user'=>array(
'type'=>'form',
'title'=>'Login information',
'elements'=>array(
'username'=>array(
'type'=>'text',
),
'password'=>array(
'type'=>'password',
),
'email'=>array(
'type'=>'text',
)
),
),

'profile'=&gt;array(
    'type'=&gt;'form',
    'title'=&gt;'Profile information',
    'elements'=&gt;array(
        'firstName'=&gt;array(
            'type'=&gt;'text',
        ),
        'lastName'=&gt;array(
            'type'=&gt;'text',
        ),
    ),
),

'buttons'=&gt;array(
    'register'=&gt;array(
        'type'=&gt;'submit',
        'label'=&gt;'Register',
    ),
),

);

is incorrect. User and Profile need to be sitting inside elements array. I
added a comment in the document to say this, please remove it from the
document comment.

Migrated from http://code.google.com/p/yii/issues/detail?id=754


earlier comments

qiang.xue said, at 2009-12-23T14:09:51.000Z:

This issue was closed by revision r1613.

CDbCriteria::addInCondition() return null on non empty array

What steps will reproduce the problem?
1.Create a new CDbCriteria
$item = new CdbCriteria;
$Items = $model->findAll($item->addInCondition('id',array(2 => 7)))

What is the expected output? What do you see instead?
in this case $item->addInCondition return 'IS NULL'
findAll return empty array

What version of the product are you using? On what operating system?
Ubuntu 8.04 LTS
lighttpd/1.4.19
PHP Version 5.2.4-2ubuntu5.9
yii-1.0.11
Firefox/3.0.16

Please provide any additional information below.
My patch

public function addInCondition($column,$values,$operator='AND')
{
if(($n=count($values))<1)
return $this->addCondition('0=1',$operator);
if($n===1)
{
+++ $value=array_values($values);
--- if($values[0]===null)
+++ if($value[0]===null)
return $this->addCondition($column.' IS NULL');
$condition=$column.'='.self::PARAM_PREFIX.$this->_paramCount;
--- $this->params[self::PARAM_PREFIX.$this->_paramCount++]=$values[0];
+++ $this->params[self::PARAM_PREFIX.$this->_paramCount++]=$value[0];
}
else
...

Migrated from http://code.google.com/p/yii/issues/detail?id=757


earlier comments

qiang.xue said, at 2010-02-01T21:46:44.000Z:

This issue was closed by revision r1786.

hyphens (dash) in table field names cause problem with crud or model or both

What steps will reproduce the problem?

  1. Table has a field name containing a hyphen -
  2. model table name and crud table name
  3. Get blank screen trying to view the table in browser like
    http://localhost/jlf_edu/index.php?r=tLessons. No error messages with
    model or crud but results will not display

What is the expected output? What do you see instead? Expected screen to
add a record or manage. Got blank screen.

What version of the product are you using? On what operating system?
yii-1.1-dev on Ubuntu

Please provide any additional information below.
I had four tables and went through the model crud procedure on all four.
Three would display the proper screen in the browser but the fourth would
not. It had about 20 fields. I reinstalled yii. That did not change
anything. Then i started eliminating fields from the table. Only one field
had hyphens in the field name and it would cause the problem. When I
changed the hyphens to underscores everything worked ok.

Migrated from http://code.google.com/p/yii/issues/detail?id=755


earlier comments

qiang.xue said, at 2009-12-23T17:15:00.000Z:

This is expected because when accessing such column like an object property, PHP code will break. A workaround is to use $object->getAttribute($columnName). However, doing so in the CRUD code generator would make the rest of the code less clean. For this reason, we will not fix the issue. Instead, you should modify the generated CRUD code accordingly (that's also the original intention of code generator.) Thanks.

CDetailView::formatImage() alt-tag

If i set type to image in CDetailView, i cant set the alt text for the image.

array('label'=>'Label', 'value'=>'image url...', 'type'=>'image'),

What version of the product are you using? On what operating system?
1.1rc

Migrated from http://code.google.com/p/yii/issues/detail?id=768


earlier comments

qiang.xue said, at 2009-12-29T14:44:11.000Z:

In this case, you need to use 'type'=>'raw' and set 'value' to be the image tag with alt text.

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.