2008年8月31日星期日

Re: [fw-core] The validation for Zend_Form_Element_File with belongsTo attrubite hasn't effect.

Please add a issue to jira with all data and reproducable code.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message -----
From: "rollenc" <rollenc@gmail.com>
To: <fw-core@lists.zend.com>
Sent: Monday, September 01, 2008 3:43 AM
Subject: [fw-core] The validation for Zend_Form_Element_File with belongsTo
attrubite hasn't effect.

When a Form_Element_file is set with a belongsTo attrubite, the validation
hasn't effect.

My form configure likes followed:

[Profile]
;;;; Signup form ;;;
form.action = "/user.php?switch=editprofile"
form.enctype="multipart/form-data"
form.method = "post"
form.id = "editprofile"
form.name = "editprofile"
form.elementsBelongTo = "profile"

;; Avatar
form.elements.Avatar.type = "file"
form.elements.Avatar.options.label = "Avatar: "
form.elements.Avatar.options.validators.Count.validator = "1" ; 1个文件
form.elements.Avatar.options.validators.Size.validator = "1024000" ; 1M
form.elements.Avatar.options.validators.Extension.validator = "jpg,png,gif"


Thanks for any posts.


--
View this message in context:
http://www.nabble.com/The-validation-for-Zend_Form_Element_File-with-belongsTo-attrubite-hasn%27t-effect.-tp19247887p19247887.html
Sent from the Zend Core mailing list archive at Nabble.com.

[fw-core] The validation for Zend_Form_Element_File with belongsTo attrubite hasn't effect.

When a Form_Element_file is set with a belongsTo attrubite, the validation
hasn't effect.

My form configure likes followed:

[Profile]
;;;; Signup form ;;;
form.action = "/user.php?switch=editprofile"
form.enctype="multipart/form-data"
form.method = "post"
form.id = "editprofile"
form.name = "editprofile"
form.elementsBelongTo = "profile"

;; Avatar
form.elements.Avatar.type = "file"
form.elements.Avatar.options.label = "Avatar: "
form.elements.Avatar.options.validators.Count.validator = "1" ; 1个文件
form.elements.Avatar.options.validators.Size.validator = "1024000" ; 1M
form.elements.Avatar.options.validators.Extension.validator = "jpg,png,gif"


Thanks for any posts.


--
View this message in context: http://www.nabble.com/The-validation-for-Zend_Form_Element_File-with-belongsTo-attrubite-hasn%27t-effect.-tp19247887p19247887.html
Sent from the Zend Core mailing list archive at Nabble.com.

Re: [fw-mvc] Passing Zend Form instances around in a controller for validation

Thanks. That does the trick quite nicely!

>
> I typically add a "getForm()" method to my controller to instantiate and
> return the form:
>
> protected $_form;
>
> public function getForm()
> {
> if (null === $this->_form) {
> $this->_form = new My_Form_SomeFunctionalityINeedAFormFor();
> $this->_form->setAction(...)
> ->setMethod('post');
> }
> return $this->_form;
> }
>
> Then, in my actions, I retrieve it:
>
> public function formAction()
> {
> $this->view->form = $this->getForm();
> }
>
> public function processAction()
> {
> $request = $this->getRequest();
> if (!$request->isPost()) {
> return $this->_forward('form');
> }
>
> $form = $this->getForm();
> if (!$form->isValid($request->getPost())) {
> return $this->render('form');
> }
>
> // process and redirect ...
> }
>
> --
> Matthew Weier O'Phinney
> Software Architect | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
>

--
View this message in context: http://www.nabble.com/Passing-Zend-Form-instances-around-in-a-controller-for-validation-tp19243691p19244651.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_Db_Profiler_Firebug with large number of request

ZF 1.6 RC3 or better r11163+ with FirePHP 0.1.2 should work without a
problem.

FirePHP 0.1.2 is not available on mozilla add-ons yet as it is still stuck
in the review que. You can upgrade to it from http://www.firephp.org/HQ/

Christoph

mikaelkael wrote:
>
> Hi,
>
> As I wrote here http://framework.zend.com/issues/browse/ZF-4020, It's OK
> for me.
> I think you have also to update FirePhp (perhaps FireBug). Christoph can
> confirm.
>
> Mickael.
>
>

--
View this message in context: http://www.nabble.com/Zend_Db_Profiler_Firebug-with-large-number-of-request-tp18912121p19244279.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_Db_Profiler_Firebug with large number of request

Hi,

As I wrote here http://framework.zend.com/issues/browse/ZF-4020, It's OK
for me.
I think you have also to update FirePhp (perhaps FireBug). Christoph can
confirm.

Mickael.
> sorry. It is 11117. (lost one 1 ) :)
>
>
> Matthew Weier O'Phinney-3 wrote:
>
>> -- agatone <zoran.zoki@gmail.com> wrote
>> (on Friday, 29 August 2008, 05:28 AM -0700):
>>
>>> Well I've updated to revision 1117 and still get the same error.
>>>
>> I hate to say it, but r1117 was YEARS ago. Can you verify the revision
>> number, please?
>>
>>
>>> mikaelkael wrote:
>>>
>>>> I have a application under production since 18 months. I always follow
>>>> ZF evolution so this application run now with 1.6RC2 (yes RC2).
>>>> I don't want to disturb anything and I want to see my database requests
>>>> so I decide to use Zend_Db_Profiler_Firebug.
>>>> For most of my page, there is no problem (10 database request) but one
>>>> page need 200 request and I have a exception in Firebug.
>>>> See the image:
>>>>
>>>> Is it due to a too big header? A too big JSON string for Firebug?
>>>>
>> --
>> Matthew Weier O'Phinney
>> Software Architect | matthew@zend.com
>> Zend Framework | http://framework.zend.com/
>>

Re: [fw-mvc] Passing Zend Form instances around in a controller for validation

-- GJ Bogaerts <gj@zigg.nl> wrote
(on Sunday, 31 August 2008, 09:25 AM -0700):
> I wonder what is the best way to pass an instance of a Zend_Form around in a
> controller. I used to post to the same page as the form was on, so
> validation would be easy: I would instantiate a form, and depending on the
> fact if a post was done, I could validate on the form and forward to another
> page, or present the error messages.
>
> But I want to do post-processing and validation in another action (the same
> controller) and I don't have access to the instantiated form in this other
> action. I've tried to set the form as a protected property of the
> controller, but that doesn't work.
>
> Any ideas or help would be greatly appreciated.
>
> BTW, in the docs I could only find examples of same-page-posts.

I typically add a "getForm()" method to my controller to instantiate and
return the form:

protected $_form;

public function getForm()
{
if (null === $this->_form) {
$this->_form = new My_Form_SomeFunctionalityINeedAFormFor();
$this->_form->setAction(...)
->setMethod('post');
}
return $this->_form;
}

Then, in my actions, I retrieve it:

public function formAction()
{
$this->view->form = $this->getForm();
}

public function processAction()
{
$request = $this->getRequest();
if (!$request->isPost()) {
return $this->_forward('form');
}

$form = $this->getForm();
if (!$form->isValid($request->getPost())) {
return $this->render('form');
}

// process and redirect ...
}

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Zend_Form_Element_Checkbox render a additional hidden input

-- 谢言付 <xieyanfu@macrowing.com> wrote
(on Sunday, 31 August 2008, 10:19 PM +0800):
> Thanks for your quick response !
> This not the perfect way , because in the javascript coding, we
> usually use document.forms['formName'].elements['elementName'] to get
> the element object ,

>
> <dt>&nbsp;</dt>
> <dd>
> <input type="hidden" name="public" value="0"><input type="checkbox"
> name="public" id="public" value="1"></dd>
>
> In the code, we use document.forms['formName'].elements['public'] to
> get the public checkbox, but it will only return the hidden input .

Use the ID of the element instead, as only the checkbox receives the id.
You can use the Javascript method document.getElementById(), or, if
using a more modern JS toolkit, use one of their convenience features
(in prototype, $('<id>'); in dojo, dojo.byId('<id>'); in jquery,
$('#<id>')).

> -------------------------------
> (on Sunday, 31 August 2008, 08:01 PM +0800):
> > But why should we add a hidden input ?
>
> To ensure a value is actually sent. When a checkbox is not checked, it
> does not send a key for that element when the form is submitted. Adding
> the hidden element ensures that the unchecked value is transmitted. This
> is done to ensure that a value for the element is always present.
>
> --
> Matthew Weier O'Phinney
> Software Architect | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

[fw-mvc] Passing Zend Form instances around in a controller for validation

Hi all,

I wonder what is the best way to pass an instance of a Zend_Form around in a
controller. I used to post to the same page as the form was on, so
validation would be easy: I would instantiate a form, and depending on the
fact if a post was done, I could validate on the form and forward to another
page, or present the error messages.

But I want to do post-processing and validation in another action (the same
controller) and I don't have access to the instantiated form in this other
action. I've tried to set the form as a protected property of the
controller, but that doesn't work.

Any ideas or help would be greatly appreciated.

BTW, in the docs I could only find examples of same-page-posts.

GJ
--
View this message in context: http://www.nabble.com/Passing-Zend-Form-instances-around-in-a-controller-for-validation-tp19243691p19243691.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_Form_Element_Checkbox render a additional hidden input

Thanks for your quick response !
This not the perfect way , because in the javascript coding, we usually use document.forms['formName'].elements['elementName'] to get the element object ,

<dt>&nbsp;</dt>
<dd>
<input type="hidden" name="public" value="0"><input type="checkbox" name="public" id="public" value="1"></dd>

In the code, we use document.forms['formName'].elements['public'] to get the public checkbox, but it will only return the hidden input .

-------------------------------
(on Sunday, 31 August 2008, 08:01 PM +0800):
> But why should we add a hidden input ?

To ensure a value is actually sent. When a checkbox is not checked, it
does not send a key for that element when the form is submitted. Adding
the hidden element ensures that the unchecked value is transmitted. This
is done to ensure that a value for the element is always present.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Zend_Form_Element_Checkbox render a additional hidden input

-- 谢言付 <xieyanfu@macrowing.com> wrote
(on Sunday, 31 August 2008, 08:01 PM +0800):
> But why should we add a hidden input ?

To ensure a value is actually sent. When a checkbox is not checked, it
does not send a key for that element when the form is submitted. Adding
the hidden element ensures that the unchecked value is transmitted. This
is done to ensure that a value for the element is always present.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

[fw-mvc] Zend_Form_Element_Checkbox render a additional hidden input

<?php

 

include 'zend/view.php';

include 'zend/form/element/checkbox.php';

 

$view = new Zend_View();

$public = new Zend_Form_Element_Checkbox('public');

$public ->render($view);

echo $public;

 

?>

 

 

Will generate a hidden input :

 

<dt>&nbsp;</dt>

<dd>

<input type="hidden" name="public" value="0"><input type="checkbox" name="public" id="public" value="1"></dd>

 

My zf version is 1.6.0RC3, and I check the formCheckbox helper , I found the code like this :

 

// build the element

        $xhtml = '';

        if (!strstr($name, '[]')) {

            $xhtml = $this->_hidden($name, $checkedOptions['unCheckedValue']);

        }

                   $xhtml .= '<input type="checkbox"'

                . ' name="' . $this->view->escape($name) . '"'

                . ' id="' . $this->view->escape($id) . '"'

                . ' value="' . $this->view->escape($checkedOptions['checkedValue']) . '"'

                . $checkedOptions['checkedString']

                . $disabled

                . $this->_htmlAttribs($attribs)

                . $endTag;

 

But why should we add a hidden input ?

 

2008年8月30日星期六

[fw-server] Soap help... Please!

Soap has just been killing me! Here's the wsdl that i'm trying to respond to:
<s:element name="DeleteCustomerProfile">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="merchantAuthentication" type="tns:MerchantAuthenticationType"/>
<s:element minOccurs="1" maxOccurs="1" name="customerProfileId" type="s:long"/>
</s:sequence>
</s:complexType>
</s:element>

So I did:
$soapclient->DeleteCustomerProfile($methant_authentication, $customerProfile);

Anyone see what I did wrong? Or do I need to provide more info

Thanks in advance

[fw-server] Zend_Rest_Server issues and returning arrays

Hi All,

Currently, when you return a numeric array, Zend_Rest_Server will turn
something like this:

$result = array('A','Bit','Of','Data');

Into something like this:

<key_0>A</key_0>
<key_1>Bit</key_1>
<key_2>Of</key_2>
<key_3>Data</key_3>

This works, but can be cumbersome. What would be nicer is something like
this:

<data index="0">A</data>
<data index="1">Bit</data>
<data index="2">Of</data>
<data index="3">Data</data>

The former is easier to iterate over using ActionScript's ObjectProxy and
E4X syntax's. You could just do something like this:

result.data[0]// accesses "A"
result.data[1] // accesses "Bit"

And so forth. This is easier to iterate over than:

result.key_1 // accesses "A"
result.key_2 // accesses "Bit"

This is because you have iterate from n=0 to n={upperLimit}, and then look
in result.data[n], but it's a bit trickier to inspect result.key_{n}.

Anyway, I was wondering there were any plans to add a new, optional behavior
to Zend_Rest_Server so it would be like I described above. I've already
implemented this by changing a few lines in an class method that overrides
Zend_Rest_Server::_structValue. See here:
http://www.zfforums.com/zend-framework-components-13/web-web-services-22/some-zend_rest_server-issues-i-m-having-42.html#post4527

-Josh
--
View this message in context: http://www.nabble.com/Zend_Rest_Server-issues-and-returning-arrays-tp19236018p19236018.html
Sent from the Zend Server mailing list archive at Nabble.com.

Re: [fw-mvc] Firebug logger issues

Hey there,

This has already been resolved in http://framework.zend.com/issues/browse/ZF-3963, it should be fixed in RC3.

Later,


Matthew.

Matthew Weier O'Phinney wrote:
-- Adam Jensen <jazzslider@gmail.com> wrote (on Thursday, 14 August 2008, 08:49 AM -0500):   
Just confirmed it...manually calling Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush() from within my layout script fixes the problem.  Is there a way the plugin could be refactored to address this issue?     
 This is useful information -- please add it in a comment to the issue report. It's very likely that the issue is indeed the order in which the plugins are being executed -- and there's actually a way to force the order that was added in 1.6.0.  Thanks for the continued sleuthing!    
On Thu, Aug 14, 2008 at 8:46 AM, Adam Jensen <jazzslider@gmail.com> wrote:     
On Wed, Aug 13, 2008 at 7:26 PM, Matthew Weier O'Phinney <matthew@zend.com> wrote:       
So, try and narrow down your reproduce case, to the smallest amount of code necessary, and then post it to see if others get the same results.         
I'm working on narrowing down a minimal reduce case, but it's been somewhat difficult given the number of components involved in all this...ordinarily I'd just write a simple test script and upload it, but I need the entire Zend_Controller_Front architecture for this one.  I have, however, found out at least one more relevant detail.  For whatever reason, I'm able to log to Firebug just fine in any context _except_ for layout scripts.  Are layout scripts rendered after the postDispatch() hook for the Channel plugin has already fired?  I think that would explain why any log messages fired off within that context never end up in the response headers.  I'll keep looking into it; meanwhile, please let me know if you've got any ideas for solving this.  Should I call the Channel plugin's flush() method myself from the end of my layout script?       
   

2008年8月29日星期五

Re: [fw-mvc] Zend_Db_Profiler_Firebug with large number of request

sorry. It is 11117. (lost one 1 ) :)


Matthew Weier O'Phinney-3 wrote:
>
> -- agatone <zoran.zoki@gmail.com> wrote
> (on Friday, 29 August 2008, 05:28 AM -0700):
>> Well I've updated to revision 1117 and still get the same error.
>
> I hate to say it, but r1117 was YEARS ago. Can you verify the revision
> number, please?
>
>> mikaelkael wrote:
>> > I have a application under production since 18 months. I always follow
>> > ZF evolution so this application run now with 1.6RC2 (yes RC2).
>> > I don't want to disturb anything and I want to see my database requests
>> > so I decide to use Zend_Db_Profiler_Firebug.
>> > For most of my page, there is no problem (10 database request) but one
>> > page need 200 request and I have a exception in Firebug.
>> > See the image:
>> >
>> > Is it due to a too big header? A too big JSON string for Firebug?
>
> --
> Matthew Weier O'Phinney
> Software Architect | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
>

--
View this message in context: http://www.nabble.com/Zend_Db_Profiler_Firebug-with-large-number-of-request-tp18912121p19220291.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_Db_Profiler_Firebug with large number of request

-- agatone <zoran.zoki@gmail.com> wrote
(on Friday, 29 August 2008, 05:28 AM -0700):
> Well I've updated to revision 1117 and still get the same error.

I hate to say it, but r1117 was YEARS ago. Can you verify the revision
number, please?

> mikaelkael wrote:
> > I have a application under production since 18 months. I always follow
> > ZF evolution so this application run now with 1.6RC2 (yes RC2).
> > I don't want to disturb anything and I want to see my database requests
> > so I decide to use Zend_Db_Profiler_Firebug.
> > For most of my page, there is no problem (10 database request) but one
> > page need 200 request and I have a exception in Firebug.
> > See the image:
> >
> > Is it due to a too big header? A too big JSON string for Firebug?

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Zend_Db_Profiler_Firebug with large number of request

Well I've updated to revision 1117 and still get the same error.

Anyone else having troubles?
Any solutions ?


mikaelkael wrote:
>
> Hi,
>
> I have a application under production since 18 months. I always follow
> ZF evolution so this application run now with 1.6RC2 (yes RC2).
> I don't want to disturb anything and I want to see my database requests
> so I decide to use Zend_Db_Profiler_Firebug.
> For most of my page, there is no problem (10 database request) but one
> page need 200 request and I have a exception in Firebug.
> See the image:
>
> Is it due to a too big header? A too big JSON string for Firebug?
>
> Mickael.
>
>
>
>

--
View this message in context: http://www.nabble.com/Zend_Db_Profiler_Firebug-with-large-number-of-request-tp18912121p19218925.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-db] Zend_Db_Table time overhead - about 25%

Bill Karwin wrote:
>
>
> Who is insisting that you use Table/Row Gateway for everything? Not me.
> I definitely agree that OO abstractions for data access are less speedy
> than writing SQL queries. I agree that they have their use, but no
> solution should be employed in all situations.
>
> Regards,
> Bill Karwin
>

I found this quite interesting. I dislike the encapsulation of SQL, I prefer
to just write it.

I don't think the distinction is made in the ZF documents. It simply shows
you how to use all the DB objects and implies you *should* be using them.
This is where the confusion lies. I had a 'feeling' that I was somehow doing
it wrong, but the more I hang out in this email list the more I realise that
perhaps I'm doing it right.

Like you say, for simple queries, use what suits you best. For slow pages
think about just using SQL and for very slow pages think about memcache or
something.

monk.e.boy

--
View this message in context: http://www.nabble.com/Zend_Db_Table-time-overhead---about-25--tp19203345p19218286.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-core] Deep Cloning Zend_Config

Hi,

I'm happy to contribute. Thanks for implementing the change so quickly.

Rob Allen wrote:
> Hi,
>
> Thanks very much for the report! I've resolved this on the trunk in
> svn r11113.
>
> Regards,
>
> Rob...
>
>
> On 26 Aug 2008, at 20:25, Daniel Skinner wrote:
>
>> I am getting unexpected behaviour when cloning a Zend_Config object:
>>
>> Example (actual behaviour):
>>
>> $parent = new Zend_Config(array('key' => array('nested' =>
>> 'parent')), true); //allow read-write for merging
>> $newConfig = clone $parent;
>> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
>> 'override')), true));
>> echo $newConfig->key->nested; // 'override' - as expected
>> echo $parent->key->nested; // 'override' - I was expecting this to be
>> 'parent'
>>
>>
>> Intuitive behaviour (what makes sense):
>>
>> Cloning a Zend_Config object should completely separate the new
>> instance from the original - i.e. there should be no cross-references.
>>
>> $parent = new Zend_Config(array('key' => array('nested' =>
>> 'parent')), true); //allow read-write for merging
>> $newConfig = clone $parent;
>> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
>> 'override')), true));
>> echo $newConfig->key->nested; // 'override'
>> echo $parent->key->nested; // 'parent'
>>
>>
>> This is occurring because cloning Zend_Config only creates a shallow
>> clone currently.
>>
>> Solution 1: Cast to an array and create a new instance:
>>
>> This can be achieved already and effectively creates a deep clone.
>>
>> $parent = new Zend_Config(array('key' => array('nested' =>
>> 'parent')), true); //allow read-write for merging
>> $newConfig = new Zend_Config($parent->toArray(), true); //cast the
>> parent object to an array and create a new Zend_Config
>> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
>> 'override')), true));
>> echo $newConfig->key->nested; // 'override' - as expected
>> echo $parent->key->nested; // 'parent' - as expected
>>
>> Solution 2: Fixing Zend_Config to perform a deep clone:
>>
>> /**
>> * Perform a deep clone of this instance to allow side-effect free
>> cloning.
>> * @return void
>> */
>> public function __clone()
>> {
>> $data = array();
>> foreach ($this->_data as $key => $value)
>> {
>> if ($value instanceof Zend_Config)
>> {
>> $data[$key] = clone $value;
>> } else {
>> $data[$key] = $value;
>> }
>> }
>> $this->_data = $data;
>> }
>>
>> Gives:
>>
>> $parent = new Zend_Config(array('key' => array('nested' =>
>> 'parent')), true); //allow read-write for merging
>> $newConfig = clone $parent;
>> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
>> 'override')), true));
>> echo $newConfig->key->nested; // 'override' - as expected
>> echo $parent->key->nested; // 'parent' - as expected
>>
>> It makes sense to me that this is the expected behaviour when cloning
>> and a deep clone greatly reduces the chance of hard to detect
>> side-effects. Does anybody disagree?
>>
>> A full description of the above can be found at:
>> http://www.daniel-skinner.co.uk/cloning-zend_config-without-side-effects/26/08/2008
>>
>>
>> Test cases and a patch can be found at:
>> http://www.destiny-denied.co.uk/files/ZendConfigClone.zip
>>
>> Kind Regards,
>>
>> *Daniel Skinner*
>> **
>> skinner@destiny-denied.co.uk <mailto:skinner@destiny-denied.co.uk>
>> www.destiny-denied.co.uk <http://www.destiny-denied.co.uk/>
>>
>

Re: [fw-db] Out of memory error

Thanks Bill :-) that is a strange little bug :-/

I blogged it for google, it may save someone the same frustrations ;-)

http://teethgrinder.co.uk/perm.php?a=Zend-Framework-MySQL-Out-Of-Memory-Error

--
View this message in context: http://www.nabble.com/Out-of-memory-error-tp19108319p19215843.html
Sent from the Zend DB mailing list archive at Nabble.com.

2008年8月28日星期四

Re: [fw-core] Deep Cloning Zend_Config

Hi,

Thanks very much for the report! I've resolved this on the trunk in
svn r11113.

Regards,

Rob...


On 26 Aug 2008, at 20:25, Daniel Skinner wrote:

> I am getting unexpected behaviour when cloning a Zend_Config object:
>
> Example (actual behaviour):
>
> $parent = new Zend_Config(array('key' => array('nested' =>
> 'parent')), true); //allow read-write for merging
> $newConfig = clone $parent;
> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
> 'override')), true));
> echo $newConfig->key->nested; // 'override' - as expected
> echo $parent->key->nested; // 'override' - I was expecting this to
> be 'parent'
>
>
> Intuitive behaviour (what makes sense):
>
> Cloning a Zend_Config object should completely separate the new
> instance from the original - i.e. there should be no cross-references.
>
> $parent = new Zend_Config(array('key' => array('nested' =>
> 'parent')), true); //allow read-write for merging
> $newConfig = clone $parent;
> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
> 'override')), true));
> echo $newConfig->key->nested; // 'override'
> echo $parent->key->nested; // 'parent'
>
>
> This is occurring because cloning Zend_Config only creates a shallow
> clone currently.
>
> Solution 1: Cast to an array and create a new instance:
>
> This can be achieved already and effectively creates a deep clone.
>
> $parent = new Zend_Config(array('key' => array('nested' =>
> 'parent')), true); //allow read-write for merging
> $newConfig = new Zend_Config($parent->toArray(), true); //cast the
> parent object to an array and create a new Zend_Config
> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
> 'override')), true));
> echo $newConfig->key->nested; // 'override' - as expected
> echo $parent->key->nested; // 'parent' - as expected
>
> Solution 2: Fixing Zend_Config to perform a deep clone:
>
> /**
> * Perform a deep clone of this instance to allow side-effect free
> cloning.
> * @return void
> */
> public function __clone()
> {
> $data = array();
> foreach ($this->_data as $key => $value)
> {
> if ($value instanceof Zend_Config)
> {
> $data[$key] = clone $value;
> } else {
> $data[$key] = $value;
> }
> }
> $this->_data = $data;
> }
>
> Gives:
>
> $parent = new Zend_Config(array('key' => array('nested' =>
> 'parent')), true); //allow read-write for merging
> $newConfig = clone $parent;
> $newConfig->merge(new Zend_Config(array('key' => array('nested' =>
> 'override')), true));
> echo $newConfig->key->nested; // 'override' - as expected
> echo $parent->key->nested; // 'parent' - as expected
>
> It makes sense to me that this is the expected behaviour when
> cloning and a deep clone greatly reduces the chance of hard to
> detect side-effects. Does anybody disagree?
>
> A full description of the above can be found at: http://www.daniel-skinner.co.uk/cloning-zend_config-without-side-effects/26/08/2008
>
> Test cases and a patch can be found at: http://www.destiny-denied.co.uk/files/ZendConfigClone.zip
>
> Kind Regards,
>
> *Daniel Skinner*
> **
> skinner@destiny-denied.co.uk <mailto:skinner@destiny-denied.co.uk>
> www.destiny-denied.co.uk <http://www.destiny-denied.co.uk/>
>

Re: [fw-db] Zend_Db_Table time overhead - about 25%

Viper X wrote:
>
> My point of view is that insisting to use another and another layers of
> abstraction just for the abstraction itself does not lead to good things.
> Table Gateway and Row Gateway patterns have their use, but they have
> limitations also and are not the best solution for everything.
>

Who is insisting that you use Table/Row Gateway for everything? Not me. I
definitely agree that OO abstractions for data access are less speedy than
writing SQL queries. I agree that they have their use, but no solution
should be employed in all situations.

Not every database query needs to be optimal. Some queries are done
infrequently. Many performance problems cannot be solved in a scalable way
with code alone -- you have to rearchitect, or use caching, or do
server-level scale-out. Performance optimization is a holistic process,
involving every level of software architecture (and some hardware
architecture too), so don't focus too much on any one part of it. Sometimes
writing SQL by hand is the best way to improve database access. Sometimes
it may be caching the query results.

You're right that encapsulation is a good OO principle, and centralizing the
database queries makes them easier to maintain than scattering SQL
throughout your code. But that doesn't necessarily mean that we need to
abandon the OO interface and write *every* SQL query by hand. What I
recommend is that we use OO classes for simplicity and convenience, and when
we find some code that is a bottleneck in the app because of using the OO
interface, then we can refactor that code to improve its performance.

My example of writing your own data store module, or abandoning PHP is
hyperbole on my part. I just mean to say that there's always a point of
diminishing returns when you choose coding techniques for the sake of
performance over development efficiency. Switching to programming in
assembler is of course a bad idea for 99.9% of web apps. But in very rare
cases, it could be exactly the right thing to do.

Where the balance point lies is determined on a case by case basis.
Sometimes you're writing a tiny little intranet app that has only six users
and doesn't need to be optimized -- but developing that app needs to be very
quick and easy, because it would senseless to invest months of effort for an
app to serve only six people. Other times you're working on a high-end
content management system for a highly scalable news site like Yahoo! Then
you can invest a lot of engineering time to optimize more for performance.

I think you and I are probably on the same page...

By coincidence, Rasmus Lerdorf gave a keynote at Drupalcon this week in
Hungary, and reportedly he said some things that support this too. He
compared a bunch of frameworks, and observes that they all have overhead
that makes them unsuitable for high-performance, high-scalability
applications. He even says that any scripting language (like PHP) is
unsuitable for very high-scale apps!
Here's an article reporting his speech:
http://www.sitepoint.com/blogs/2008/08/29/rasmus-lerdorf-php-frameworks-think-again/

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Zend_Db_Table-time-overhead---about-25--tp19203345p19206688.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Zend_Db_Table time overhead - about 25%

Bill Karwin wrote:
>
> In fact, if performance is the only concern, you shouldn't be using an
> RDBMS at all -- you should be managing data using a custom storage module
> that you write, specialized to your application. Also, you shouldn't be
> coding in PHP in the first place -- you should be writing all your code by
> hand in assembler.
>

Hi Bill, thank for the answer, you are of course right with this statement,
but when the performance is not the only concern, but it is main concern -
what is the situation then? Coding in assembler is not a question at all, we
are writing a web applications, so we have choosen PHP for this. We want
some coding standarts and some structure to follow, so we use Zend
Framework. It have not small overhead alone, so when we have choosen to use
Zend Framework we already have made some trade-off between speed and
development convenience.

But. Most of the web applications make heavy use of database. While
scattering your code with SQL queries is bad and with no doubt you should
avoid it, placing direct SQL queries in some class in your Model layer is
not bad design for me.
I don't want to start a flame here, I just want to share some thoughts and
to see the opinion of the others. My point of view is that insisting to use
another and another layers of abstraction just for the abstraction itself
does not lead to good things. Table Gateway and Row Gateway patterns have
their use, but they have limitations also and are not the best solution for
everything. For example when we want to represent tabular data and edit it
row by row this is great approach. Also if we want to have some kind of code
generation, for example for quick generation of admin modules, allowing
editing, inserting and deleting of rows in and from DB tables the Table
Gateway and Row Gateway pattern is nice. Together with Zend_Form this can be
very powerfull way to quickly generate very complex applications. But when
it comes to speed, writing in assembler is not the only way to improve it..
--
View this message in context: http://www.nabble.com/Zend_Db_Table-time-overhead---about-25--tp19203345p19205502.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Zend_Db_Table time overhead - about 25%

Viper X wrote:
>
> conclusion: Zend_Db_Table is not good for heavy loaded web applications.
> My personal choice is to go with something like variant 4. The time
> overhead here is minimal and the code in the controller is most readable.
>

I agree with this. All ORM solutions are notorious for adding performance
overhead. Their value is in extending the object-oriented paradigm to
database programming.

There's no substitute for writing SQL queries by hand, if performance is
your top priority. In fact, if performance is the only concern, you
shouldn't be using an RDBMS at all -- you should be managing data using a
custom storage module that you write, specialized to your application.
Also, you shouldn't be coding in PHP in the first place -- you should be
writing all your code by hand in assembler.

The point being that often a trade-off exists between development
convenience and runtime speed.

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Zend_Db_Table-time-overhead---about-25--tp19203345p19203700.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-core] Deep Cloning Zend_Config

Excellent problem description with solution.  Nice work!  I've created an issue to track this bug:


-Matt

On Tue, Aug 26, 2008 at 12:25 PM, Daniel Skinner <skinner@destiny-denied.co.uk> wrote:
I am getting unexpected behaviour when cloning a Zend_Config object:

Example (actual behaviour):

$parent = new Zend_Config(array('key' => array('nested' => 'parent')), true); //allow read-write for merging
$newConfig = clone $parent;
$newConfig->merge(new Zend_Config(array('key' => array('nested' => 'override')), true));
echo $newConfig->key->nested; // 'override'  - as expected
echo $parent->key->nested; // 'override' - I was expecting this to be 'parent'


Intuitive behaviour (what makes sense):

Cloning a Zend_Config object should completely separate the new instance from the original - i.e. there should be no cross-references.

$parent = new Zend_Config(array('key' => array('nested' => 'parent')), true); //allow read-write for merging
$newConfig = clone $parent;
$newConfig->merge(new Zend_Config(array('key' => array('nested' => 'override')), true));
echo $newConfig->key->nested; // 'override'
echo $parent->key->nested; // 'parent'


This is occurring because cloning Zend_Config only creates a shallow clone currently.

Solution 1: Cast to an array and create a new instance:

This can be achieved already and effectively creates a deep clone.

$parent = new Zend_Config(array('key' => array('nested' => 'parent')), true); //allow read-write for merging
$newConfig = new Zend_Config($parent->toArray(), true); //cast the parent object to an array and create a new Zend_Config
$newConfig->merge(new Zend_Config(array('key' => array('nested' => 'override')), true));
echo $newConfig->key->nested; // 'override'  - as expected
echo $parent->key->nested; // 'parent' - as expected

Solution 2: Fixing Zend_Config to perform a deep clone:

  /**
   * Perform a deep clone of this instance to allow side-effect free cloning.
   * @return void
   */
  public function __clone()
  {
      $data = array();
      foreach ($this->_data as $key => $value)
      {
          if ($value instanceof Zend_Config)
          {
              $data[$key] = clone $value;
          } else {
              $data[$key] = $value;
          }
      }
      $this->_data = $data;
  }

Gives:

$parent = new Zend_Config(array('key' => array('nested' => 'parent')), true); //allow read-write for merging
$newConfig = clone $parent;
$newConfig->merge(new Zend_Config(array('key' => array('nested' => 'override')), true));
echo $newConfig->key->nested; // 'override'  - as expected
echo $parent->key->nested; // 'parent' - as expected

It makes sense to me that this is the expected behaviour when cloning and a deep clone greatly reduces the chance of hard to detect side-effects. Does anybody disagree?

A full description of the above can be found at: http://www.daniel-skinner.co.uk/cloning-zend_config-without-side-effects/26/08/2008

Test cases and a patch can be found at: http://www.destiny-denied.co.uk/files/ZendConfigClone.zip

Kind Regards,

*Daniel Skinner*
**
skinner@destiny-denied.co.uk <mailto:skinner@destiny-denied.co.uk>
www.destiny-denied.co.uk <http://www.destiny-denied.co.uk/>


[fw-db] Zend_Db_Table time overhead - about 25%

here I will post my results from a test which I ran to check how much time
adds zend_db_table to my code..

In
http://zfsite.andreinikolov.com/2008/08/zend_db_table-time-overhead-about-25-percents/
http://zfsite.andreinikolov.com/2008/08/zend_db_table-time-overhead-about-25-percents/
this post in my blog I have posted the full code for the tests and have
described exactly what I have done. Here I will post just the results and
the conclusion.

I will be happy if you have notes, arguments and remarks. If I miss
something about Zend_Db_Table and do not use it in the best way - please do
not hesitate to comment :)

I ran the test in 4 different variants. These 4 variants proved to
distinguish one from another in the time they took to run.
These 4 variants are:
1) using Zend_Db_Table without metadata cache
2) using Zend_Db_Table with APC as metadata cache
3) writing the SQL queries directly in the controller, using direct
Zend_Db_Adapter_Mysqli
4) writing the SQL queries in Model classes, using direct
Zend_Db_Adapter_Mysqli

I tested with level of concurency 5 with 100 requests (ab -c 5 -n 100)
Requests per second:
method 3 - writing the SQL queries directly in the controller, using direct
Zend_Db_Adapter_Mysqli: 12.93 rps
method 4 - writing the SQL queries in Model classes, using direct
Zend_Db_Adapter_Mysqli: 12.66 rps
method 2 - using Zend_Db_Table with APC as metadata cache: 10.2 rps
method 1 - using Zend_Db_Table without metadata cache 9.2 rps

conclusion: Zend_Db_Table is not good for heavy loaded web applications. My
personal choice is to go with something like variant 4. The time overhead
here is minimal and the code in the controller is most readable.
--
View this message in context: http://www.nabble.com/Zend_Db_Table-time-overhead---about-25--tp19203345p19203345.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Problem with DocType plugin not found?

Because your local machine is Windows, which is not case sensitive, and your testing server is Linux which is case sensitive. I ran into the same problem before :-)

On Thu, Aug 28, 2008 at 11:20 AM, GJ Bogaerts <gj@zigg.nl> wrote:

That's interesting: it worked! Thanks a bunch!

Any idea why the casing would'nt make a difference locally, but be important
on the testing server?

Thanks again!



Wrong casing, try (lowercase "t"):

$view->doctype('XHTML1_STRICT');

On Thu, Aug 28, 2008 at 11:01 AM, GJ Bogaerts <gj@zigg.nl> wrote:

--
View this message in context: http://www.nabble.com/Problem-with-DocType-plugin-not-found--tp19202496p19202863.html
Sent from the Zend MVC mailing list archive at Nabble.com.




--
Bradley Holt
bradley.holt@foundline.com

Re: [fw-mvc] Problem with DocType plugin not found?

That's interesting: it worked! Thanks a bunch!

Any idea why the casing would'nt make a difference locally, but be important
on the testing server?

Thanks again!

Wrong casing, try (lowercase "t"):

$view->doctype('XHTML1_STRICT');

On Thu, Aug 28, 2008 at 11:01 AM, GJ Bogaerts <gj@zigg.nl> wrote:

--
View this message in context: http://www.nabble.com/Problem-with-DocType-plugin-not-found--tp19202496p19202863.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Problem with DocType plugin not found?

Wrong casing, try (lowercase "t"):

$view->doctype('XHTML1_STRICT');

On Thu, Aug 28, 2008 at 11:01 AM, GJ Bogaerts <gj@zigg.nl> wrote:

Hi all,

I've got a problem that has cost me a good part of my day.

In my bootstrap-method setupView I've this piece of code:

               $view = new Zend_View();
               $view->setEncoding('utf-8');
               $view->docType('XHTML1_STRICT');

On my local machine, that works perfectly.

On the testing environment, I get this exception thrown:

Plugin by name DocType was not found in the registry.
#0 /home/volkskra/www/lib_vk/php/Zend_1.6_RC2/Zend/View/Abstract.php(1114):
Zend_Loader_PluginLoader->load('DocType')
#1 /home/volkskra/www/lib_vk/php/Zend_1.6_RC2/Zend/View/Abstract.php(545):
Zend_View_Abstract->_getPlugin('helper', 'docType')
#2 /home/volkskra/www/lib_vk/php/Zend_1.6_RC2/Zend/View/Abstract.php(312):
Zend_View_Abstract->getHelper('docType')
#3 [internal function]: Zend_View_Abstract->__call('docType', Array)
#4 /home/volkskra/www/studeerwijzer/application/Bootstrap.php(90):
Zend_View->docType('XHTML1_STRICT')
#5 /home/volkskra/www/studeerwijzer/application/Bootstrap.php(30):
Bootstrap::setupView()
#6 /home/volkskra/www/studeerwijzer/application/Bootstrap.php(13):
Bootstrap::prepare()
#7 /home/volkskra/www/studeerwijzer/public/index.php(10): Bootstrap::run()
#8 {main}

I use the same versions on my local development machine and the testing
environment of the hosting company: 1.6 RC 2, as confirmed by a call to
Zend_Version::VERSION.

The only include-path I've set is to my own application, plus the ZF
Library.

I've made sure the entire ZF Library is available on that location; I see
the file Doctype.php sitting there in view/helper.
I'm also sure the library is found; other ZF-classes and functions perform
as expected.

The only noticeable difference is the PHP version and OS: locally I've got
5.2.3 on Windows XP, on my testing machine I've got some Linux distro with
PHP 5.1.6

Thanks for any help!

GJ

--
View this message in context: http://www.nabble.com/Problem-with-DocType-plugin-not-found--tp19202496p19202496.html
Sent from the Zend MVC mailing list archive at Nabble.com.




--
Bradley Holt
bradley.holt@foundline.com

[fw-mvc] Problem with DocType plugin not found?

Hi all,

I've got a problem that has cost me a good part of my day.

In my bootstrap-method setupView I've this piece of code:

$view = new Zend_View();
$view->setEncoding('utf-8');
$view->docType('XHTML1_STRICT');

On my local machine, that works perfectly.

On the testing environment, I get this exception thrown:

Plugin by name DocType was not found in the registry.
#0 /home/volkskra/www/lib_vk/php/Zend_1.6_RC2/Zend/View/Abstract.php(1114):
Zend_Loader_PluginLoader->load('DocType')
#1 /home/volkskra/www/lib_vk/php/Zend_1.6_RC2/Zend/View/Abstract.php(545):
Zend_View_Abstract->_getPlugin('helper', 'docType')
#2 /home/volkskra/www/lib_vk/php/Zend_1.6_RC2/Zend/View/Abstract.php(312):
Zend_View_Abstract->getHelper('docType')
#3 [internal function]: Zend_View_Abstract->__call('docType', Array)
#4 /home/volkskra/www/studeerwijzer/application/Bootstrap.php(90):
Zend_View->docType('XHTML1_STRICT')
#5 /home/volkskra/www/studeerwijzer/application/Bootstrap.php(30):
Bootstrap::setupView()
#6 /home/volkskra/www/studeerwijzer/application/Bootstrap.php(13):
Bootstrap::prepare()
#7 /home/volkskra/www/studeerwijzer/public/index.php(10): Bootstrap::run()
#8 {main}

I use the same versions on my local development machine and the testing
environment of the hosting company: 1.6 RC 2, as confirmed by a call to
Zend_Version::VERSION.

The only include-path I've set is to my own application, plus the ZF
Library.

I've made sure the entire ZF Library is available on that location; I see
the file Doctype.php sitting there in view/helper.
I'm also sure the library is found; other ZF-classes and functions perform
as expected.

The only noticeable difference is the PHP version and OS: locally I've got
5.2.3 on Windows XP, on my testing machine I've got some Linux distro with
PHP 5.1.6

Thanks for any help!

GJ

--
View this message in context: http://www.nabble.com/Problem-with-DocType-plugin-not-found--tp19202496p19202496.html
Sent from the Zend MVC mailing list archive at Nabble.com.

RE: [fw-webservices] Zend_Soap_Client: use custom _soapClient object?

This seems to be just what I needed!

 

I will check it out soon.

 

Dieter

 

From: Alexander Veremyev [mailto:alexander.v@zend.com]
Sent: woensdag 27 augustus 2008 9:47
To: Dieter Devlieghere; fw-webservices@lists.zend.com
Subject: RE: [fw-webservices] Zend_Soap_Client: use custom _soapClient object?

 

Hi Deiter,

 

Internal structure of Zend_Soap_Client was a bit changed with just released ZF 1.6.0 RC3

 

Zend_Soap_Client has _doRequest() method which may be overridden in children.

See Zend_Soap_Client_Local as an example.

 

 

PS Two additional methods intended to customize client behavior are _preProcessArguments() and _preProcessResult(). They are automatically invoked during a request.

 

With best regards,

   Alexander Veremyev.

 


From: Dieter Devlieghere [mailto:dieter.devlieghere@extendit.be]
Sent: Wednesday, August 20, 2008 6:34 PM
To: fw-webservices@lists.zend.com
Subject: [fw-webservices] Zend_Soap_Client: use custom _soapClient object?

 

Hi,

 

Is it possible to somehow override the __doRequest method of the _soapClient property of Zend_Soap_Client?

 

We have an issue where the soap server has problems with empty nodes and I would like to remove possible empty nodes on __doRequest()…

 

It seems kind of stupid to subclass Zend_Soap_Client only to use a different object as _soapClient (and rewrite the entire Zend_Soap_Client::_initSoapClientObject method)?

 

Regards,

Dieter Devlieghere

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.6.6/1621 - Release Date: 19.08.2008 18:53

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.6.9/1636 - Release Date: 26/08/2008 19:09

Re: [fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

Tobias Gies wrote:
>
> Hi Václav,
>
> as an educated guess, I'd say you did not tell Zend_Form to use the view
> you
> added your custom helpers to. Search Zend_Form::setView() in the docs :-).
>
> Best regards
> Tobias
>
> 2008/8/27 Václav Vaník <vanik@walk.cz>
>
>>
>> OK, I create my own:
>>
>> Walk_View_Helper_FormMultiCheckboxFilter extends
>> Zend_View_Helper_FormMultiCheckbox
>>
>> I added path to helper in bootstrap:
>>
>> $view->addHelperPath(ROOT_DIR . '/app/valhalla/helpers',
>> 'Walk_View_Helper');
>>
>> Then I set decorator to multicheckbox element:
>>
>> $checkbox->setDecorators(array('ViewHelper', array('helper' =>
>> 'formMultiCheckboxFilter')));
>>
>> but when I render form I get error:
>>
>> Warning: Plugin by name FormMultiCheckboxFilter was not found in the
>> registry. in /path/library/Zend/Form/Element.php on line 1892
>>
>> How could I fix it?
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19183452.html
>> Sent from the Zend MVC mailing list archive at Nabble.com.
>>
>>
>
>

Damn, you're right :)

I set to form the view, which i defined in bootstrap, but it still doesnt
work, it throws same warning.

My form is defined:

$form = new Zend_Form();
$form->setAction($this->view->url(array('controller' => 'user'),
null, true))
->setMethod(Zend_Form::METHOD_GET)
->setAttrib('id', 'indexUser')
->setElementFilters(array('StringTrim'))
->setView($this->_helper->viewRenderer->view)
->setDecorators(array(array('viewScript', array('viewScript' =>
'user/index-form.phtml'))));

$id = $form->createElement('text', 'fId', array('size' =>
1));

$firstname = $form->createElement('text', 'fFirstname',
array('size' => 12));
$lastname = $form->createElement('text', 'fLastname', array('size'
=> 12));

$checkAll = $form->createElement('checkbox', 'checkAll');
$checkbox = $form->createElement('multiCheckbox', 'checkboxIds')
->setDecorators(array('ViewHelper',
array('helper' => 'formMultiCheckboxFilter')));

$submit = $form->createElement('submit',
'sent')->setLabel('filtrovat');
$command = $form->createElement('submit',
'command')->setLabel('provést');

$form->addElement($id)
->addElement($firstname)
->addElement($lastname)
->addElement($checkAll)
->addElement($submit)
->addElement($command)
->setElementDecorators(array('ViewHelper'))
->addElement($checkbox);
--
View this message in context: http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19196844.html
Sent from the Zend MVC mailing list archive at Nabble.com.

2008年8月27日星期三

Re: [fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

Hi Václav,

as an educated guess, I'd say you did not tell Zend_Form to use the view you added your custom helpers to. Search Zend_Form::setView() in the docs :-).

Best regards
Tobias

2008/8/27 Václav Vaník <vanik@walk.cz>

OK, I create my own:

Walk_View_Helper_FormMultiCheckboxFilter extends
Zend_View_Helper_FormMultiCheckbox

I added path to helper in bootstrap:

$view->addHelperPath(ROOT_DIR . '/app/valhalla/helpers',
'Walk_View_Helper');

Then I set decorator to multicheckbox element:

$checkbox->setDecorators(array('ViewHelper', array('helper' =>
'formMultiCheckboxFilter')));

but when I render form I get error:

Warning: Plugin by name FormMultiCheckboxFilter was not found in the
registry. in /path/library/Zend/Form/Element.php on line 1892

How could I fix it?


--
View this message in context: http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19183452.html
Sent from the Zend MVC mailing list archive at Nabble.com.


Re: [fw-auth] LDAP - following referrals

Hi Mike,

The patch is from ZF-2994, Allow for anonymous bind in Zend_Ldap.

Thanks,
Mike

On Wed, Aug 27, 2008 at 1:55 PM, Michael B Allen <ioplex@gmail.com> wrote:
> Ok. Thanks.
>
> I'm curious though, what is the "bindAnonymously" patch?
>
> Mike
>

Re: [fw-auth] LDAP - following referrals

Ok. Thanks.

I'm curious though, what is the "bindAnonymously" patch?

Mike

On Wed, Aug 27, 2008 at 1:00 PM, Mike Mercier <mmercier@gmail.com> wrote:
> Hi Mike,
>
> Your suggestion resolves the issue I am seeing. Issue ZF-4092 has
> been opened as requested.
>
> Thanks,
> Mike
>
> On Wed, Aug 27, 2008 at 12:16 PM, Michael B Allen <ioplex@gmail.com> wrote:
>>
>> On Wed, Aug 27, 2008 at 9:46 AM, Mike Mercier <mmercier@gmail.com> wrote:
>> > when I look at the /tmp/ldap.log file, I see the following:
>> >
>> > <date> DEBUG (7): Ldap: 2: someuser authentication failed: 0x20: Referral:
>> > (uid=someuser)
>> >
>> > Is there some way to have Zend_Auth_Adapter_Ldap follow the Referral?
>> >
>> > I have tried the following with no success:
>> >
>> > $adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);
>> > ldap_set_options($adapter->getLdap()->getResource(), LDAP_OPT_REFERRALS, 1);
>> > $result = $auth->authenicate($adapter)
>>
>> That won't work since LDAP_OPT_REFERRALS is unconditionally turned off
>> in Zend_Ldap::connect() which occurs after authenticate().
>>
>> Try flipping on LDAP_OPT_REFERRALS in Zend/Ldap.php around line 631.
>>
>> If it works, please create a tracker issue requesting that the
>> referrals option be made optional and I'll create a proper patch.
>>
>> Mike
>>
>> --
>> Michael B Allen
>> PHP Active Directory SPNEGO SSO
>> http://www.ioplex.com/
>

--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/

Re: [fw-db] Out of memory error

monk.e.boy wrote:
>
> $sqlxx = <<<EOT
> SELECT
> FORMAT(seconds_to_download,2) as secs
> FROM page
> EOT;
> Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to
> allocate 1431655772 bytes) in
> /usr/local/lib/php/Zend/Db/Statement/Mysqli.php on line 254
>

The Mysqli adapter has a known problem with the LONGTEXT data type
(http://framework.zend.com/issues/browse/ZF-1498). This problem is
unresolved, but the workaround is to use TEXT, MEDIUMTEXT or VARCHAR,
because the problem does not occur with other data types.

In MySQL, FORMAT() called on a FLOAT column returns a field of type
LONGTEXT. You can verify this by capturing the output in a temporary table
and get metadata for the resulting temp table:

CREATE TEMPORARY TABLE tempresult
SELECT FORMAT(seconds_to_download,2) AS secs FROM page;
DESCRIBE tempresult;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| secs | longtext | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
1 row in set (0.01 sec)

You can wrap your call to FORMAT() inside CAST() to change its return value
to an ordinary string data type:

CREATE TEMPORARY TABLE tempresult
SELECT CAST(FORMAT(seconds_to_download,2) AS CHAR(20)) AS secs FROM page;
DESCRIBE tempresult;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| secs | varchar(20) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.00 sec)

Oddly, even though I specified CHAR(20), it produced a VARCHAR(20).

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Out-of-memory-error-tp19108319p19185386.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-auth] LDAP - following referrals

Hi Mike,

Your suggestion resolves the issue I am seeing. Issue ZF-4092 has
been opened as requested.

Thanks,
Mike

On Wed, Aug 27, 2008 at 12:16 PM, Michael B Allen <ioplex@gmail.com> wrote:
>
> On Wed, Aug 27, 2008 at 9:46 AM, Mike Mercier <mmercier@gmail.com> wrote:
> > when I look at the /tmp/ldap.log file, I see the following:
> >
> > <date> DEBUG (7): Ldap: 2: someuser authentication failed: 0x20: Referral:
> > (uid=someuser)
> >
> > Is there some way to have Zend_Auth_Adapter_Ldap follow the Referral?
> >
> > I have tried the following with no success:
> >
> > $adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);
> > ldap_set_options($adapter->getLdap()->getResource(), LDAP_OPT_REFERRALS, 1);
> > $result = $auth->authenicate($adapter)
>
> That won't work since LDAP_OPT_REFERRALS is unconditionally turned off
> in Zend_Ldap::connect() which occurs after authenticate().
>
> Try flipping on LDAP_OPT_REFERRALS in Zend/Ldap.php around line 631.
>
> If it works, please create a tracker issue requesting that the
> referrals option be made optional and I'll create a proper patch.
>
> Mike
>
> --
> Michael B Allen
> PHP Active Directory SPNEGO SSO
> http://www.ioplex.com/

Re: [fw-auth] LDAP - following referrals

On Wed, Aug 27, 2008 at 9:46 AM, Mike Mercier <mmercier@gmail.com> wrote:
> when I look at the /tmp/ldap.log file, I see the following:
>
> <date> DEBUG (7): Ldap: 2: someuser authentication failed: 0x20: Referral:
> (uid=someuser)
>
> Is there some way to have Zend_Auth_Adapter_Ldap follow the Referral?
>
> I have tried the following with no success:
>
> $adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);
> ldap_set_options($adapter->getLdap()->getResource(), LDAP_OPT_REFERRALS, 1);
> $result = $auth->authenicate($adapter)

That won't work since LDAP_OPT_REFERRALS is unconditionally turned off
in Zend_Ldap::connect() which occurs after authenticate().

Try flipping on LDAP_OPT_REFERRALS in Zend/Ldap.php around line 631.

If it works, please create a tracker issue requesting that the
referrals option be made optional and I'll create a proper patch.

Mike

--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/

Re: [fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

OK, I create my own:

Walk_View_Helper_FormMultiCheckboxFilter extends
Zend_View_Helper_FormMultiCheckbox

I added path to helper in bootstrap:

$view->addHelperPath(ROOT_DIR . '/app/valhalla/helpers',
'Walk_View_Helper');

Then I set decorator to multicheckbox element:

$checkbox->setDecorators(array('ViewHelper', array('helper' =>
'formMultiCheckboxFilter')));

but when I render form I get error:

Warning: Plugin by name FormMultiCheckboxFilter was not found in the
registry. in /path/library/Zend/Form/Element.php on line 1892

How could I fix it?


--
View this message in context: http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19183452.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-core] Zend_Form_Element 'name' and brackets.

On Wed, Aug 27, 2008 at 16:48, Matthew Weier O'Phinney <matthew@zend.com> wrote:
> You *could* put them in a subform, which would automatically create the
> namespacing... but using numbers for element names within Zend_Form is a
> no-no (element names need to be valid variable names, and variable names
> cannot begin with numbers).

Ok thanks, I understnad.

--
Paweł Chuchmała
pawel.chuchmala at gmail dot com

Re: [fw-core] Zend_Form_Element 'name' and brackets.

-- Paweł Chuchmała <pawel.chuchmala@gmail.com> wrote
(on Wednesday, 27 August 2008, 04:29 PM +0200):
> On Wed, Aug 27, 2008 at 16:23, Matthew Weier O'Phinney <matthew@zend.com> wrote:
> >
> > -- Paweł Chuchmała <pawel.chuchmala@gmail.com> wrote
> >
> > > Problem is that Zend_Form_Element call filterName with 'allowBrackets' = flase.
> > > Why?
> > > For Zend_Form_Element_Multicheckbox brackets are allowed, so why not for all
> > > elements?
> >
> > Set the "isArray" property of the element:
> >
> > $element->setIsArray(true);
> >
> > This will append [] to the name.
>
> Ok, but if i want not only name[], but: name[12], name[43] ?

Won't work with Zend_Form.

You *could* put them in a subform, which would automatically create the
namespacing... but using numbers for element names within Zend_Form is a
no-no (element names need to be valid variable names, and variable names
cannot begin with numbers).

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-core] Zend_Form_Element 'name' and brackets.

On Wed, Aug 27, 2008 at 16:23, Matthew Weier O'Phinney <matthew@zend.com> wrote:
>
> -- Paweł Chuchmała <pawel.chuchmala@gmail.com> wrote
>
> > Problem is that Zend_Form_Element call filterName with 'allowBrackets' = flase.
> > Why?
> > For Zend_Form_Element_Multicheckbox brackets are allowed, so why not for all
> > elements?
>
> Set the "isArray" property of the element:
>
> $element->setIsArray(true);
>
> This will append [] to the name.

Ok, but if i want not only name[], but: name[12], name[43] ?

--
Paweł Chuchmała
pawel.chuchmala at gmail dot com

Re: [fw-core] Zend_Form_Element 'name' and brackets.

-- Paweł Chuchmała <pawel.chuchmala@gmail.com> wrote
(on Wednesday, 27 August 2008, 01:31 PM +0200):
> I want to create form with some checkbox. I need to get chceckbox values as
> array with
> specified keys. I create this form by my class extended Zend_Form, and add
> fields in init()
> method.
>
> Problem is that Zend_Form_Element call filterName with 'allowBrackets' = flase.
> Why?
> For Zend_Form_Element_Multicheckbox brackets are allowed, so why not for all
> elements?

Set the "isArray" property of the element:

$element->setIsArray(true);

This will append [] to the name.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

-- Václav Vaník <vanik@walk.cz> wrote
(on Wednesday, 27 August 2008, 06:41 AM -0700):
> I want to render multicheckbox with view helper only (no label decorator)
>
> my form is:
>
> $form = new Zend_Form();
> $multi = $form->createElement('multiCheckbox', 'foo');
> $form->addElement($multi)->setElementDecorators(array('ViewHelper'));
>
> and rendered checkbox is inside label
>
> I tried:
>
> $multi = $form->createElement('multiCheckbox', 'foo');
> $multi->setDecorators(array('ViewHelper'));
>
> but result is with label :(

MultiCheckbox generates labels for each checkbox -- this is not part of
decoration, but generated via the view helper itself.

You can create your own MultiCheckbox view helper to drop in as a
replacement if you need to customize the HTML output.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-db] Update with where clause!!

The other option i think i would use is to have a query function with the
sql query in it. Then i dont have to worry about bugs with arrays and stuff

so something like
$sql = $db->quoteInto('Update MemEvents SET IsActive= 1 WHERE EventID
=?',$requestEvent ).$db->quoteInto('AND MemberID=?',$requestMember);
$query = $db->query($sql);
...

I definitely would prefer this going the PDO route...

Bill Karwin wrote:
>
>
>
> dele454 wrote:
>>
>> Hi am trying to use the update() of the Zend_Db class for 2 conditions
>> that must be true for the update to take place:
>>
>>
>> $where[] = "EventID = ' ". $requestEvent ."'";
>> $where[] = "MemberID = ' ". $requestMember ."'";
>> $db->update('memevents', $updateColumn,$where);
>>
>> Wherever i run this code my view appears blank. The only thing that makes
>> this code different from that in the ZF doc is that i am inserting
>> parameters from the URL into mine.
>>
>> I dont know why this isnt working strangely when i comment out on of the
>> array declarations then the code runs. :( But i need both conditions!!
>>
>>
>>
>
> Unfortunately not all methods consistently support an array for the
> where-clause parameter.
> This is a long-desired enhancement and there is a bug logged for it:
> http://framework.zend.com/issues/browse/ZF-1726
>
> You can work around this by joining your array into a string:
>
> $where[] = "EventID = ' ". $requestEvent ."'";
> $where[] = "MemberID = ' ". $requestMember ."'";
> $db->update('memevents', $updateColumn, join(' AND ', $where));
>
> Be careful to put spaces in the ' AND ' string, and use parentheses to
> clarify precedence if each term contains OR expressions.
>
> Regards,
> Bill Karwin
>


-----
dee
--
View this message in context: http://www.nabble.com/Update-with-where-clause%21%21-tp19180609p19181511.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Update with where clause!!

Thanks Bill i knew you would have an answer to it :)

dele454 wrote:
>
> Hi am trying to use the update() of the Zend_Db class for 2 conditions
> that must be true for the update to take place:
>
>
> $where[] = "EventID = ' ". $requestEvent ."'";
> $where[] = "MemberID = ' ". $requestMember ."'";
> $db->update('memevents', $updateColumn,$where);
>
> Wherever i run this code my view appears blank. The only thing that makes
> this code different from that in the ZF doc is that i am inserting
> parameters from the URL into mine.
>
> I dont know why this isnt working strangely when i comment out on of the
> array declarations then the code runs. :( But i need both conditions!!
>
>
>


-----
dee
--
View this message in context: http://www.nabble.com/Update-with-where-clause%21%21-tp19180609p19181377.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-auth] LDAP - following referrals

Hello,

I have an issue with Zend_Auth_Adapter_Ldap..

A bit of backgroud...

Zend Framework version 1.5.3
php5 -v : PHP 5.2.5 with Suhosin-Patch 0.9.6.2  Zend Engine v2.2.0
OS: SLES 10 SP2

My site has multiple LDAP servers.  Some of these servers can potentially return a "Referral" when searching for specific data for a user.
For example (using ldapsearch):

ldapsearch -b -o=myorg -h ldap-server1 -Z -x '(uid=someuser)' dn
this returns:

search: 3
result: 10 Referral
ref: ldaps://ldap-server2/o=myorg
ref: ldaps://ldap-server3/o=myorg
ref: ldaps://ldap-server4/o=myorg

If I add the -C option to above, I will get the dn for "someuser", cn=someuser,o=myorg

When using Zend_Auth_Adapter_Ldap and following the basic instructions at http://framework.zend.com/manual/en/zend.auth.adapter.ldap.html for authentication, when I look at the /tmp/ldap.log file, I see the following:

<date> DEBUG (7): Ldap: 2: someuser authentication failed: 0x20: Referral: (uid=someuser)

Is there some way to have Zend_Auth_Adapter_Ldap follow the Referral?

I have tried the following with no success:

$adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);
ldap_set_options($adapter->getLdap()->getResource(), LDAP_OPT_REFERRALS, 1);
$result = $auth->authenicate($adapter)

Note, my Zend_Config_Ini configuration for contains the following

ldap.server1.host = ldap-server1
ldap.server1.useSsl = true
ldap.server1.baseDn = o=myorg
ldap.server1.accountFilterFormat = "(uid=%s)"
ldap.server1.bindRequireDn = true

Is there a way to make the adapter follow the "Referral"?  Is there something that need to be configured externally?

Thanks,
Mike

[fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

Hi,

I want to render multicheckbox with view helper only (no label decorator)

my form is:

$form = new Zend_Form();
$multi = $form->createElement('multiCheckbox', 'foo');
$form->addElement($multi)->setElementDecorators(array('ViewHelper'));

and rendered checkbox is inside label

I tried:

$multi = $form->createElement('multiCheckbox', 'foo');
$multi->setDecorators(array('ViewHelper'));

but result is with label :(

I have ZF 1.6RC2
--
View this message in context: http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19181211.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-db] Update with where clause!!

dele454 wrote:
>
> Hi am trying to use the update() of the Zend_Db class for 2 conditions
> that must be true for the update to take place:
>
>
> $where[] = "EventID = ' ". $requestEvent ."'";
> $where[] = "MemberID = ' ". $requestMember ."'";
> $db->update('memevents', $updateColumn,$where);
>
> Wherever i run this code my view appears blank. The only thing that makes
> this code different from that in the ZF doc is that i am inserting
> parameters from the URL into mine.
>
> I dont know why this isnt working strangely when i comment out on of the
> array declarations then the code runs. :( But i need both conditions!!
>
>
>

Unfortunately not all methods consistently support an array for the
where-clause parameter.
This is a long-desired enhancement and there is a bug logged for it:
http://framework.zend.com/issues/browse/ZF-1726

You can work around this by joining your array into a string:

$where[] = "EventID = ' ". $requestEvent ."'";
$where[] = "MemberID = ' ". $requestMember ."'";
$db->update('memevents', $updateColumn, join(' AND ', $where));

Be careful to put spaces in the ' AND ' string, and use parentheses to
clarify precedence if each term contains OR expressions.

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Update-with-where-clause%21%21-tp19180609p19181103.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] zend_db_table_row and quoting

tony stamp wrote:
>
> Hello
>
> Just a quick question - when updating a row in a database, i usually do:
>
> $query = "update foo set bar = ?, baz = ?, goon = ?";
> $sth->execute($query, array('a', 'b', 'c');
>
> where i know that the db abstraction layer will apply quoting to make the
> values safe.
>

You have misunderstood. The code you show does not do quoting, it treats
the values as query parameters. Parameters are not interpolated into the
SQL string, so parameters don't require quoting.

It's a bit confusing, because methods like quoteInto() use the ? character
as an interpolation placeholder, while SQL also uses ? as a parameter
placeholder.


tony stamp wrote:
>
> ... will quoting also be applied to the row before saving, or is that the
> responsibility of the row to implement ie subclassing and performing
> validation on the properties before an update?
>

The $row->save() method uses $db->update() internally, so it gains the same
benefits of query parameters. It does use quoting for the WHERE clause of
the update, but it performs quoting for you in that case.

One exception: if you have set one of the row fields to a Zend_Db_Expr, you
are responsible for quoting. For example, suppose you want to update the
row but make sure a very long string is shortened instead of exceeding the
field length in the database, you can use a SQL expression like this:

$row->name = $name;
$row->surname = new Zend_Db_Expr($db->quoteInto('SUBSTRING(?, 0, 10)',
$surname));
$row->save();

You have to use Zend_Db_Expr because otherwise the entire expression
starting with 'SUBSTRING(...' will be treated as the new surname. But once
you use Zend_Db_Expr, the update will interpolate it into the SQL statement
instead of using a query parameter. Thus you are responsible for quoting
any strings you interpolate into the expression.

The result will be SQL:

UPDATE tablename
SET name = ?, -- note query parameter placeholder
surname = SUBSTRING('O\'Reilly', 0, 10) -- note quoting and escaping has
been done
WHERE primarykey = 1234;

Then it executes the query, passing $name as the sole query parameter to
execute().

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/zend_db_table_row-and-quoting-tp19177390p19180753.html
Sent from the Zend DB mailing list archive at Nabble.com.