yiic shell problem on pardus

hi,

i have posted a thread like this yesterday however i guess i am not the only one who is encountering this problem since i have tried to use yiic shell on another pardus running computer so i thought maybe there is a bug. the yiic shell command throws the following error:




<!DOCTYPE html PUBLIC                                   

        "-//W3C//DTD XHTML 1.0 Transitional//EN"        

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>                                                             

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>                                                             

CException</title>                                                  


<style type="text/css">

/*<![CDATA[*/          

body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;}

h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }           

h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }        

h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}                         

p {font-family:"Verdana";font-size:9pt;}                                           

pre {font-family:"Lucida Console";font-size:10pt;}                                 

.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}                 

.message {color: maroon;}                                                          

.source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;}

.error {background-color: #ffeeee;}                                                

/*]]>*/                                                                            

</style>                                                                           

</head>                                                                            


<body>

<h1>CException</h1>


<h3>Description</h3>

<p class="message"> 

Property &quot;CWebApplication.import&quot; is not defined.</p>


<h3>Source File</h3>

<p>                 

/var/www/localhost/htdocs/yii/framework/base/CModule.php(431)</p>


<div class="source">

<pre>

00419:         }

00420:     }

00421:

00422:     /**

00423:      * Configures the module with the specified configuration.

00424:      * @param array the configuration array

00425:      */

00426:     public function configure($config)

00427:     {

00428:         if(is_array($config))

00429:         {

00430:             foreach($config as $key=&gt;$value)

<div class="error">00431:                 $this-&gt;$key=$value;

</div>00432:         }

00433:     }

00434:

00435:     /**

00436:      * Loads static application components.

00437:      */

00438:     protected function preloadComponents()

00439:     {

00440:         foreach($this-&gt;preload as $id)

00441:             $this-&gt;getComponent($id);

00442:     }

00443:

</pre>

</div><!-- end of source -->


<h3>Stack Trace</h3>

<div class="callstack">

<pre>

#0 /var/www/localhost/htdocs/yii/framework/base/CModule.php(431): CComponent-&gt;__set('import', Array)

#1 /var/www/localhost/htdocs/yii/framework/base/CApplication.php(117): CModule-&gt;configure(Array)

#2 /var/www/localhost/htdocs/yii/framework/YiiBase.php(81): CApplication-&gt;__construct('/var/www/localh...')

#3 /var/www/localhost/htdocs/blog/index.php(11): YiiBase::createWebApplication('/var/www/localh...')

#4 /var/www/localhost/htdocs/yii/framework/cli/commands/ShellCommand.php(78): require('/var/www/localh...')

#5 /var/www/localhost/htdocs/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand-&gt;run(Array)

#6 /var/www/localhost/htdocs/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner-&gt;run(Array)

#7 /var/www/localhost/htdocs/yii/framework/base/CApplication.php(134): CConsoleApplication-&gt;processRequest()

#8 /var/www/localhost/htdocs/yii/framework/yiic.php(31): CApplication-&gt;run()

#9 /var/www/localhost/htdocs/blog/protected/yiic.php(7): require_once('/var/www/localh...')

#10 /var/www/localhost/htdocs/blog/protected/yiic(4): require_once('/var/www/localh...')

#11 {main}</pre>

</div><!-- end of callstack -->


<div class="version">

2009-09-01 14:38:45 <a href="http://www.yiiframework.com/">Yii Framework</a>/1.0.8</div>

</body>

</html>mengu@mengu-pardus protected $




anyone has any idea why is this happening? i am using php 5.2.10, mysql 5.1 and yii 1.0.8 on a linux distro called pardus. i appreciate any help.

thanks.

will somebody please point me some direction?

well,

it is definitely weird that nobody else has it, but maybe you could hack the code in the CModel (line 431) and put an if(…) statement around it.

I know it’s not pretty, but might work :confused:

–iM

This is very strange. The code in CModule.php line 431 tries to set your configuration and breaks with the key import. It translates to:


$this->import=$value; // Where value is the import array from your config



As import is not a public property of CModule but CModule extends CComponent this will call __set() of CComponent. Here it will check, whether a method setImport exists (line 140). At this place $this should be a CWebApplication and this class does have a method setImport(). Strangely the method_exists() call returns false for you.

You could alter the code in framework/base/CComponent.php:140 and inspect the $this object there. But you should keep a copy of your original file as this is only for debugging purposes.

Somehow i feel like it could be some issue with case sensitivity. But it shouldn’t as PHP is case insensitive with functions.

I tried to help Mengu last night because we have a similar setup (Linux, Yii 1.0.8) and everything was working fine on mine. (The PHP versions were different, though)

Windows doesn’t care about cases, Mac is not case-sensitive by default and Linux is case sensitive.

–iM

i have checked to see the $setter in CComponent.php:140 with an echo statement. the result was:


setimport

setcomponents

setparams

setroutes

these methods are setImport, setComponents, setParams and setRoutes in the class files. so, if it was an issue with case-sensitivity, then it would also would not work on the web since it is working great. i see no errors, no problems. i only get this with yiic shell.

i’d like to see some guidence of the authors as well since i am not the only who’s facing this error on pardus.

CComponent.php:139 should be changed from




               $setter='set'.$name;



to




               $setter='set'.ucfirst($name);



so that it conforms to case sensitivity.

unfortunately that didn’t help when i tried it yesterday before posting my previous post. when i try to access my application via browser, it doesn’t make any difference, it works both as ie. setImport and setimport. but the shell command still provides me that error. i don’t think shell command is calling the __set method. you can see it yourself by adding a simple echo statement to the CComponent.php:139.

however, i have added the following line to CModule.php:431 and got another error.

code:


$key = ($key == "import" ? "Import" : $key);

error:

i’m open to all suggestions. :)

some other notes…

when i use "./protected/yiic shell protected/yiic.php" it got into the shell. and i tried model User and got an error:




Fatal error: Call to a member function getDb() on a non-object in /home/mengu/public_html/yii/framework/cli/commands/shell/ModelCommand.php on line 246



i only get this in the shell. ./protected/yiic shell index.php still providing me this error:




Fatal error: Couldn't find implementation for method CList::getiterator in Unknown on line 0



would this be a permission error?

PHP can be configured differently for webserver and command line. This seems to be the reason for your problems. Try this and compare the output in phpinof.txt to that of your webservers PHP version:


php  -r 'phpinfo();' > phpinfo.txt

why do i get this error "Fatal error: Call to a member function getDb() on a non-object in /home/mengu/public_html/yii/framework/cli/commands/shell/ModelCommand.php on line 246" when i use ./protected/yiic shell protected/yiic.php for model User despite the fact that the database is set?

Have you tried the above? You have serious issues with a lot of missing methods in classes. It’s always the same error: Missing a method that should be there. That has nothing to do with permissions etc. It’s a PHP problem…

sorry, i forgot to mention it in my previous post. yes, i have tried and there wasn’t that difference from what i saw.

but, i also have tried something.

i have added the following method to /web/CWebApplication.php and it is the exact copy of setImport method in CModule.php:200.




public function setimport($aliases)

        {

            foreach($aliases as $alias)

			Yii::import($alias);

        }



the full error i get is:

It doesn’t make much sense to copy these methods. You need to find out why method_exists() in CComponent returns false even though the methods definitely exist. That’s the main reason for all your problems.

Mike, it doesn’t even call __set() method. i have added an echo statement to __set() method to test but there was nothing.

Ok, well at least it did in your first post. But as i said: There must be something seriously wrong with your PHP as it doesn’t find any class methods that must be there. Maybe a PHP bug?

Can you try to do some simple tests in a custom php script? I would try to build some test class, extend it, and try to call the inherited methods from the child class. This seem to make problems in your setup with the CLI version of PHP. Never seen such behavior.

the error “Fatal error: Couldn’t find implementation for method CList::getiterator in Unknown on line 0” is an error for permission issues. any ideas on where CList::getiterator is being called?

Why do you think it’s a permission issue? getIterator is part of PHP’s IteratorAggregate interface. Any object from a class that implements this interface can be used in a loop (foreach, etc.). CList implements this interface. That’s why it can be used like an array in loops.

It’s still the same issue here: getIterator() does exist but PHP complains that it can’t find this method.

well, the following code is working.




<?php


class A

{

	function sayHello() {}

	

}


class B extends A

{

	function sayGoodBye() {}

}


class C extends B

{

	function checkMethod()

	{

		var_dump(method_exists($this, 'sayHello')); // returns bool(true)

		var_dump(method_exists($this, 'sayhello')); // returns bool(true)

	}

}


$c = new C();

$c->checkMethod();


?>




please let me know if there’s anything to add.

The interesting cases are:


$c->sayHello();

$c->sayhello();