[fw-general] Problem with ZF2 exceptions and SPL exception inheritance

2011-05-22 Thread Justin Hendrickson
I've been looking at the ZF2 exception proposal and trying to wrap my head
around all the use cases involved in it. For the most part, it makes perfect
sense, except when a component wants to have exceptions classes for two SPL
exceptions and one of those SPL exceptions extends the other. Since you have
to extend the SPL exception in both cases, the child component exception
class cannot extend the parent component exception class. The end result is
that you cannot catch the parent component exception class and expect the
catch the child component exception class.

I don't think I did a very good job explaining the issue, so here's an
example: \Zend\Search\Lucene\Exception\RuntimeException and
\Zend\Search\Lucene\Exception\OutOfBoundsException both extend their
respective SPL exception classes. \OutOfBoundException extends
\RuntimeException, so you if you try to catch \RuntimeException, you'll also
catch
\OutOfBoundsException. \Zend\Search\Lucene\Exception\OutOfBoundsException
does not extends \Zend\Search\Lucene\Exception\RuntimeException, so you
cannot catch \Zend\Search\Lucene\Exception\RuntimeException and also
catch \Zend\Search\Lucene\Exception\OutOfBoundsException.

try {
throw new \OutOfBoundsException();
} catch (\RuntimeException $e) {
die(ok);
}
die(not ok);

try {
throw new \Zend\Search\Lucene\Exception\OutOfBoundsException();
} catch (\Zend\Search\Lucene\Exception\RuntimeException $e) {
die(ok);
}
die(not ok);

So what exactly should be done here? It seems like there are two solutions;
1) it's not a valid use cases so ignore it; or 2) it is a valid use cases,
so instead of creating concrete exceptions classes in components that extend
SPL exceptions, marker interfaces have to be created for them and generic
concrete classes be created (ie
\Zend\Search\Lucene\Exception\RuntimeException becomes an interface and
\Zend\Search\Lucene\Exception\GenericRuntimeException becomes a concrete
class that implements the previous marker interface and extends
\RuntimeException)?


Re: [fw-general] Problem with ZF2 exceptions and SPL exception inheritance

2011-05-22 Thread Justin Hendrickson
It's unfortunate that this scheme breaks down in this use case. The problem
I see with the current approach is we're using SPL classnames but not
maintaining their inheritance structures, resulting in some confusion. The
proposal about exceptions in ZF2 should document this breakdown with
something about component exceptions that extend SPL exceptions will not
follow the same inheritance structure as the underlying SPL exception.


Just to clarify one point.


 Alternately, we do as you suggest, and make low-level exceptions, such as
 RuntimeException, interfaces within the ZF hierarchy, allowing for a
 slightly richer experience. However, that means you cannot throw a
 concrete RuntimeException from that component. Trade-offs.


It's still possible, just not very pretty.

interface \Zend\Search\Lucene\Exception\RuntimeException extends
\Zend\Search\Lucene\Exception {}
interface \Zend\Search\Lucene\Exception\OutOfBoundsException extends
\Zend\Search\Lucene\RuntimeException {} // mimics the SPL exception
inheritance tree

class \Zend\Search\Lucene\Exception\GenericRuntimeException extends
\RuntimeException implements \Zend\Search\Lucene\Exception\RuntimeException
{}
class \Zend\Search\Lucene\Exception\GenericOutOfBoundException extends
\GenericOutOfBoundException implements
\Zend\Search\Lucene\Exception\OutOfBoundsException {}

This addresses all the use cases, but now you've got parallel inheritance
structures and well... just look at that mess... let me be the first to say,
yuck.


[fw-general] New Proposal: Zend_Controller_Plugin_SessionExpire

2011-01-23 Thread Justin Hendrickson
Zend_Controller_Plugin_SessionExpire is a Zend_Controller plugin that
provides userland control of session expiration by tracking a users last
access time and redirecting to a custom module/controller/action if a
timeout is exceeded.

http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Plugin_SessionExpire

Any feedback would be appreciated.


[fw-general] Zend_Application_Resource_Smtp is ready for review

2009-12-24 Thread Justin Hendrickson
Hello everyone,

The Zend_Application_Resource_Smtp proposal is ready for review. It is a
simple resource class for the Zend_Mail_Transport_Smtp class. Any feedback
would be appreciated.

The proposal can be found here:
http://framework.zend.com/wiki/display/ZFPROP/Zend_Application_Resource_Smtp+-+Justin+Hendrickson


[fw-general] Zend_Form_Element_File and previewing

2009-04-16 Thread Justin Hendrickson
I'm trying to create a Zend_Form that contains a couple of
Zend_Form_Element_File elements, amongst other things. I want to support
previewing the content before submitting, but I'm not sure how to make the
file elements stick from the preview to the submit. Has anyone found a good
way of handling this?


Re: [fw-general] how to get format action name without Action suffix?

2008-07-09 Thread Justin Hendrickson
Though I too would like to see methods in the dispatcher that would return
the inflected action/controller/module name without the prefix/suffix, it's
pretty easy to get around:

$formatted = $dispatcher-formatActionName($unformatted);
echo preg_replace('/Action$/', $formatted); // option 1
echo substr($formatted, 0, -6); // option 2

On Wed, Jul 9, 2008 at 11:18 AM, Jacky Chen [EMAIL PROTECTED] wrote:

 Hi,

 I want to get the format action name,but there just a method in
 Zend_Controller_Dispatcher_Abstract::formatActionName($unformatted), but it
 return the action name with the Action suffix.

 because action name or controller name can be, get.data,or get-data, for
 example.If i call the method getActionName() with Request,it just return the
 unformatted action name,and i want to test that if there is a getData
 action.

 I think it is convenient if there have a method return the format module(or
 controller,or action)name. There have one,but is protected.



Re: [fw-general] Dojo view helper in incubator and ready for testing

2008-07-08 Thread Justin Hendrickson
I'm pretty sure the problem is that you're trying to use Zend_Form with the
new Dojo view helpers. Zend_Form_Decorator_Form is expecting to call
Zend_View_Helper_Form::form() and when you add the Dojo helpers in,
Zend_Form_Decorator_Form calls Zend_Dojo_View_Helper_Form::form(), which has
a different signature.

If you want to use Zend_Form with the new Zend_Dojo stuff, you can delete
Zend_Dojo_View_Helper_Form or wait until the form stuff has been addressed.

On Tue, Jul 8, 2008 at 8:33 AM, Matthew Weier O'Phinney [EMAIL PROTECTED]
wrote:

 -- philip142au [EMAIL PROTECTED] wrote
 (on Tuesday, 08 July 2008, 06:14 AM -0700):
  Or can you suggest a setup of what version of ZF and what version of
  incubator files works?

 Current incubator works, but until the code is pushed to
 standard/library, the API may be in flux.

 --
 Matthew Weier O'Phinney
 Software Architect   | [EMAIL PROTECTED]
 Zend Framework   | http://framework.zend.com/



Re: [fw-general] Dojo view helper in incubator and ready for testing

2008-07-08 Thread Justin Hendrickson
On a separate note, are their plans for a view helper for the Dijit.Editor
widget? I was playing around with it last week and noticed a problem with
submitting data from a Dijit.Editor (it appears to remove the textarea
from the form) and I was wondering if/how you were going to handle that.

On Tue, Jul 8, 2008 at 10:19 AM, Matthew Weier O'Phinney [EMAIL PROTECTED]
wrote:

 -- Justin Hendrickson [EMAIL PROTECTED] wrote
 (on Tuesday, 08 July 2008, 10:12 AM -0500):
  I'm pretty sure the problem is that you're trying to use Zend_Form with
 the new
  Dojo view helpers. Zend_Form_Decorator_Form is expecting to call
  Zend_View_Helper_Form::form() and when you add the Dojo helpers in,
  Zend_Form_Decorator_Form calls Zend_Dojo_View_Helper_Form::form(), which
 has a
  different signature.
 
  If you want to use Zend_Form with the new Zend_Dojo stuff, you can delete
  Zend_Dojo_View_Helper_Form or wait until the form stuff has been
 addressed.

 Correct -- the dojo elements and decorators are incomplete at this time.
 I should have them working later today. (I was under the impression he
 was using just view helpers, and hence my original answer.)

  On Tue, Jul 8, 2008 at 8:33 AM, Matthew Weier O'Phinney 
 [EMAIL PROTECTED]
  wrote:
 
  -- philip142au [EMAIL PROTECTED] wrote
  (on Tuesday, 08 July 2008, 06:14 AM -0700):
   Or can you suggest a setup of what version of ZF and what version
 of
   incubator files works?
 
  Current incubator works, but until the code is pushed to
  standard/library, the API may be in flux.

 --
 Matthew Weier O'Phinney
 Software Architect   | [EMAIL PROTECTED]
 Zend Framework   | http://framework.zend.com/



Re: [fw-general] PHP 5.2.6 and Zend_Translate

2008-05-28 Thread Justin Hendrickson
I've just run into the same problem. Windows XP, PHP 5.2.6.

I've isolated the problem to line 140:

(Zend_Locale::isLocale((string) $info)

On 5.2.6, (string) $info returns the complete relative pathname
(../languages/en, ../languages/es). On Ubuntu 7.10 w/PHP 5.2.3 and Windows
XP w/PHP 5.2.5 it returns simply the directory name.

On Tue, May 6, 2008 at 3:08 PM, Robert Castley [EMAIL PROTECTED]
wrote:

  WHOOPS! Spoke too soon, forgot to delete my cache.

 Still the same issue, I downloaded with Windows .zip of 5.2.6.
 Php.ini files are the same.

 Maybe there is an issue with the SPL in 5.2.6?

 Cheers,
 - Robert

 -Original Message-
 From: Robert Castley
 Sent: 06 May 2008 20:42
 To: fw-general@lists.zend.com
 Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate

 WOW! You are good!  Learnt another thing about PHP5.

 Sorry to trouble you (again!)

 Cheers,

 - Robert

 -Original Message-
 From: Thomas Weidner [mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
 ]
 Sent: 06 May 2008 20:26
 To: Robert Castley; fw-general@lists.zend.com
 Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate

 Looks like you have not installed SPL.

 Directory scanning works with RecursiveDirectoryIterator and
 RecursiveIteratorIterator.
 When eigther of these two is not available the result would be like
 described from you.

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

 - Original Message -
 From: Robert Castley [EMAIL PROTECTED]
 To: fw-general@lists.zend.com
 Sent: Tuesday, May 06, 2008 9:13 PM
 Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate

  Hi,
 
  In my custom plugin ( http://framework.zend.com/wiki/x/p6o ) I do
  check for the language
 
  snippet
  if (!$translate-isAvailable($locale-getLanguage())) {
 $locale-setLocale('en');
  }
  /snippet
 
  This works fine under PHP 5.2.5.  By adding some trace I see the
  following:
 
  print_r(List languages (getList) : );
  print_r($translate-getList());
 
  HTTP_ACCEPT_LANGUAGE: en-gb
  List languages (getList) : Array
  (
 [de] = de
 [en] = en
 [es] = es
 [fr] = fr
 [it] = it
  )
 
  If I switch to PHP 5.2.6 (and nothing else changes) I get:
 
  print_r(List languages (getList) : );
  print_r($translate-getList());
 
  HTTP_ACCEPT_LANGUAGE: en-gb
  List languages (getList) : Array
  (
 [en_GB] = en_GB
  )
 
  Really strange ... It seems as though with PHP 5.2.6 it won't scan and
  pick up the other languages in the languages directory.
 
  - Robert
 
 
  -Original Message-
  From: Thomas Weidner [mailto:[EMAIL PROTECTED][EMAIL PROTECTED]
 ]
  Sent: 06 May 2008 19:39
  To: Robert Castley; fw-general@lists.zend.com
  Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate
 
  This error is thrown by Zend_Translate when you try to translate a
  language which does not exist.
 
  I got no problem with 5.2.6, and you are free to add a issue.
  But you could help yourself and look which language exists before
  throwing in a new issue.
 
  Greetings
  Thomas Weidner, I18N Team Leader, Zend Framework
  http://www.thomasweidner.com
 
  - Original Message -
  From: Robert Castley [EMAIL PROTECTED]
  To: fw-general@lists.zend.com
  Sent: Tuesday, May 06, 2008 8:31 PM
  Subject: [fw-general] PHP 5.2.6 and Zend_Translate
 
 
  Scanning for language files with Zend_Translate was working
  beautifully with PHP 5.2.5.
 
  Trying out PHP 5.2.6 and this no longer works.  Anyone else found the
  same?
 
  I get the error:
  Fatal error: Uncaught exception 'Zend_Translate_Exception' with
  message 'Language (en) has to be added before it can be used.'
 
 
  I am using my custom Plugin:   http://framework.zend.com/wiki/x/p6o
  http://framework.zend.com/wiki/x/p6o
 
  Shall I log an issue?  Or is this an issue with PHP itself?
 
 
 
  Robert W. Castley
 
  Macro 4
 
 
 
 
 
 
  _
  ___ This email has been scanned for all known viruses by the
  MessageLabs Email
 
  Security Service and the Macro 4 plc internal virus protection system.
  _
  ___
 
 
  __
  __ This email has been scanned for all known viruses by the
  MessageLabs Email Security Service and the Macro 4 plc internal virus
  protection system.
  __
  __
 
 
  __
  __ This email has been scanned for all known viruses by the
  MessageLabs Email Security Service and the Macro 4 plc internal virus
  protection system.
  __
  __

 
 This email has been scanned for all known viruses by the MessageLabs Email
 Security Service and the Macro 4 plc 

Re: [fw-general] PHP 5.2.6 and Zend_Translate

2008-05-28 Thread Justin Hendrickson
Quick follow-up:

Looks like it's a PHP 5.2.6 bug in Windows. I'm able to reproduce the
behavior with:

?php
$iterator = new RecursiveDirectoryIterator('/etc',
RecursiveDirectoryIterator::KEY_AS_PATHNAME);

foreach($iterator as $item) {
echo (string) $item . \n;
}

KEY_AS_PATHNAME is the source of the problem. On 5.2.5 it returns just the
filename and on 5.2.6 it returns the path information with the filename.

On Wed, May 28, 2008 at 11:30 AM, Justin Hendrickson 
[EMAIL PROTECTED] wrote:

 I've just run into the same problem. Windows XP, PHP 5.2.6.

 I've isolated the problem to line 140:

 (Zend_Locale::isLocale((string) $info)

 On 5.2.6, (string) $info returns the complete relative pathname
 (../languages/en, ../languages/es). On Ubuntu 7.10 w/PHP 5.2.3 and Windows
 XP w/PHP 5.2.5 it returns simply the directory name.


 On Tue, May 6, 2008 at 3:08 PM, Robert Castley [EMAIL PROTECTED]
 wrote:

  WHOOPS! Spoke too soon, forgot to delete my cache.

 Still the same issue, I downloaded with Windows .zip of 5.2.6.
 Php.ini files are the same.

 Maybe there is an issue with the SPL in 5.2.6?

 Cheers,
 - Robert

 -Original Message-
 From: Robert Castley
 Sent: 06 May 2008 20:42
 To: fw-general@lists.zend.com
 Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate

 WOW! You are good!  Learnt another thing about PHP5.

 Sorry to trouble you (again!)

 Cheers,

 - Robert

 -Original Message-
 From: Thomas Weidner [mailto:[EMAIL PROTECTED][EMAIL PROTECTED]
 ]
 Sent: 06 May 2008 20:26
 To: Robert Castley; fw-general@lists.zend.com
 Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate

 Looks like you have not installed SPL.

 Directory scanning works with RecursiveDirectoryIterator and
 RecursiveIteratorIterator.
 When eigther of these two is not available the result would be like
 described from you.

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

 - Original Message -
 From: Robert Castley [EMAIL PROTECTED]
 To: fw-general@lists.zend.com
 Sent: Tuesday, May 06, 2008 9:13 PM
 Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate

  Hi,
 
  In my custom plugin ( http://framework.zend.com/wiki/x/p6o ) I do
  check for the language
 
  snippet
  if (!$translate-isAvailable($locale-getLanguage())) {
 $locale-setLocale('en');
  }
  /snippet
 
  This works fine under PHP 5.2.5.  By adding some trace I see the
  following:
 
  print_r(List languages (getList) : );
  print_r($translate-getList());
 
  HTTP_ACCEPT_LANGUAGE: en-gb
  List languages (getList) : Array
  (
 [de] = de
 [en] = en
 [es] = es
 [fr] = fr
 [it] = it
  )
 
  If I switch to PHP 5.2.6 (and nothing else changes) I get:
 
  print_r(List languages (getList) : );
  print_r($translate-getList());
 
  HTTP_ACCEPT_LANGUAGE: en-gb
  List languages (getList) : Array
  (
 [en_GB] = en_GB
  )
 
  Really strange ... It seems as though with PHP 5.2.6 it won't scan and
  pick up the other languages in the languages directory.
 
  - Robert
 
 
  -Original Message-
  From: Thomas Weidner [mailto:[EMAIL PROTECTED][EMAIL PROTECTED]
 ]
  Sent: 06 May 2008 19:39
  To: Robert Castley; fw-general@lists.zend.com
  Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate
 
  This error is thrown by Zend_Translate when you try to translate a
  language which does not exist.
 
  I got no problem with 5.2.6, and you are free to add a issue.
  But you could help yourself and look which language exists before
  throwing in a new issue.
 
  Greetings
  Thomas Weidner, I18N Team Leader, Zend Framework
  http://www.thomasweidner.com
 
  - Original Message -
  From: Robert Castley [EMAIL PROTECTED]
  To: fw-general@lists.zend.com
  Sent: Tuesday, May 06, 2008 8:31 PM
  Subject: [fw-general] PHP 5.2.6 and Zend_Translate
 
 
  Scanning for language files with Zend_Translate was working
  beautifully with PHP 5.2.5.
 
  Trying out PHP 5.2.6 and this no longer works.  Anyone else found the
  same?
 
  I get the error:
  Fatal error: Uncaught exception 'Zend_Translate_Exception' with
  message 'Language (en) has to be added before it can be used.'
 
 
  I am using my custom Plugin:   http://framework.zend.com/wiki/x/p6o
  http://framework.zend.com/wiki/x/p6o
 
  Shall I log an issue?  Or is this an issue with PHP itself?
 
 
 
  Robert W. Castley
 
  Macro 4
 
 
 
 
 
 
  _
  ___ This email has been scanned for all known viruses by the
  MessageLabs Email
 
  Security Service and the Macro 4 plc internal virus protection system.
  _
  ___
 
 
  __
  __ This email has been scanned for all known viruses by the
  MessageLabs Email Security Service and the Macro 4 plc internal virus
  protection system

[fw-general] Timezone recommendations?

2008-05-02 Thread Justin Hendrickson
I'm trying to create a list of translated timezones, but I'm finding the
variety of options pretty overwhelming.

I wanted to avoid having to store GMT offsets and DST flags, and instead
store PHP  area/location values (http://us.php.net/manual/en/timezones.php)
which I could fetch via timezone_identifiers_list() (
http://us.php.net/manual/en/function.timezone-identifiers-list.php), but it
seems to be pretty impractical to display that entire list to end users.
There's a lot of ambiguity in list as well. For example, US/Arizona and
America/Phoenix; America/Havana and Cuba; UTC and UCT. Additionally, PHP
doesn't offer any translations so there was no way I was going to do that
myself.

I thought I'd have a little more luck using Zend_Locale getting
translations, so I looked at the CityToTimezone list. For some reason,
Zend_Locale_Data::getList('en', 'CityToTimezone') only returns three
results. Other locales returned various different counts (es: 83, el: 293),
so I'm a bit confused how to use it. I also tried the WindowsToTimezone list
which seems promising as a compromise of completeness vs usability, but
there were ambiguous entries (US Mountain and Mountain) in the list and none
of the results were coming back translated.

I tried search Google for a bit, but I wasn't able to find any
recommendations or guidelines for timezone selection, so I'm at a dead end.
Any suggestions?


[fw-general] [#ZF-2324] Attachment corruption with MS Exchange

2008-03-31 Thread Justin Hendrickson
Could [#ZF-2324] get some attention? It's been out there for 3.5 months and
still isn't working. It'd be a very simple fix to make the LINELENGTH
configurable. Alternatively, I have access to an MS Exchange server at work,
so I can run tests if needed.


[fw-general] Zend_Form multipage examples?

2008-02-12 Thread Justin Hendrickson
I'm trying to put together a simple Zend_Form setup for a multipaged form,
but the documentation on implementing the multipage part is a bit sparse.
Once the form object is setup with the subforms, what's the right way to
render and validate the subforms and process the results?

This is what I have right now:

?php
require_once 'ApplicationController.php';

require_once 'Zend/Form.php';

class IndexController extends ApplicationController
{

public function siteInformationAction()
{
$subform = $this-_getForm()-getSubForm('site_information');

if ($this-getRequest()-isPost() 
$subform-isValid($this-getRequest()-getPost())) {
return $this-getHelper('redirector')-gotoRoute(
array(
'action' = 'personalInformation'
)
);
}

$this-view-form = $subform;
$this-render('form');
}

public function personalInformationAction()
{
$subform = $this-_getForm()-getSubForm('personal_information');

if ($this-getRequest()-isPost() 
$subform-isValid($this-getRequest()-getPost())) {
var_dump($this-_getForm()-getValues());
exit;
}

$this-view-form = $subform;
$this-render('form');
}

private function _getForm()
{
return new Zend_Form(array(
'method' = 'POST',
'subforms' = array(
'site_information' = new Zend_Form(array(
'elements' = array(
'username' = array(
'text',
array(
'label' = 'Username',
'required' = true,
'validators' = array(
'NotEmpty'
)
)
),
'password' = array(
'password',
array(
'label' = 'Password',
'required' = true,
'validators' = array(
'NotEmpty'
)
)
),
'submit_site_information' = array(
'submit',
array(
'value' = 'Next Page'
)
)
)
)),
'personal_information' = new Zend_Form(array(
'elements' = array(
'name' = array(
'text',
array(
'label' = 'Name',
'required' = true,
'validators' = array(
'NotEmpty'
)
)
),
'street' = array(
'text',
array(
'label' = 'Street',
)
),
'city' = array(
'text',
array(
'label' = 'City'
)
),
'state' = array(
'text',
array(
'label' = 'State'
)
),
'zip' = array(
'text',
array(
'label' = 'Zip'
)
),
'submit_personal_information' = array(
'submit',
array(
'value' = 'Submit'
)
)
)
))
)
));
}

}

Unfortunately, I'm obviously missing something because
var_dump($this-_getForm()-getValues());
is giving me array()
. Is my approach completely off? Also, how do you go about preventing
someone from manually going to the personalInformationAction()?


[fw-general] Re: PHP bug when calling save() on a newly created Zend_Db_Table_Row

2007-08-02 Thread Justin Hendrickson
I'm still looking for some help with this problem. I've experience the
problem with both 1.0.0 and 1.0.1.

If it is indeed a bug within PHP, does anyone have any resources on
how I to do internal stack trace dumps for submitting the bug?

On 8/1/07, Justin Hendrickson [EMAIL PROTECTED] wrote:
 I'm trying to create a row and save it, but I keep getting this error message:
 'Cannot refresh row as parent is missing'

 I tracked the problem down to Zend_Db_Table_Row_Abstract, line 371:
 $primaryKey = $this-_getTable()-insert($this-_data);

 var_dump($primaryKey) shows it's null.

 Backtracking to insert() in Zend_Db_Table_Abstract, line 788:
 return $this-_db-lastInsertId();

 I changed this to:
 $id = $this-_db-lastInsertId();
 var_dump($id);
 return $id;

 This displayed '273', the next auto increment value for the database.

 For some reason, the value is correctly coming back from the
 Zend_Db_Adapter, but something is breaking the return value from
 Zend_Db_Table_Abstract::insert() to
 Zend_Db_Table_Row_Abstract::_doInsert().

 I tested with PHP 5.2.1/Ubuntu 7.04 and PHP 5.2.3/Windows Server 2003 SP2.

 Has anyone else encountered this problem? Can anyone share any insight?



[fw-general] PHP bug when calling save() on a newly created Zend_Db_Table_Row

2007-08-01 Thread Justin Hendrickson
I'm trying to create a row and save it, but I keep getting this error message:
'Cannot refresh row as parent is missing'

I tracked the problem down to Zend_Db_Table_Row_Abstract, line 371:
$primaryKey = $this-_getTable()-insert($this-_data);

var_dump($primaryKey) shows it's null.

Backtracking to insert() in Zend_Db_Table_Abstract, line 788:
return $this-_db-lastInsertId();

I changed this to:
$id = $this-_db-lastInsertId();
var_dump($id);
return $id;

This displayed '273', the next auto increment value for the database.

For some reason, the value is correctly coming back from the
Zend_Db_Adapter, but something is breaking the return value from
Zend_Db_Table_Abstract::insert() to
Zend_Db_Table_Row_Abstract::_doInsert().

I tested with PHP 5.2.1/Ubuntu 7.04 and PHP 5.2.3/Windows Server 2003 SP2.

Has anyone else encountered this problem? Can anyone share any insight?


Re: [fw-general] Operating with file system: OO approach

2007-04-02 Thread Justin Hendrickson

I believe PEAR::VFS would work well for you, based on your description.

http://pear.php.net/package/VFS

On 3/31/07, Ivan Ruiz Gallego [EMAIL PROTECTED] wrote:


Hello,

I am looking for a class or a set of classes that allow an
object-oriented operation with the file system. I am working now with
SPL and I have also taken a look to PEAR, but I haven't so far found a
comprehensive solution. As far as I know is such a library not included
in Zend Framework.

Here my questions:
- Is the inclusion of such functionality planed within Zend Framework?
- Does anyone know about such a library?

Thanks.

Best regards,
Ivan.

--
Loglan GmbH
Ivan Ruiz Gallego

Binzmühlestrasse 210
8050 Zürich
Switzerland

Office +41 44 310 19 20
Mobile +41 76 321 23 68
Net www.loglan.net





Re: [fw-general] Authentication in Mail Class

2007-02-01 Thread Justin Hendrickson

I wrote this a few weeks back and it seems to be working alright. It only
supports AUTH LOGIN and AUTH PLAIN though.

?php
require_once 'Zend/Mail/Transport/Smtp.php';

class My_Zend_Mail_Transport_Smtp_Auth extends Zend_Mail_Transport_Smtp {

   /[EMAIL PROTECTED]
* Authentication types
* @var string
*/
   const LOGIN = 'LOGIN';
   const PLAIN = 'PLAIN';
   /[EMAIL PROTECTED]/

   /**
* @param string $username
* @param string $password
* @param string $method
*/
   protected function authenticate($username, $password, $method =
self::PLAIN) {
   switch($method) {
   case self::LOGIN:
   $this-authenticateLogin($username, $password);
   break;

   case self::PLAIN:
   $this-authenticatePlain($username, $password);
   break;
   }
   }

   /**
* @param  string $username
* @param  string $password
* @throws Zend_Mail_Transport_Exception
*/
   protected function authenticateLogin($username, $password) {
   $this-_send('AUTH LOGIN');

   try {
   $this-_expect(334);
   } catch(Zend_Mail_Transport_Exception $e) {
   if(substr($e-getMessage(), 0, 3) == 503) {
   return;
   }
   throw $e;
   }

   $this-_send(base64_encode($username));
   $this-_expect(334);
   $this-_send(base64_encode($password));
   $this-_expect(235);
   }

   /**
* @param  string $username
* @param  string $password
* @throws Zend_Mail_Transport_Exception
*/
   protected function authenticatePlain($username, $password) {
   $this-_send('AUTH PLAIN');

   try {
   $this-_expect(334);
   } catch(Zend_Mail_Transport_Exception $e) {
   if(substr($e-getMessage(), 0, 3) == 503) {
   return;
   }
   throw $e;
   }

   $this-_send(base64_encode(chr(0) . $username . chr(0) .
$password));
   $this-_expect(235);
   }

}

On 1/31/07, Sanjay Aggarwal [EMAIL PROTECTED] wrote:


 Right Now SMTP authentication is not there in the mail class. Is there
anyone who has implemented SMTP authentication with Zend Framework any how?
If so - do let me know asap. That will be a great help for us.

Regards,
Sanjay Aggarwal



Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-28 Thread Justin Hendrickson
The problem still remains that you can't call a derived classes static method in the base class.abstract class ActiveRecord { abstract static public function getTable(); static public function find() {
 echo self::getTable(); }}class Person extends ActiveRecord { static public function getTable() { return __CLASS__; }}Person::find();Fatal error: Cannot call abstract method ActiveRecord::getTable() in /home/jhendric/test.php on line 7
Call Stack: 0.0004 40688 1. {main}() /home/jhendric/test.php:0 0.0005 40688 2. ActiveRecord::find() /home/jhendric/test.php:20On 9/28/06, 
Matthew Weier O'Phinney [EMAIL PROTECTED] wrote:
-- Davey Shafik [EMAIL PROTECTED] wrote(on Thursday, 28 September 2006, 10:20 AM -0400): And that'll teach me to jump in on a conversation :) What about implementing an interface which specifies a getTable()
 method, then don't implement it in an Abstract AR class. That way when you extend, you write in a: function getTable() { return __CLASS__; }
 or you can even do: function getTable() { return Somethingcompletelydifferent; } I dislike this idea, I prefer just to instantiate the AR class and
 use it as an object :)This type of solution was discussed at one point. I believe it wasrejected because many felt it added what could be construed as one steptoo many in development. Instead of simply:
class MyTable extends Zend_Db_Table {}the developer now has to do:class MyTable extends Zend_Db_Table{public static function getTable(){return __CLASS__;
}}Admittedly not a lot of code, but it's another vector for introducingerrors.I'm not exactly sure where my own preference lies, personally. On Sep 28, 2006, at 10:03 AM, Pavel Shevaev wrote:
  On 9/28/06, Davey Shafik [EMAIL PROTECTED] wrote:   Uh __CLASS__  
   Not really, here's how it all started  http://www.sitepoint.com/forums/showthread.php?t=334377--Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]Zend - The PHP Company | http://www.zend.com/