Re: [fw-general] Zend_Form addElementPrefixPath disables Zend Validators

2008-07-02 Thread KyleMac

OK, I think I fixed it by logging from Zend_Loader::isReadable() to find out
what was wrong, but it makes no sense.

Basically, my custom validators folder cannot be called "Validate", anything
but "Validate" works, because somehow "Validate/" seems to be being mapped
to "Zend/Validate/" and is opening a successful stream to
Zend/Validate/StringLength.php before it has gotten to the Zend_Validate
$prefix, but that's impossible with my include paths.

get_include_paths() from inside Zend_Loader:isReadable() returns:
.;../lib;../app/models;../app/forms

So how does it successfully open "Validate/StringLength.php" when the path
required to that file is "Zend/Validate/StringLength.php"? Weird.


Matthew Weier O'Phinney-3 wrote:
> 
> -- KyleMac <[EMAIL PROTECTED]> wrote
> (on Wednesday, 02 July 2008, 02:12 PM -0700):
>> 
>> Here's a pastebin: http://pastebin.com/m75ddcc6b
>> 
>> BaseForm usually contains my standard decorators and so on, but I've
>> removed
>> all that to try and find the problem. AlnumExtra is my custom validator.
> 
> The problem is in your BaseForm class -- you never call
> parent::__construct(), and so the default paths are never setup
> correctly. Move that functionality into init(), and have your extending
> classes call parent::init() at the start of their init() methods.
> 
>> The case sensitivity problem is what I brought up here and exists in
>> 1.5+:
>> http://www.nabble.com/Mixed-case-controller-names-spaces-in-controller-names-to16886114.html#a16907959
>> 
>> Zend_Controller has been built on the assumption that PHP is case
>> sensitive
>> with class names, but PHP is not. Zend_Controller is in fact relying on
>> case
>> sensitivity from the file system, which NTFS doesn't have. So with ZF
>> 1.5+
>> on a Window servers, both /privacy-policy and /privacypolicy will load
>> the
>> PrivacyPolicyController.php but will fail loading the view folder.
> 
> So use /privacy-policy in the URL and not /privacypolicy. The second
> should map to PrivacypolicyController.php anyways, which should fail to
> load as class names are case SENSITIVE.
> 
> The easiest fix for case sensitivity is to use the appropriate URLs.
> 
> 
>> Matthew Weier O'Phinney-3 wrote:
>> > 
>> > -- KyleMac <[EMAIL PROTECTED]> wrote
>> > (on Wednesday, 02 July 2008, 01:20 PM -0700):
>> >> I just can't get custom validators to work properly. I want to be able
>> >> to use the validators in addElement with the shorthand name, i.e. just
>> >> "Regex".
>> >> 
>> >> The closet I can get to them working is:
>> >> 
>> >> $form->addElementPrefixPath('KM_Validate', 'Validate/',
>> >> Zend_Form_Element::VALIDATE);
>> >> 
>> >> But now none of the Zend validators work, for example: 'File
>> >> NotEmpty.php was loaded but class named KM_Validate_NotEmpty was not
>> >> found within it.' So it is still looking in Zend/Validate but is not
>> >> trying the correct class prefix.
>> > 
>> > Can you provide the full form definition, possibly in a pastebin
>> > somewhere? There are tests for this exact situation, and I've written
>> > applications and tutorials that do exactly this without any problems.
>> My
>> > inclination is that there is something else in your form definition
>> > causing problems.
>> > 
>> >> PS. Is the case sensitivity problem in Zend_Controller on NTFS going
>> >> to be fixed? If my production server ran Windows I'd consider it a
>> >> show stopper.
>> > 
>> > What case sensitivity issue are you referring to?
>> > 
>> > -- 
>> > Matthew Weier O'Phinney
>> > Software Architect   | [EMAIL PROTECTED]
>> > Zend Framework   | http://framework.zend.com/
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Zend_Form-addElementPrefixPath-disables-Zend-Validators-tp18245929p18246899.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect   | [EMAIL PROTECTED]
> Zend Framework   | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-addElementPrefixPath-disables-Zend-Validators-tp18245929p18248789.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form addElementPrefixPath disables Zend Validators

2008-07-02 Thread KyleMac

I tried what you said and it didn't work. I simplified it further and cut out
BaseForm and it still doesn't work: http://pastebin.com/m6568fed1


Also, class names are case INSENSITIVE. Try it out for yourself:

";
}
}

$test = new Test();
$test2 = new test();
?>

That will come out "hello hello".

Here's a recent bug post for PHP 5.2.5: http://bugs.php.net/bug.php?id=44676

[9 Apr 7:35am UTC] [EMAIL PROTECTED]
> PHP is not case sensitive about classes names.
> 
> class foo{} 
> $a = new FOO();

Now, I do use "/privacy-policy" as the url, but "/privacypolicy" will throw
a Zend_View_Exception instead of
Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER, which would
allow you to display your normal 404 page. It's not even a problem for me
since my staging and production servers are Linux, but don't deny that
there's a bug.


Matthew Weier O'Phinney-3 wrote:
> 
> -- KyleMac <[EMAIL PROTECTED]> wrote
> (on Wednesday, 02 July 2008, 02:12 PM -0700):
>> 
>> Here's a pastebin: http://pastebin.com/m75ddcc6b
>> 
>> BaseForm usually contains my standard decorators and so on, but I've
>> removed
>> all that to try and find the problem. AlnumExtra is my custom validator.
> 
> The problem is in your BaseForm class -- you never call
> parent::__construct(), and so the default paths are never setup
> correctly. Move that functionality into init(), and have your extending
> classes call parent::init() at the start of their init() methods.
> 
>> The case sensitivity problem is what I brought up here and exists in
>> 1.5+:
>> http://www.nabble.com/Mixed-case-controller-names-spaces-in-controller-names-to16886114.html#a16907959
>> 
>> Zend_Controller has been built on the assumption that PHP is case
>> sensitive
>> with class names, but PHP is not. Zend_Controller is in fact relying on
>> case
>> sensitivity from the file system, which NTFS doesn't have. So with ZF
>> 1.5+
>> on a Window servers, both /privacy-policy and /privacypolicy will load
>> the
>> PrivacyPolicyController.php but will fail loading the view folder.
> 
> So use /privacy-policy in the URL and not /privacypolicy. The second
> should map to PrivacypolicyController.php anyways, which should fail to
> load as class names are case SENSITIVE.
> 
> The easiest fix for case sensitivity is to use the appropriate URLs.
> 
> 
>> Matthew Weier O'Phinney-3 wrote:
>> > 
>> > -- KyleMac <[EMAIL PROTECTED]> wrote
>> > (on Wednesday, 02 July 2008, 01:20 PM -0700):
>> >> I just can't get custom validators to work properly. I want to be able
>> >> to use the validators in addElement with the shorthand name, i.e. just
>> >> "Regex".
>> >> 
>> >> The closet I can get to them working is:
>> >> 
>> >> $form->addElementPrefixPath('KM_Validate', 'Validate/',
>> >> Zend_Form_Element::VALIDATE);
>> >> 
>> >> But now none of the Zend validators work, for example: 'File
>> >> NotEmpty.php was loaded but class named KM_Validate_NotEmpty was not
>> >> found within it.' So it is still looking in Zend/Validate but is not
>> >> trying the correct class prefix.
>> > 
>> > Can you provide the full form definition, possibly in a pastebin
>> > somewhere? There are tests for this exact situation, and I've written
>> > applications and tutorials that do exactly this without any problems.
>> My
>> > inclination is that there is something else in your form definition
>> > causing problems.
>> > 
>> >> PS. Is the case sensitivity problem in Zend_Controller on NTFS going
>> >> to be fixed? If my production server ran Windows I'd consider it a
>> >> show stopper.
>> > 
>> > What case sensitivity issue are you referring to?
>> > 
>> > -- 
>> > Matthew Weier O'Phinney
>> > Software Architect   | [EMAIL PROTECTED]
>> > Zend Framework   | http://framework.zend.com/
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Zend_Form-addElementPrefixPath-disables-Zend-Validators-tp18245929p18246899.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect   | [EMAIL PROTECTED]
> Zend Framework   | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-addElementPrefixPath-disables-Zend-Validators-tp18245929p18247625.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form addElementPrefixPath disables Zend Validators

2008-07-02 Thread KyleMac

Here's a pastebin: http://pastebin.com/m75ddcc6b

BaseForm usually contains my standard decorators and so on, but I've removed
all that to try and find the problem. AlnumExtra is my custom validator.


The case sensitivity problem is what I brought up here and exists in 1.5+:
http://www.nabble.com/Mixed-case-controller-names-spaces-in-controller-names-to16886114.html#a16907959

Zend_Controller has been built on the assumption that PHP is case sensitive
with class names, but PHP is not. Zend_Controller is in fact relying on case
sensitivity from the file system, which NTFS doesn't have. So with ZF 1.5+
on a Window servers, both /privacy-policy and /privacypolicy will load the
PrivacyPolicyController.php but will fail loading the view folder.


Matthew Weier O'Phinney-3 wrote:
> 
> -- KyleMac <[EMAIL PROTECTED]> wrote
> (on Wednesday, 02 July 2008, 01:20 PM -0700):
>> I just can't get custom validators to work properly. I want to be able
>> to use the validators in addElement with the shorthand name, i.e. just
>> "Regex".
>> 
>> The closet I can get to them working is:
>> 
>> $form->addElementPrefixPath('KM_Validate', 'Validate/',
>> Zend_Form_Element::VALIDATE);
>> 
>> But now none of the Zend validators work, for example: 'File
>> NotEmpty.php was loaded but class named KM_Validate_NotEmpty was not
>> found within it.' So it is still looking in Zend/Validate but is not
>> trying the correct class prefix.
> 
> Can you provide the full form definition, possibly in a pastebin
> somewhere? There are tests for this exact situation, and I've written
> applications and tutorials that do exactly this without any problems. My
> inclination is that there is something else in your form definition
> causing problems.
> 
>> PS. Is the case sensitivity problem in Zend_Controller on NTFS going
>> to be fixed? If my production server ran Windows I'd consider it a
>> show stopper.
> 
> What case sensitivity issue are you referring to?
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect   | [EMAIL PROTECTED]
> Zend Framework   | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-addElementPrefixPath-disables-Zend-Validators-tp18245929p18246899.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_Form addElementPrefixPath disables Zend Validators

2008-07-02 Thread KyleMac

I just can't get custom validators to work properly. I want to be able to use
the validators in addElement with the shorthand name, i.e. just "Regex".

The closet I can get to them working is:

$form->addElementPrefixPath('KM_Validate', 'Validate/',
Zend_Form_Element::VALIDATE);

But now none of the Zend validators work, for example: 'File NotEmpty.php
was loaded but class named KM_Validate_NotEmpty was not found within it.' So
it is still looking in Zend/Validate but is not trying the correct class
prefix.


PS. Is the case sensitivity problem in Zend_Controller on NTFS going to be
fixed? If my production server ran Windows I'd consider it a show stopper.
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-addElementPrefixPath-disables-Zend-Validators-tp18245929p18245929.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Mixed case controller names/spaces in controller names

2008-04-24 Thread KyleMac

Say you have something like:

PrivacyPolicyController.php
privacy-policy/index.phtml

Then requesting /privacy-policy will work fine. However you can also request
/privacypolicy because PHP is case insensitive but it will throw and
exception that it can't find the view script .

How is this meant to be dealt with?
-- 
View this message in context: 
http://www.nabble.com/Mixed-case-controller-names-spaces-in-controller-names-tp16853280p16853280.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Should Zend_View_Helper_Url use rawurlencode()?

2007-12-06 Thread KyleMac

Ignore the fact that the ZF url is basically a bunch of parameters and say we
were dealing with a real folder. In such a case example.com/A+Real+Folder is
not the same as example.comA%20Real%20Folder, in fact, the first one gives
me a 404 but I bet it works on some hosts.

If I remember correctly, urlencode() is meant to encode stuff for POST or
GET, whereas rawurlencode() generates a normal url path. But since the URL's
in ZF are a bunch of parameters and don't link to real files then is using
urlencode() wrong or not?

There used to be an explanation of the differences on php.net but it's gone
now. I guess some digging through specs is needed but I don't know where to
start.
-- 
View this message in context: 
http://www.nabble.com/Should-Zend_View_Helper_Url-use-rawurlencode%28%29--tf4956211s16154.html#a14192829
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Best place to specify encoding

2007-11-06 Thread KyleMac

These settings work for me:

[client]
default_character_set = utf8

[mysqld]
character_set_server = utf8
collation_server = utf8_unicode_ci
skip-character-set-client-handshake

When PHP connects it seems to set the connection to latin1. The
"skip-character-set-client-handshake" option will make mysql ignore this and
use the default which is set to utf8. If that doesn't work then you could
also try:

[mysqld]
init-connect='SET NAMES utf8' 


Martin Carpentier wrote:
> 
> I've looked for a solution to this problem a while ago.
> 
> The MySQL documentation mention somewhere to set a parameter in the config
> in order to fix it or to use "SET CHARACTER SET utf8".
> I tried the config way but no matter what I tried it didn't work so I
> resorted to use the query fix.
> 
> I don't understand why it's so complicated to make MySQL run in UTF-8.
> 
> Martin
> 
> 
> 
> On 10/15/07, Simon Mundy <[EMAIL PROTECTED]> wrote:
>>
>> Hi Michael
>>
>> That's not necessarily true regarding UTF-8 on even Linux systems.
>>
>> I need to tell the MySQL client in Fedora Core 6 that it needs to run
>> in UTF8 before I start any queries:-
>>
>> $db->query('SET CHARACTER SET utf8');
>>
>> otherwise it will default to latin_swedish and become the weak link in
>> the chain.
>>
>> > On 10/14/07, debussy007 <[EMAIL PROTECTED]> wrote:
>> >>
>> >>
>> >> Like dinok said,
>> >> If I use $dbquery("SET NAMES 'utf8'");
>> >> I have it working.
>> >>
>> >> But does that still means I have garbage in my db ?
>> >>
>> >> Concretely I am storing the countries with their respective ISO
>> >> code from a
>> >> .csv file in my DB.
>> >
>> > Now I don't know. I've never heard of SET NAMES 'utf8'. Must be a
>> > Windows thing. On *nix systems everything runs in the UTF-8 locale [1]
>> > so it all Just Works. But if you have it working, you're good.
>> >
>> > Mike
>> >
>> > [1] except for the web server which usually runs in the C locale
>> > because it may need to handle many encodings simultaneously.
>> >
>> > --
>> > Michael B Allen
>> > PHP Active Directory SPNEGO SSO
>> > http://www.ioplex.com/
>>
>>
> 
> 
> -- 
> Martin Carpentier
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Best-place-to-specify-encoding-tf4621717s16154.html#a13610194
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] How to globally set Zend_View::setEncoding()?

2007-11-05 Thread KyleMac

Thanks, that works fine but it starts up a Zend_View every request whether
it's needed or not. Do you have any idea what kind of resources that will
waste? It seems like it'd be simpler if you could call setEncoding() as a
static method. 


Matthew Weier O'Phinney-3 wrote:
> 
> -- KyleMac <[EMAIL PROTECTED]> wrote
> (on Monday, 05 November 2007, 10:35 AM -0800):
>> Is there a way to globally set the encoding for escape() in every view
>> without setting it in every controller? I could change the default in
>> Zend_View_Abstract but then no doubt I'll forget about it after the next
>> update.
> 
> Yes. You can instantiate your own view with the configuration options
> you need and pass it to the ViewRenderer in your bootstrap or an
> early-running plugin. The method would be something like this:
> 
> $view = new Zend_View(array('encoding' => 'UTF-8'));
> $viewRenderer =
> Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
> $viewRenderer->setView($view);
> 
> -- 
> Matthew Weier O'Phinney
> PHP Developer| [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-globally-set-Zend_View%3A%3AsetEncoding%28%29--tf4753531s16154.html#a13594237
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] How to globally set Zend_View::setEncoding()?

2007-11-05 Thread KyleMac

Is there a way to globally set the encoding for escape() in every view
without setting it in every controller? I could change the default in
Zend_View_Abstract but then no doubt I'll forget about it after the next
update.
-- 
View this message in context: 
http://www.nabble.com/How-to-globally-set-Zend_View%3A%3AsetEncoding%28%29--tf4753531s16154.html#a13592793
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Mail

2007-10-28 Thread KyleMac

I was just looking into this missing date header thing since it caused a few
emails to bounce. From what I can tell, the MTA is under no obligation to
add the date header and in Exim it's considered a "fixup" (or rather, not
doing it is called suppressing fixups). Short story; if your MTA adds it
then it's being kind, if not then it's your fault for not doing it yourself.

Considering the date header is meant to be a requirement, I think that maybe
it deserves at least a mention in the ZF manual, maybe it's own addDate()
method and probably to be added automatically by Zend_Mail.



Matthew Weier O'Phinney-2 wrote:
> 
> On 7/6/06, Brent Robinson <[EMAIL PROTECTED]> wrote:
>> I am having a problem with Zend_Mail that my mail is not passing a date
>> header. I am getting a 01/01/1970 date in thunderbird and a unknown date
>> in Webmail.
>>
>> I am using SMTP and am developing on a Windows Platform with Apache 2
>> and PHP5.
> 
> 
> 
>> Is there something that I am overlooking or am not setting. I have
>> looked and googled the whole afternoon but cannot find anything.
> 
> Date headers are usually set by the mail transport; if you're not seeing
> one, then your transport isn't putting it in (which is bad behaviour on
> the part of the transport).
> 
> Two options: investigate your mail transport and see why it's not
> setting the date header, or set it manually using Zend_Mail's
> addHeader() method:
> 
> $mail->addHeader('Date', date('r'));
> 
> What are you using for mail delivery, by the way? You mention SMTP, but
> you don't specify what kind of SMTP server you're using. Others may be
> able to point out additional remedies based on that information.
> 
> -- 
> Matthew Weier O'Phinney
> PHP Developer
> Zend Technologies
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Mail-tf1902855s16154.html#a13455630
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Implement Zend_Session::regenerateId(false)?

2007-10-24 Thread KyleMac

Ok, I lied, that didn't fix anything. It seemed to but then I went to edit
Zend_Session and couldn't get it to work, so I went back to my test php and
it wasn't working there anymore either.

I'm sure there is a way to do this, perhaps every X requests or minutes is
best?


KyleMac wrote:
> 
> I just realised a better fix for this. This seems (?) to do it:
> 
> if (isset($_REQUEST[session_name()])) {
>   session_regenerate_id(true);
> }
> 
> Or with $_COOKIE if use only cookies is on. Basically, the todo under
> regenerateId() seems to be exactly this.
> 
> 
> KyleMac wrote:
>> 
>> I think that regenerageId() should take a parameter to set
>> delete_old_session to false in session_regenerate_id(). I've already
>> changed my code to do this.
>> 
>> Why do I think this should be done? Well, session_regenerate_id(true)
>> deletes the old session ID, so if a user fires off requests to a site in
>> quick succession, it is quite possible for their browser to write the new
>> cookies too slowly or in the wrong order and thus their session is lost.
>> 
>> It is quite easy to recreate this situation with some simple code and
>> then just hammer (or old down) F5. You have to pick up some speed to
>> recreate the issue but it does occur randomly at normal speeds on a
>> proper site (I think maybe the browser is slowed down much further by
>> images or javascript or something).
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Implement-Zend_Session%3A%3AregenerateId%28false%29--tf4681793s16154.html#a13384578
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Implement Zend_Session::regenerateId(false)?

2007-10-24 Thread KyleMac

I just realised a better fix for this. This seems (?) to do it:

if (isset($_REQUEST[session_name()])) {
session_regenerate_id(true);
}

Or with $_COOKIE if use only cookies is on. Basically, the todo under
regenerateId() seems to be exactly this.


KyleMac wrote:
> 
> I think that regenerageId() should take a parameter to set
> delete_old_session to false in session_regenerate_id(). I've already
> changed my code to do this.
> 
> Why do I think this should be done? Well, session_regenerate_id(true)
> deletes the old session ID, so if a user fires off requests to a site in
> quick succession, it is quite possible for their browser to write the new
> cookies too slowly or in the wrong order and thus their session is lost.
> 
> It is quite easy to recreate this situation with some simple code and then
> just hammer (or old down) F5. You have to pick up some speed to recreate
> the issue but it does occur randomly at normal speeds on a proper site (I
> think maybe the browser is slowed down much further by images or
> javascript or something).
> 

-- 
View this message in context: 
http://www.nabble.com/Implement-Zend_Session%3A%3AregenerateId%28false%29--tf4681793s16154.html#a13384561
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Implement Zend_Session::regenerateId(false)?

2007-10-23 Thread KyleMac

I think that regenerageId() should take a parameter to set delete_old_session
to false in session_regenerate_id(). I've already changed my code to do
this.

Why do I think this should be done? Well, session_regenerate_id(true)
deletes the old session ID, so if a user fires off requests to a site in
quick succession, it is quite possible for their browser to write the new
cookies too slowly or in the wrong order and thus their session is lost.

It is quite easy to recreate this situation with some simple code and then
just hammer (or old down) F5. You have to pick up some speed to recreate the
issue but it does occur randomly at normal speeds on a proper site (I think
maybe the browser is slowed down much further by images or javascript or
something).
-- 
View this message in context: 
http://www.nabble.com/Implement-Zend_Session%3A%3AregenerateId%28false%29--tf4681793s16154.html#a13378431
Sent from the Zend Framework mailing list archive at Nabble.com.