[fw-general] Zend_Validate_Ip
Hello! I'd like to use Zend_Validate_Ip to check if some input strings are - surprise - valid IP addresses. When I got some problems with strings like 192.168.34 or 192.168.34.234 asdf which evaluated to true, I had a look into apidocs and found: Returns true if and only if $value is a valid IP address Both example strings are not valid IP address, in my oppinion. Internally ip2long is used to do the checking, which accepts a lot more than just valid IP addresses. Is this intended behaviour or is it a bug and may change in the future? Regards -joachim knust
RE: [fw-general] autoloading models
Hello! -Original Message- From: James Dempster [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 18, 2008 11:18 PM To: Simeon Goranov Cc: fw-general@lists.zend.com Subject: Re: [fw-general] autoloading models $frontController = Zend_Controller_Front::getInstance(); $frontController-addModuleDirectory(ROOT_DIR.'/modules/'); As I understand the code in Controller/Front.php addModuleDirectory() only makes the front controller aware of the module's controller directory and has nothing to do with model class autoloading. On Tue, Mar 18, 2008 at 11:55 PM, Simeon Goranov [EMAIL PROTECTED] wrote: application models controllers views modules gallery models controllers views news models controllers views public index.php The questions is - which is the easier way to setup models autoloading from all of the modules and application too. The solutions posted on the list do not solve the problem in my oppinion. My thoughts and experiences: You could load the application models by adding the directory to your include_path. If you have e.g. a class User defined in application/models/User.php, a new User() will work (autoload) without problems. But it gets tricky if you try to do this with your module's models. Let's say you use a naming scheme for your module modles which adopts the one for module controllers: The index controller class for the gallery module would be Gallery_IndexController (in file modules/gallery/controllers/IndexController.php), so a model class could be Gallery_Image (in file modules/gallery/models/Image.php). But if you try new Gallery_Image() this will fail because Zend_Load tries to load gallery/image.php and searches the include_path for this. For this structure to work you need your own class loader wich can resolve your modules' modle directory structure and falls back to Zend_Load if you want to load any none model class. Next problem which will accur on cascading operations (update, delete) is that Zend_Db_Table_Abstract uses Zend_Load::loadClass to load dependent table's modle classes, which fails because Zend_Load doesn't know about module model directories. Same problem prevents the use of findManyToManyRowset() magic methods. Maybe I miss something here and somebody has any smart solutions which might be shared. Regards -joachim knust
[fw-general] interaction problem: Zend_Session::start(), Zend_Loader::isReadable() + custom autoloader
Hi! With the change from ZF 1.0.2 to 1.0.3 I discovered a problem in interaction of Zend_Session::start() and Zend_Loader::isReadable() namely if isReadable() fails during session start. Situation: The app is organized in a conventional modular directory structure (as described in section 7.11 of the reference guide). basedir |-- application | |-- Module1 | | |-- controllers | | | |-- AuthController.php | | | `-- ... | | |-- models | | | |-- Menu.php | | | `-- ... | | `-- views | | `-- scripts ... To autoload the model classes I extended Zend_Loader (18.5) and wrote an own method which searches the proper directory for the file to include (Module1_Menu - Module1/models/Menu.php). Furthermore there is a custom Session_SaveHandler to have the session data managed in a DB. In the read() method of the SaveHandler I use a model class (Module1_Session) to get the session data from. Now the following happens: In the bootstrapper I setup the autoloader: Zend_Loader::registerAutoload('Custom_Loader'); Zend_Session::setSaveHandler(new Custom_Session_SaveHandler()); Zend_Session::start(); I end up with: Zend_Session_Exception: Zend_Session::start() - fopen(Module1/Session.php) [function.fopen]: failed to open stream: No such file or directory in ZendFramework-1.0.3/library/Zend/Session.php on line 380 That's the situation... now my analysis In Zend_Session (line 372) a new error handler is set and than session_start() is called. This calls read() method of Custom_Session_SaveHandler which tries to load Module1_Session to get the session data (new Module1_Session();). While trying to load Module1_Session Zend_Loader::isReadable gets called like this: self::isReadable('Module1/Session.php') which fails and now in the 1.0.3 code because of the new fopen approach (Zend_Loader 194) error level E_WARNING is generated. This is handled by Zend_Session_Exception::handleSessionStartError() which later leads to the Exception from above. I read the mails regarding the performance issues of Zend_Loader::isReadable so maybe it could be a solution to tweak Zend_Session_Exeption to ignore such fopen warnings. Or set_error_handler for E_ERROR only. Because as I understand it the code parts there exist to circumvent: http://framework.zend.com/issues/browse/ZF-1325 At the moment I require Module1/models/Session.php manually, which is is not very smart with an autoloader available. Any hints, comments, etc. welcome Regards -joachim knust