Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Michael Morris
Those userland solutions (I've written a few myself) send the output as part
of the html file that is being composed, or they write it to a file which
you then later open up.  Which is fine.

This takes advantage of the fact that this CLI client, which will *not* be
running as a daemon, will have an open terminal window for it for as long as
it persists until the process is stopped with CTRL-C.  Sending output to
that terminal window would be *very* useful in my opinion, hence the call
for trace.  Essentially, trace is echo to that terminal window, or
print_r to that window if it is given an object or array.

The userland solutions you mention can later be enhanced to take advantage
of this trace function when they are running in the CLI webserver
environment if their authors so choose.

So can this be done now?  Yes and no - Yes in the sense that, with a little
creative working around, we can get the debug data. No in that the proposed
trace statement has two key properties the userland solutions do not and
CANNOT have:

1) It sends to the CLI webserver terminal if one exists.
2) If one does not exist the statement is discarded like comment text.

On Tue, Apr 19, 2011 at 10:29 PM, David Muir davidkm...@gmail.com wrote:

 I'm not sure if this is needed when there are already solutions for this.
 eg, syslog, error_log, or other userland solutions like Zend_Log,
 sfLogger, etc.

 Cheers,
 David

 On 19/04/11 23:44, Michael Morris wrote:
  Pardon me for following up my own post, but there is room for a range of
  functions here other than trace that could send their output to the
 command
  line where the server was started.
 
  watch ($var) - $var is sent to the console on the line this statement is
  made with the statment now watching 'var'.. init value x, and then
 each
  time it changes it is updated in the console.
 
  traceStack() - as trace, but the current stack is reported.
  traceAll() Return all variables in local scope and the current stack.
  stop() Halt execution as die or exit, unlike them it's arguments are sent
 to
  console instead of browser.
 
  On Tue, Apr 19, 2011 at 10:35 AM, Michael Morris dmgx.mich...@gmail.com
 wrote:
 
  Since the goal of this is debugging might I suggest borrowing a
 statement
  from the Adobe Flash environment:  trace.
 
  Trace sends output to the debug console.  If given a variable it would
  format it as print_r currently does.  When encountered by PHP in other
 modes
  it would be silently ignored.
 
  Thoughts?
 
  On Tue, Apr 19, 2011 at 8:17 AM, Michael Wallner m...@php.net wrote:
 
  On 04/17/2011 01:17 AM, Philip Olson wrote:
 
  Greetings Moriyoshi and all,
 
  Are people still thinking about this? And how about applying the
  current/revised patch to trunk thus making it easier to play with and
  break, but not freeze its features/API yet.
 
  Also the wiki is up again so:
 
- RFC: https://wiki.php.net/rfc/builtinwebserver
- Patch is here: http://gist.github.com/835698
 
  The php_http_* namespace is actually already used by pecl_http?
 
  Regards,
  Mike
 
 
  --
  PHP Internals - PHP Runtime Development Mailing List
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Johannes Schlüter



On 04/20/11 02:05 PM, Michael Morris wrote:

This takes advantage of the fact that this CLI client, which will*not*  be
running as a daemon, will have an open terminal window for it for as long as
it persists until the process is stopped with CTRL-C.  Sending output to
that terminal window would be*very*  useful in my opinion, hence the call
for trace.  Essentially, trace is echo to that terminal window, or
print_r to that window if it is given an object or array.


error_log() output should go there by default. (didn't check the patch) 
you can route everything there. I don't think it's good to add tons of 
extra functions for that.


johannes

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Matthew Weier O'Phinney
On 2011-04-20, Michael Morris dmgx.mich...@gmail.com wrote:
 --e0cb4e43cce199248e04a15872c6
 Content-Type: text/plain; charset=ISO-8859-1

 Those userland solutions (I've written a few myself) send the output
 as part of the html file that is being composed, or they write it to a
 file which you then later open up.  Which is fine.

 This takes advantage of the fact that this CLI client, which will
 *not* be running as a daemon, will have an open terminal window for it
 for as long as it persists until the process is stopped with CTRL-C.
 Sending output to that terminal window would be *very* useful in my
 opinion, hence the call for trace.  Essentially, trace is echo to
 that terminal window, or print_r to that window if it is given an
 object or array.

I'm going to correct one of your assumptions here, which is or they
write it to a file.

Zend_Log has an adapter-based approach to log writers. How the writer
performs its task is up to the developer. We have writers that write to
web services and databases. Our file writer is actually labelled
Stream, because it uses streams.

This means you can use php://stdout to write to.

Additionally, you can have many writers attached to the logger. So, you
could have one writing to a file, and another to STDOUT.

This is all configurable via a factory.

And ZF's solution isn't unique; I've seen other logging solutions that
do similarly. My point is: don't dismiss userland solutions out-of-hand;
they may offer flexibility that a language-based solution cannot
provide.

 The userland solutions you mention can later be enhanced to take
 advantage of this trace function when they are running in the CLI
 webserver environment if their authors so choose.

 So can this be done now?  Yes and no - Yes in the sense that, with a
 little creative working around, we can get the debug data. No in that
 the proposed trace statement has two key properties the userland
 solutions do not and CANNOT have:

 1) It sends to the CLI webserver terminal if one exists.
 2) If one does not exist the statement is discarded like comment text.

As I noted above, you can open a stream to php://stdout. If it's
unavailable, the text is basically discarded.

 On Tue, Apr 19, 2011 at 10:29 PM, David Muir davidkm...@gmail.com wrote:

 I'm not sure if this is needed when there are already solutions for this.
 eg, syslog, error_log, or other userland solutions like Zend_Log,
 sfLogger, etc.

 Cheers,
 David

 On 19/04/11 23:44, Michael Morris wrote:
  Pardon me for following up my own post, but there is room for a range of
  functions here other than trace that could send their output to the
 command
  line where the server was started.
 
  watch ($var) - $var is sent to the console on the line this statement is
  made with the statment now watching 'var'.. init value x, and then
 each
  time it changes it is updated in the console.
 
  traceStack() - as trace, but the current stack is reported.
  traceAll() Return all variables in local scope and the current stack.
  stop() Halt execution as die or exit, unlike them it's arguments are sent
 to
  console instead of browser.
 
  On Tue, Apr 19, 2011 at 10:35 AM, Michael Morris dmgx.mich...@gmail.com
 wrote:
 
  Since the goal of this is debugging might I suggest borrowing a
 statement
  from the Adobe Flash environment:  trace.
 
  Trace sends output to the debug console.  If given a variable it would
  format it as print_r currently does.  When encountered by PHP in other
 modes
  it would be silently ignored.
 
  Thoughts?
 
  On Tue, Apr 19, 2011 at 8:17 AM, Michael Wallner m...@php.net wrote:
 
  On 04/17/2011 01:17 AM, Philip Olson wrote:
 
  Greetings Moriyoshi and all,
 
  Are people still thinking about this? And how about applying the
  current/revised patch to trunk thus making it easier to play with and
  break, but not freeze its features/API yet.
 
  Also the wiki is up again so:
 
- RFC: https://wiki.php.net/rfc/builtinwebserver
- Patch is here: http://gist.github.com/835698
 
  The php_http_* namespace is actually already used by pecl_http?
 
  Regards,
  Mike
 
 
  --
  PHP Internals - PHP Runtime Development Mailing List
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php



 --e0cb4e43cce199248e04a15872c6--


-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] SoapServer::handle some times does not call php_end_ob_buffer

2011-04-20 Thread Konstantin Leboev
Hi all,

In some cases SoapServer::handle does not call php_end_ob_buffer and I can
not call it from php. For example:

class A {
}

$s = new SoapServer(wsdl.wsdl);
$s-setClass(A);

ob_start();
var_dump(ob_get_level()); // int(1)
$s-handle();
var_dump(ob_get_level()); // int(2)
echo ob_get_clean(); // Notice: ob_get_clean(): failed to delete buffer
default output handler

1. When method handle() called without arguments and it is not POST method
2. When unknown compression used or we can't uncompress compressed request.

-- 
Regards,
Konstantin


Re: [PHP-DEV] SoapServer::handle some times does not call php_end_ob_buffer

2011-04-20 Thread Ferenc Kovacs
On Wed, Apr 20, 2011 at 3:29 PM, Konstantin Leboev 
konstantin.leb...@gmail.com wrote:

 Hi all,

 In some cases SoapServer::handle does not call php_end_ob_buffer and I can
 not call it from php. For example:

 class A {
 }

 $s = new SoapServer(wsdl.wsdl);
 $s-setClass(A);

 ob_start();
 var_dump(ob_get_level()); // int(1)
 $s-handle();
 var_dump(ob_get_level()); // int(2)
 echo ob_get_clean(); // Notice: ob_get_clean(): failed to delete buffer
 default output handler

 1. When method handle() called without arguments and it is not POST method
 2. When unknown compression used or we can't uncompress compressed request.

 --
 Regards,
 Konstantin


hi

please report it as a bug on http://bugs.php.net, its easier to keep track
of the problem if its in there.

Tyrael


Re: [PHP-DEV] SoapServer::handle some times does not call php_end_ob_buffer

2011-04-20 Thread Konstantin Leboev
On Wed, Apr 20, 2011 at 5:35 PM, Ferenc Kovacs i...@tyrael.hu wrote:

 please report it as a bug on http://bugs.php.net, its easier to keep track
 of the problem if its in there.


http://bugs.php.net/bug.php?id=54575

-- 
Regards,
Konstantin


Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-20 Thread Ben Schmidt

On 17/04/11 9:14 AM, Ángel González wrote:

Ben Schmidt wrote:

$var = $arr['key'] ?? : 'empty';


Also note this is possible with the recent proposal Hannes and I were
discussing. It simply looks like

$var = $arr?['key'] ?: 'empty';

The ?[ avoids notices and the ?: works as it always has.

Ben.


If it was going to be ?[, I'd much prefer $arr['key'?]. It was proposed as
$arr[?'key'] instead to avoid a backtracking (would that really be
noticeable?
I'd prefer readibility), but ?[ would have the same problem.


The backtracking issue was part of a different proposal where a ternary
operator had an optional 'else' part. It is not an issue with
notice-free array lookups as more recently proposed, and I see no reason
we couldn't use ?[ or [? or ?] as the syntax. In all cases, either that
combination of characters can be scanned as a single token, or the
parsing can be done with just one token of lookahead and no
backtracking. I don't know what kind of parser PHP uses, though, so I'm
just guessing; but AFAICT any standard kind of parser shouldn't have
much trouble here.

The one argument I can find for favouring ?[ or [? is that this
generalises more naturally. Perhaps [? is the best. It generalises
nicely if required:

$array[?'key']
$?variable
$object-?property

I personally only think we need the first one, but there are a few votes
for the second, too. I personally also don't care very much about the
syntax; I'd be equally happy with $array['key'?] or $array?['key']. I'm
just keen to have the functionality (and separately, the !==null
operator(s)).

Ben.




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Dave Ingram
On 04/19/11 15:44, Michael Morris wrote:
 watch ($var) - $var is sent to the console on the line this statement is
 made with the statment now watching 'var'.. init value x, and then each
 time it changes it is updated in the console.
Just my 0.02 as a user, but it strikes me that watch() could be a handy
addition that would be difficult and/or extremely painful to do in userland.


Dave

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Johannes Schlüter



On 04/20/11 04:18 PM, Dave Ingram wrote:

On 04/19/11 15:44, Michael Morris wrote:

watch ($var) -  $var is sent to the console on the line this statement is
made with the statment now watching 'var'.. init value x, and then each
time it changes it is updated in the console.

Just my 0.02 as a user, but it strikes me that watch() could be a handy
addition that would be difficult and/or extremely painful to do in userland.


... but this can be relatively easily be done in a debug extension and 
that's where this belongs.


johannes

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Richard Quadling
On 20 April 2011 15:18, Dave Ingram d...@dmi.me.uk wrote:
 On 04/19/11 15:44, Michael Morris wrote:
 watch ($var) - $var is sent to the console on the line this statement is
 made with the statment now watching 'var'.. init value x, and then each
 time it changes it is updated in the console.
 Just my 0.02 as a user, but it strikes me that watch() could be a handy
 addition that would be difficult and/or extremely painful to do in userland.


 Dave

Being able to watch($var [, ...]), unwatch($var [, ...]) and
trace([bool $start = true]) without a debugger in userland ...

Just like you can overload session handling logic by using
session_set_save_handler(), would something like ...

bool debugging_set_handler(callback $watch, callback $unwatch, callback $trace);

be of use?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] RFC: built-in web server in CLI.

2011-04-20 Thread Richard Quadling
2011/4/20 Johannes Schlüter johan...@schlueters.de:


 On 04/20/11 04:18 PM, Dave Ingram wrote:

 On 04/19/11 15:44, Michael Morris wrote:

 watch ($var) -  $var is sent to the console on the line this statement
 is
 made with the statment now watching 'var'.. init value x, and then
 each
 time it changes it is updated in the console.

 Just my 0.02 as a user, but it strikes me that watch() could be a handy
 addition that would be difficult and/or extremely painful to do in
 userland.

 ... but this can be relatively easily be done in a debug extension and
 that's where this belongs.

 johannes

If the extension could allow for userland interpretation of the debug
events ... then I think that's the best of all worlds.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Function proposal: varset

2011-04-20 Thread Mark
Hi,

This proposal is for the often called line like this:
$var = isset($_GET['var']) ? $_GET['var'] : '';

Only a shorter and imho a cleaner solution to get the same:
$var = varset($_GET['var']);

The implementation for this in PHP code is this:

# Arg 1 = the variable to check for existence
# Arg 2 = the default return value which is an empty string by default

function varset($var, $default = '')
{
return (isset($var) ? $var : $default);
}

However there is a slight issue with this approach. If notices are turned on
this code will generate a notice while i think it should not do that. But
perhaps this approach is to short.
A slightly different implementation (and longer) prevents the notice:

# Arg 1 = the array in which a given key should be checked for existence
# Arg 2 = the key to check in the array from arg 1
# Arg 3 = the default return value which is an empty string by default

function varset($arr, $key, $default = '')
{
return (isset($arr[$key]) ? $arr[$key] : $default);
}

where the call would be:
$var = varset($_GET, 'var');

I personally like both ways...
My proposal is to make this function a core php function in PHP 5.4. The
added benifit is obvious. People can, with this, use a way shorter notation
to validate if a given array element exists. Right now that needs to be done
with a ternary, filter_var or some other method (there are quite a few ways
to check for existence).

I tried to look in the PHP source to see if i could make a patch to add this
but i couldn't find the function that defines the isset function (i wanted
to base it on that). So a pointer to the right location would be nice (along
with docs that tell me what i all need to do to implement a new php
function). If someone else wants to make the implementation, please be my
guest :)

So, what do you think of this?

Regards,
Mark


Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Alain Williams
On Wed, Apr 20, 2011 at 04:55:00PM +0200, Mark wrote:
 Hi,
 
 This proposal is for the often called line like this:
 $var = isset($_GET['var']) ? $_GET['var'] : '';
 
 Only a shorter and imho a cleaner solution to get the same:
 $var = varset($_GET['var']);

It should be called var_set() - better on name space pollution.

 However there is a slight issue with this approach. If notices are turned on
 this code will generate a notice while i think it should not do that. But
 perhaps this approach is to short.
 A slightly different implementation (and longer) prevents the notice:

If is is a language element (like isset()) then you can avoid this problem.

I do find a lot of code, in simple scripts, that does just that.

It might be nice to extend it such that if the 1st argument is a list then the
first in the list which is set is returned, eg:

$var = var_set(($_GET['var'], $_POST['var']), 'default');

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include std_disclaimer.h

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Mark
On Wed, Apr 20, 2011 at 5:12 PM, Alain Williams a...@phcomp.co.uk wrote:

 On Wed, Apr 20, 2011 at 04:55:00PM +0200, Mark wrote:
  Hi,
 
  This proposal is for the often called line like this:
  $var = isset($_GET['var']) ? $_GET['var'] : '';
 
  Only a shorter and imho a cleaner solution to get the same:
  $var = varset($_GET['var']);

 It should be called var_set() - better on name space pollution.


oke


   However there is a slight issue with this approach. If notices are
 turned on
  this code will generate a notice while i think it should not do that. But
  perhaps this approach is to short.
  A slightly different implementation (and longer) prevents the notice:

 If is is a language element (like isset()) then you can avoid this problem.


Could you explain that a bit more?


 I do find a lot of code, in simple scripts, that does just that.

 It might be nice to extend it such that if the 1st argument is a list then
 the
 first in the list which is set is returned, eg:

$var = var_set(($_GET['var'], $_POST['var']), 'default');


I might be missing the point here, but the way i understand it that can give
unexpected results.. since it returns the first element from an array in
your suggestion but that's not what you want to do.


 --
 Alain Williams
 Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
 Lecturer.
 +44 (0) 787 668 0256  http://www.phcomp.co.uk/
 Parliament Hill Computers Ltd. Registration Information:
 http://www.phcomp.co.uk/contact.php
 #include std_disclaimer.h



Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Alain Williams
On Wed, Apr 20, 2011 at 05:19:36PM +0200, Mark wrote:

  If is is a language element (like isset()) then you can avoid this problem.
 
 
 Could you explain that a bit more?

It looks like a function but is not:

http://uk3.php.net/manual/en/function.isset.php

  It might be nice to extend it such that if the 1st argument is a list then
  the
  first in the list which is set is returned, eg:
 
 $var = var_set(($_GET['var'], $_POST['var']), 'default');
 
 
 I might be missing the point here, but the way i understand it that can give
 unexpected results.. since it returns the first element from an array in
 your suggestion but that's not what you want to do.

I mean that it checks $_GET['var'], then $_POST['var']  returns the first of 
the two that is set
or 'default'.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include std_disclaimer.h

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Jonathan Bond-Caron
On Wed Apr 20 10:55 AM, Mark wrote:
 
 function varset($arr, $key, $default = '') { return (isset($arr[$key]) 
 ? $arr[$key] : $default); }
 
 where the call would be:
 $var = varset($_GET, 'var');
 
 I personally like both ways...
 My proposal is to make this function a core php function in PHP 5.4.
 The added benifit is obvious. People can, with this, use a way shorter 
 notation to validate if a given array element exists. Right now that 
 needs to be done with a ternary, filter_var or some other method 
 (there are quite a few ways to check for existence).
 
 I tried to look in the PHP source to see if i could make a patch to 
 add this but i couldn't find the function that defines the isset 
 function (i wanted to base it on that). So a pointer to the right 
 location would be nice (along with docs that tell me what i all need 
 to do to implement a new php function). 

https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_language_parser.y?rev
ision=306938view=markup

Look for isset_variables:, then zend_do_isset_or_isempty

isset() lives in the parser and requires some advanced knowledge of the
opcodes (personally I'm not there yet)

 
 So, what do you think of this?
 

I like the idea, it could also be called vardef() or var_default()



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Brian Moon

It might be nice to extend it such that if the 1st argument is a list then the
first in the list which is set is returned, eg:

$var = var_set(($_GET['var'], $_POST['var']), 'default');


If that is the usage, I would suggest coalesce() to be consistent with 
the same concept in SQL. And you would not need a list as the first 
argument. Just pass multiple arguments and return the first set value.


$var = var_set($_GET['var'], $_POST['var'], 'default');

http://en.wikipedia.org/wiki/Null_%28SQL%29#COALESCE

Brian.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Alain Williams
On Wed, Apr 20, 2011 at 11:06:47AM -0500, Brian Moon wrote:
 It might be nice to extend it such that if the 1st argument is a list then 
 the
 first in the list which is set is returned, eg:
 
  $var = var_set(($_GET['var'], $_POST['var']), 'default');
 
 If that is the usage, I would suggest coalesce() to be consistent with 
 the same concept in SQL. And you would not need a list as the first 
 argument. Just pass multiple arguments and return the first set value.
 
 $var = var_set($_GET['var'], $_POST['var'], 'default');

Even better.

 http://en.wikipedia.org/wiki/Null_%28SQL%29#COALESCE

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include std_disclaimer.h

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] PECL: mysqlnd_ms (Load-Balancing)

2011-04-20 Thread Reindl Harald
http://pecl.php.net/package/mysqlnd_ms/download/1.0.0/

This is a really great idea to use replication-salves for
read-access without touch the php-application and if this
will work with php_flag site-specific using the available
slaves automatically / leave them out if they are stopped
this can make many setups very scaleable and much more
efficient as do the work in php-scripts with all the needed
decisions read-query, which mysql-host and is the host
currently available

I think this would be finally a thing to directly include
in mysqlnd and leave default off

 The replication and load balancing plugin is a plugin for the mysqlnd library.
 It can be used with PHP MySQL extensions (ext/mysql, ext/mysqli, PDO_MySQL).
 if they are compiled to use mysqlnd. The plugin inspects queries to do 
 read-write
 splitting. Read-only queries are send to configured MySQL replication slave 
 servers
 all other queries are redirected to the MySQL replication master server. Very 
 little,
 if any, application changes required, dependent on the usage scenario 
 required.

-- 

Reindl Harald
the lounge interactive design GmbH
A-1060 Vienna, Hofmühlgasse 17
CTO / software-development / cms-solutions
p: +43 (1) 595 3999 33, m: +43 (676) 40 221 40
icq: 154546673, http://www.thelounge.net/

http://www.thelounge.net/signature.asc.what.htm



signature.asc
Description: OpenPGP digital signature


Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Hannes Landeholm
This discussion is equivalent to the one that we just had. Read the thread
[PHP-DEV] Implicit isset/isempty check on short-ternary operator.

Also the $var = var_set($_GET['var'], $_POST['var'], 'default'); syntax
you propose would be equivalent to (as per previous discussion):

$var = $_GET[?'var'] $: $_POST[?'var'] $: 'default';

(The syntax might also be [?'var'], ['var'?] or different).


On 20 April 2011 18:19, Alain Williams a...@phcomp.co.uk wrote:

 On Wed, Apr 20, 2011 at 11:06:47AM -0500, Brian Moon wrote:
  It might be nice to extend it such that if the 1st argument is a list
 then
  the
  first in the list which is set is returned, eg:
  
   $var = var_set(($_GET['var'], $_POST['var']), 'default');
 
  If that is the usage, I would suggest coalesce() to be consistent with
  the same concept in SQL. And you would not need a list as the first
  argument. Just pass multiple arguments and return the first set value.
 
  $var = var_set($_GET['var'], $_POST['var'], 'default');

 Even better.

  http://en.wikipedia.org/wiki/Null_%28SQL%29#COALESCE

 --
 Alain Williams
 Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
 Lecturer.
 +44 (0) 787 668 0256  http://www.phcomp.co.uk/
 Parliament Hill Computers Ltd. Registration Information:
 http://www.phcomp.co.uk/contact.php
 #include std_disclaimer.h

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Ferenc Kovacs
On Wed, Apr 20, 2011 at 7:14 PM, Hannes Landeholm landeh...@gmail.comwrote:

 This discussion is equivalent to the one that we just had. Read the thread
 [PHP-DEV] Implicit isset/isempty check on short-ternary operator.


except that it wouldn't bring new syntax.

ps: please don't top post if everybody else does bottom or inline posting,
it's hard to follow.

Tyrael


Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Mark
On Wed, Apr 20, 2011 at 6:00 PM, Jonathan Bond-Caron jbo...@openmv.comwrote:

 On Wed Apr 20 10:55 AM, Mark wrote:
 
  function varset($arr, $key, $default = '') { return (isset($arr[$key])
  ? $arr[$key] : $default); }
 
  where the call would be:
  $var = varset($_GET, 'var');
 
  I personally like both ways...
  My proposal is to make this function a core php function in PHP 5.4.
  The added benifit is obvious. People can, with this, use a way shorter
  notation to validate if a given array element exists. Right now that
  needs to be done with a ternary, filter_var or some other method
  (there are quite a few ways to check for existence).
 
  I tried to look in the PHP source to see if i could make a patch to
  add this but i couldn't find the function that defines the isset
  function (i wanted to base it on that). So a pointer to the right
  location would be nice (along with docs that tell me what i all need
  to do to implement a new php function).


 https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_language_parser.y?rev
 ision=306938view=markup

 Look for isset_variables:, then zend_do_isset_or_isempty

 isset() lives in the parser and requires some advanced knowledge of the
 opcodes (personally I'm not there yet)


Oh boy, i never ever did anything in the core PHP coding so i'm certainly
not likely to be able to understand all of that. (yet)


 
  So, what do you think of this?
 

 I like the idea, it could also be called vardef() or var_default()



@ the rest.
The list idea is nice, but i don't really see the added value for it.. Lets
keep it simple, oke :)
As for that other thread: [PHP-DEV] Implicit isset/isempty check on
short-ternary operator
I don't really know much of it, but does that mean that my suggestion is
rejected even before i made an RFC for it?

Regards,
Mark


Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread D. Dante Lorenso

On 4/20/11 9:55 AM, Mark wrote:

Hi,
This proposal is for the often called line like this:
$var = isset($_GET['var']) ? $_GET['var'] : '';
Only a shorter and imho a cleaner solution to get the same:
$var = varset($_GET['var']);

The implementation for this in PHP code is this:

# Arg 1 = the variable to check for existence
# Arg 2 = the default return value which is an empty string by default

function varset($var, $default = '')
{
return (isset($var) ? $var : $default);
}


I proposed something similar over 5 years ago.  It ain't gonna happen 
because PHP language can't support it.  The Zend engine needs to be 
rewritten to remove the warnings and that's not something they are 
volunteering to do no matter how much people want it.


  http://markmail.org/message/yl26ebzcix35wtke

My proposal was called filled since it was the opposite of empty 
which already existed.  I extended the function to return the first 
non-empty value or null if all values evaluated as empty.


You could use the function like this:

  $x = filled($_GET['x'], $obj-something, $default, 'default');

It would return the first argument where !empty($arg) evaluates as TRUE.

There would need to be a companion function to check 'isset' opposite as 
you have proposed.


Like I said, though, I don't think this can be done in the language 
because I think they ran out of OPCODES and would have to tear apart the 
whole PHP engine to support such a feature.


-- Dante

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: Function proposal: varset

2011-04-20 Thread Mark
On Wednesday, April 20, 2011, D. Dante Lorenso da...@lorenso.com wrote:
 On 4/20/11 9:55 AM, Mark wrote:

 Hi,
 This proposal is for the often called line like this:
 $var = isset($_GET['var']) ? $_GET['var'] : '';
 Only a shorter and imho a cleaner solution to get the same:
 $var = varset($_GET['var']);

 The implementation for this in PHP code is this:

 # Arg 1 = the variable to check for existence
 # Arg 2 = the default return value which is an empty string by default

 function varset($var, $default = '')
 {
 return (isset($var) ? $var : $default);
 }


 I proposed something similar over 5 years ago.  It ain't gonna happen because 
 PHP language can't support it.  The Zend engine needs to be rewritten to 
 remove the warnings and that's not something they are volunteering to do no 
 matter how much people want it.

   http://markmail.org/message/yl26ebzcix35wtke

 My proposal was called filled since it was the opposite of empty which 
 already existed.  I extended the function to return the first non-empty value 
 or null if all values evaluated as empty.

 You could use the function like this:

   $x = filled($_GET['x'], $obj-something, $default, 'default');

 It would return the first argument where !empty($arg) evaluates as TRUE.

 There would need to be a companion function to check 'isset' opposite as you 
 have proposed.

 Like I said, though, I don't think this can be done in the language because I 
 think they ran out of OPCODES and would have to tear apart the whole PHP 
 engine to support such a feature.

 -- Dante

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php


Hi,

well, i did propose 2 possible ways although the second one is a
little longer but still clean and readable.
And the second one is certainly possible to implement!

Btw. i did look at the suggested core php code parts and even though i
can do nearly everything in php.. i have a hard time understanding how
the inner php parsing things actually work. There is no way i'm able
to make a patch for php.

Regards,
Mark

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Function proposal: varset

2011-04-20 Thread Arpad Ray
On Wed, Apr 20, 2011 at 11:50 PM, Mark mark...@gmail.com wrote:
 On Wednesday, April 20, 2011, D. Dante Lorenso da...@lorenso.com wrote:
 On 4/20/11 9:55 AM, Mark wrote:

 Hi,
 This proposal is for the often called line like this:
 $var = isset($_GET['var']) ? $_GET['var'] : '';
 Only a shorter and imho a cleaner solution to get the same:
 $var = varset($_GET['var']);

 The implementation for this in PHP code is this:

 # Arg 1 = the variable to check for existence
 # Arg 2 = the default return value which is an empty string by default

 function varset($var, $default = '')
 {
 return (isset($var) ? $var : $default);
 }


 I proposed something similar over 5 years ago.  It ain't gonna happen 
 because PHP language can't support it.  The Zend engine needs to be 
 rewritten to remove the warnings and that's not something they are 
 volunteering to do no matter how much people want it.

   http://markmail.org/message/yl26ebzcix35wtke

 My proposal was called filled since it was the opposite of empty which 
 already existed.  I extended the function to return the first non-empty 
 value or null if all values evaluated as empty.

 You could use the function like this:

   $x = filled($_GET['x'], $obj-something, $default, 'default');

 It would return the first argument where !empty($arg) evaluates as TRUE.

 There would need to be a companion function to check 'isset' opposite as you 
 have proposed.

 Like I said, though, I don't think this can be done in the language because 
 I think they ran out of OPCODES and would have to tear apart the whole PHP 
 engine to support such a feature.

 -- Dante

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php


 Hi,

 well, i did propose 2 possible ways although the second one is a
 little longer but still clean and readable.
 And the second one is certainly possible to implement!

 Btw. i did look at the suggested core php code parts and even though i
 can do nearly everything in php.. i have a hard time understanding how
 the inner php parsing things actually work. There is no way i'm able
 to make a patch for php.

 Regards,
 Mark

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php



Hi,

As Hannes said, the other thread discussing this feature (although the
subject line may suggest otherwise) is still active, so please move
this discussion there:
[PHP-DEV] Implicit isset/isempty check on short-ternary operator

Cheers,

Arpad

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-20 Thread Arpad Ray
On Thu, Apr 14, 2011 at 3:05 PM, Hannes Landeholm landeh...@gmail.com wrote:
 Some suggested that the ternary if comparison should suppress the notice
 automatically. This would break existing code and also be confusing since
 people expect a ternary if and normal if to work the same way.

 Some suggested ?? as an array access operator that suppresses the notice and
 has 3 variants: A: nothing specified - uses null as default, B: has default
 specified, C: returns X if index exists or Y if index doesn't exist. This
 effectively solves the code duplication problem and is a shortcut for saying
 the array index may or may not exist.

 One person said that the relation between ? and ?? and == and === would make
 the operator non-intuitive. Other people disagreed and claimed the opposite.

 So basically the discussion now is what exact characters that should be used
 to represent this operator? I really hope we can get this implemented
 quickly... I worked with $_POST yesterday and I could really use that ??
 operator.

Hi,

I must say that the prospect of yet more new syntax is scary. It
really looks like Perl, and I wouldn't have the slightest clue what it
meant if I'd missed the release notes.

I've pined for something like coalesce($_GET['foo'], $defaults['foo'],
42) for years, and I think that style is far more in keeping with the
PHP ethos, and far more readily understandable than this suggested new
syntax.

If I've missed some argument against this then please correct me.

Regards,

Arpad

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-20 Thread Arpad Ray
On Thu, Apr 21, 2011 at 12:56 AM, Arpad Ray array...@gmail.com wrote:
 I've pined for something like coalesce($_GET['foo'], $defaults['foo'],
 42) for years, and I think that style is far more in keeping with the
 PHP ethos, and far more readily understandable than this suggested new
 syntax.


To elaborate, I'd probably think this code was an unlikely series of
typos, or an encoding error:

$var = $_GET[?'var'] $: $_POST[?'var'] $: 'default';

But as a PHP coder, I'm quite familiar with how coalesce() works.

Regards,

Arpad

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-20 Thread David Muir
On 21/04/11 08:56, Arpad Ray wrote:
 On Thu, Apr 14, 2011 at 3:05 PM, Hannes Landeholm landeh...@gmail.com wrote:
 Some suggested that the ternary if comparison should suppress the notice
 automatically. This would break existing code and also be confusing since
 people expect a ternary if and normal if to work the same way.

 Some suggested ?? as an array access operator that suppresses the notice and
 has 3 variants: A: nothing specified - uses null as default, B: has default
 specified, C: returns X if index exists or Y if index doesn't exist. This
 effectively solves the code duplication problem and is a shortcut for saying
 the array index may or may not exist.

 One person said that the relation between ? and ?? and == and === would make
 the operator non-intuitive. Other people disagreed and claimed the opposite.

 So basically the discussion now is what exact characters that should be used
 to represent this operator? I really hope we can get this implemented
 quickly... I worked with $_POST yesterday and I could really use that ??
 operator.
 Hi,

 I must say that the prospect of yet more new syntax is scary. It
 really looks like Perl, and I wouldn't have the slightest clue what it
 meant if I'd missed the release notes.

 I've pined for something like coalesce($_GET['foo'], $defaults['foo'],
 42) for years, and I think that style is far more in keeping with the
 PHP ethos, and far more readily understandable than this suggested new
 syntax.

 If I've missed some argument against this then please correct me.

 Regards,

 Arpad


What does coalesce() do?
If I'm guessing correctly, would  proposal #2 that Rune Kaagaard put up
solve that for you?
https://gist.github.com/909711

Cheers,
David

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php