[PHP-DEV] filter_var doesn't support international email addresses

2015-02-05 Thread j adams
Please let me know which mailing list address to use if I have sent this to
the wrong list.

filter_var does not properly validate emails with international characters.
For example, this returns FALSE:

var_dump(filter_var("Pelé@example.com", FILTER_VALIDATE_EMAIL));

Are there any plans to implement proper validation of email addresses as
described in RFC 6530?
http://tools.ietf.org/html/rfc6530


Re: [PHP-DEV] filter_var doesn't support international email addresses

2015-02-16 Thread j adams
Rowan, thanks for your response.

Wow that regex is pretty intense. A new filter type sounds like a
reasonable idea to me. I'm not sure if I'll be able to offer any
improvements myself (although I will look into it shortly here). I I do
know that Google announced last August that they plan to support RFC6530:
http://googleblog.blogspot.com/2014/08/a-first-step-toward-more-global-email.html



On Fri, Feb 6, 2015 at 7:14 AM, Rowan Collins 
wrote:

> j adams wrote on 06/02/2015 00:05:
>
>  Please let me know which mailing list address to use if I have sent this
>> to
>> the wrong list.
>>
>> filter_var does not properly validate emails with international
>> characters.
>> For example, this returns FALSE:
>>
>> var_dump(filter_var("Pelé@example.com", FILTER_VALIDATE_EMAIL));
>>
>> Are there any plans to implement proper validation of email addresses as
>> described in RFC 6530?
>> http://tools.ietf.org/html/rfc6530
>>
>
> Hi,
>
> There was a discussion a while back about Internationalized Domain Name
> support in FILTER_VALIDATE_URL [1], and I believe there was a concern that
> since not all systems would accept the wider format, allowing them through
> the existing filter might be unhelpful. This is particularly true in the
> case of internationalized e-mails, since if I understand it correctly it's
> an "all or nothing" system, rather than one with a compatible fallback like
> the "punycode" notation used in domains.
>
> The most useful would probably be to add a new filter type which accepted
> the new format, so that users could choose to accept what they know they
> can process. If you know of or can create a succinct validity test (e.g. a
> PCRE-compatible regex) it ought to be fairly easy to add; the existing
> implementation is here for comparison: http://lxr.php.net/xref/PHP_
> TRUNK/ext/filter/logical_filters.c#575
>
> [1] http://grokbase.com/t/php/php-internals/149jfzxtq3/
> internationalized-domain-name-support-in-filter-validate-url
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>


[PHP-DEV] Is OpCache enabled by default in php 5.5 and later or not?

2015-03-05 Thread j adams
I don't know if this is a question for the documentation team or not, but
figured I'd start here. There does not appear to be any definitive, clear,
reliable information on PHP's op caching functionality in recent 5.*
versions and this problem needs to be remedied.

Question 1: Is OpCache enabled by default in php 5.5 and later or not?

This page:
http://php.net/manual/en/intro.opcache.php
says "This extension is bundled with PHP 5.5.0 and later, and is »
available in PECL for PHP versions 5.2, 5.3 and 5.4."

But this page:
http://php.net/manual/en/opcache.installation.php
says "PHP 5.5.0 and later

OPcache can only be compiled as a shared extension. If you have disabled
the building of default extensions with --disable-all , you must compile
PHP with the --enable-opcache option for OPcache to be available.

Once compiled, you can use the zend_extension configuration directive to
load the OPcache extension into PHP. This can be done with
zend_extension=/full/path/to/opcache.so on non-Windows platforms, and
zend_extension=C:\path\to\php_opcache.dll on Windows."



Question 2:
If OpCache is enabled, does it require any php.ini settings or not? Does it
show any functions or constants or phpinfo() that will reveal its
existence?  I've got php 5.6.6 installed on CentOS 7 and I can find neither
hide nor hair of it.  There is, however, an opcache package one can install
(php56u-opcache.x86_64 in my case).



Question 3:
What about Zend Optimizer? Still other articles say it has been integrated
into php 5.5 and later, but this mythical beast also makes no sign to
indicate its inclusion either. Some articles:
https://wiki.php.net/rfc/optimizerplus
https://wordpress.org/support/topic/looking-ahead-to-php-55-zend-optimizer-the-end-of-apc
http://www.internetnews.com/blog/skerner/php-5-5-to-include-open-source-zend-optimizer-.html


Seems to me there is currently a lot of confusion surrounding OPCache and
it should be cleared up.


Re: [PHP-DEV] Is OpCache enabled by default in php 5.5 and later or not?

2015-03-05 Thread j adams
Thank you so much for the generous clarity. Personally, I wish this sort of
information was clearly visible in the docs. However, I don't want to
introduce unnecessary complications there. Should I mention this to the
docs team? It might help eliminate some of the speculative/incorrect
information at the top of google search results.

On Thu, Mar 5, 2015 at 9:11 AM, Rowan Collins 
wrote:

> j adams wrote on 05/03/2015 16:12:
>
>  I don't know if this is a question for the documentation team or not, but
>> figured I'd start here. There does not appear to be any definitive, clear,
>> reliable information on PHP's op caching functionality in recent 5.*
>> versions and this problem needs to be remedied.
>>
>> Question 1: Is OpCache enabled by default in php 5.5 and later or not?
>>
>> This page:
>> http://php.net/manual/en/intro.opcache.php
>> says "This extension is bundled with PHP 5.5.0 and later, and is »
>> available in PECL for PHP versions 5.2, 5.3 and 5.4."
>>
>> But this page:
>> http://php.net/manual/en/opcache.installation.php
>> says "PHP 5.5.0 and later
>>
>> OPcache can only be compiled as a shared extension. If you have disabled
>> the building of default extensions with --disable-all , you must compile
>> PHP with the --enable-opcache option for OPcache to be available.
>>
>> Once compiled, you can use the zend_extension configuration directive to
>> load the OPcache extension into PHP. This can be done with
>> zend_extension=/full/path/to/opcache.so on non-Windows platforms, and
>> zend_extension=C:\path\to\php_opcache.dll on Windows."
>>
>>
>>
>> Question 2:
>> If OpCache is enabled, does it require any php.ini settings or not? Does
>> it
>> show any functions or constants or phpinfo() that will reveal its
>> existence?  I've got php 5.6.6 installed on CentOS 7 and I can find
>> neither
>> hide nor hair of it.  There is, however, an opcache package one can
>> install
>> (php56u-opcache.x86_64 in my case).
>>
>>
>>
>> Question 3:
>> What about Zend Optimizer? Still other articles say it has been integrated
>> into php 5.5 and later, but this mythical beast also makes no sign to
>> indicate its inclusion either. Some articles:
>> https://wiki.php.net/rfc/optimizerplus
>> https://wordpress.org/support/topic/looking-ahead-to-php-55-
>> zend-optimizer-the-end-of-apc
>> http://www.internetnews.com/blog/skerner/php-5-5-to-
>> include-open-source-zend-optimizer-.html
>>
>>
>> Seems to me there is currently a lot of confusion surrounding OPCache and
>> it should be cleared up.
>>
>
>
> I think part of your confusion here is over terminology:
>
> - Every module of PHP is referred to as an "extension", however deeply
> embedded it is in the language. The most basic functions you can think of,
> like string and array manipulation, are in "ext/standard" in the source.
> - A module being "bundled" means that it is included in the official
> tarball releases on php.net, and indicates a certain guarantee of
> maintenance for compatibility with new versions of PHP.
> - Some bundled extensions cannot be disabled, because to do so would break
> too many dependencies. Most can technically be disabled, and/or built as
> separate shared libraries to be enabled in your php.ini as desired. In the
> case of OpCache, it's bundled, but as a shared library.
> - The PHP you install on a Linux system will most likely NOT be the
> official tarball, but something put together by your Linux distribution.
> They are under no obligation to handle all bundled extensions the same way,
> or enable them by default. They may for instance install the extensions as
> shared libraries and offer a script to enable/disable them, or they may put
> them all into separate packages which you have to install and then
> configure themselves automatically.
> - Oh, and roughly speaking "OpCache" is the name for the open sourced
> version of "ZendOptimizer+", i.e. the version which was made available as a
> PECL download for PHP 5.2, 5.3, and 5.4, and included as a "bundled"
> extension in PHP 5.5 onwards.
>
> This is all a rather long-winded way of saying the same thing Rasmus just
> said, but maybe it will help. :)
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DEV] Alternatives to mailing list?

2012-10-16 Thread J. Adams
I agree. VBulletin rules. It also permits voluntary participation rather 
than getting every email for ever conversation. Should you prefer to get 
everything via email, I believe it is possible to sync VBulletin with a 
mailing list.



On 10/16/2012 5:18 PM, Yahav Gindi Bar wrote:

I may sound old fashioned, but what about a forum?

On Wed, Oct 17, 2012 at 3:05 AM, Clint Priest  wrote:


Is it just me or has this Property Accessors chain of emails been
impossible to make heads or tails of?  People replying within replies
within replies, quoting partial emails, cross-posting and all sorts of
chaos.

Would anyone be willing to entertain an alternative "communication method"
with specific respect to building/refining an RFC or fleshing out an idea?

Heck, I think even live chat meeting over IRC would beat what's been going
on...

Not saying abandon the mailing list, it's crucial, but when there gets to
be 150+ emails on one subject and numerous sub-subjects it just seems
inefficient at best and chaos at its worst...

I don't know of anything offhand that would work well but I'd be willing
to try and find something we could try out.

-Clint




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



[PHP-DEV] Compiling PHP on Windows 7 - wiki needs update

2012-12-24 Thread j adams
Hello all:

I'm not sure if this is the right place to ask this question, but I'm
wondering if there might be an update available for this wiki describing
how to compile on Windows:
https://wiki.php.net/internals/windows/stepbystepbuild

In particular, there are a couple of aspects to that wiki entry that look a
bit old:
* setenv flag of /x86 -- what about 64-bit?
* setenv flag of /xp -- what about win 7?
* setenv flag of /2008 -- what about VC++ 2010?

Any help or suggestions would be much appreciated.  Please let me know if I
should pester the doc team instead.


Re: [PHP-DEV] writing pecl's?

2012-12-30 Thread J. Adams
Please note:  I'm hardly an advanced developer and have yet to produce 
any viable PHP extension.


That said, I have found this book to be helpful:
http://www.amazon.com/Extending-Embedding-PHP-Sara-Golemon/dp/067232704X

All these links and books are probably dated in some respects, but will 
help get you started. I have found that the source itself relies heavily 
on macro definitions in the code. This source browser has been extremely 
useful for me:

http://lxr.php.net/



On 12/30/2012 2:21 PM, Lars Nielsen wrote:

Hi,

I am looking at how to write an extension for php, and i have found an
article on zend.com from 2005 which works fine with my local php 5.3.

My question is should i be worried that this article is almost 8 years
old? Is there some more recent articles? Or is this the way to do it?

http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/

Med venlig hilsen / Best Regards

Lars Nielsen
email : l...@lfweb.dk






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



[PHP-DEV] Recommended ignore list for GIT/SVN?

2013-01-09 Thread J. Adams
Is there any official/doctrinal list of file types for a GIT/SVN ignore 
list when working on a PECL extension?  I've been snooping around and 
found the following (from 
http://stackoverflow.com/questions/85353/best-general-svn-ignore-pattern) but 
was wondering if there was any ignore list that is gospel for the PHP 
dev community.



*.o *.lo *.la #*# .*.rej *.rej
.*~ *~ .#* .DS_Store thumbs.db
Thumbs.db *.bak *.class *.exe *.dll
*.mine *.obj *.ncb *.lib *.log
*.idb *.pdb *.ilk *.msi* .res *.pch *.suo
*.exp *.*~ *.~* ~*.* cvs  CVS .CVS .cvs
release Release debug Debug
ignore Ignore bin Bin obj  Obj
*.csproj.user *.user
*.generated.cs

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



Re: [PHP-DEV] PHP development environment

2011-01-14 Thread J. Adams
I'm curious about this too. I've been developing on a Mac using nano 
from the command line and it can be pretty tough. Any and all details 
welcome.  I'm about to set up a 64-bit box with Ubuntu which would be my 
primary dev box.  I also have a windows desktop.




On 1/14/2011 5:40 PM, Martin Scotta wrote:

Hi all,

I'm just starting with the internal PHP development.
Do you have some sort of common development environment? Eclipse project or
the like?

I'm using Ubuntu but also have a WXP, just for the sake of.

how do you develop PHP ?


  Martin Scotta




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



Re: [PHP-DEV] Time zone database shut down by legal threat

2011-10-06 Thread J. Adams

Perhaps we could all contact Astrolabe and voice our complaints?

http://alabe.com/



On 10/6/2011 3:24 PM, David Zülke wrote:

FYI: http://blog.joda.org/2011/10/today-time-zone-database-was-closed.html

This could impact PHP as well since it bundles the database.

David

P.S. I hope Google/IBM/Oracle/whoever just buys those guys and then fires 
everyone.





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



Re: [PHP-DEV] Re: Time zone database shut down by legal threat

2011-10-07 Thread J. Adams
Is the IANA tz database subject to the same constraints as the old one?  
If so, it may be subject to the same legal constraints. I believe it 
would be wise to seek some quality legal advice on the issue.  I have 
tried to contact the Free Software Foundation and the EFF just to see 
what they might say. I'll pass on anything interesting.




On 10/7/2011 6:55 AM, Derick Rethans wrote:

On Fri, 7 Oct 2011, Lester Caine wrote:


Derick Rethans wrote:

FYI:http://blog.joda.org/2011/10/today-time-zone-database-was-closed.html

  This could impact PHP as well since it bundles the database.

We don't actually bundle the database as rules. Instead, we bundle a
compiled version of that, and the original rules do not remain in
what we bundle. Not sure whether that means it impacts us or not,
and I will not be making any comments about that.

Unfortunately if the courts rule that the data is not public domain,
then any use of it would be blocked and liable to license claims? It
is the current block on making any future updates to the data which is
a problem that will need to be addressed at some point? So ignoring
the problem is not really practical :(

The TZ database maintenance is/was in the process of being put under the
IANA as DAO is going on retirement soon. In that light, a new ML has
already been set-up where the timezone database is now being maintained.
New versions of the database will come out as usual, and we'll update
PHP with those new database rules.

cheers,
Derick



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



[PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-22 Thread j adams
I'm working on a data serialization routine wherein I must iterate through
an object's properties while distinguishing between "sealed" properties
(i.e., those specified by class definitions) and "dynamic" properties"
(i.e., those assigned ad-hoc to some object that are not party of any class
definition).

I found the source of the php function get_object_vars():
http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
However, I am still pretty confused. PHP source is *full* of macros and has
basically no comments. Hoping for some tips to keep me on the right track.
I'm pretty sure I can get something kludgy working, but I want my code to
be orthodox and work well.

QUESTIONS
1) Sadly, this approach is unable to distinguish "sealed" properties from
dynamic ones. If anyone can refer me to some source (or outline a general
approach) which can first iterate sealed properties and then iterate only
dynamic ones, that would be extremely helpful.

2) What does zend_objects_get_address do? This reference looks very
different than the usual macro, e.g. Z_OBJ_HT_P

3) Am I correct in understanding that zend_check_property_access simply
checks if the property in question is availabe in the scope in which this
function call gets executed? Is this the canonical/orthodox way to make
this check?

4) What does zend_unmangle_property_name do? Why is this function changed
to zend_unmangle_property_name_ex in 5.5 and later?

5) Why do we call Z_ADDREF_PP(value) here? Is this reference counting to
prevent garbage collection?

6) An IS_INTERNED check is added in php 5.6 and yet the macro for
IS_INTERNED is zero. What's that all about?

7) The code looks quite different between the different versions:
5.3 - http://lxr.php.net/xref/PHP_5_3/Zend/zend_builtin_functions.c#950
5.5 - http://lxr.php.net/xref/PHP_5_5/Zend/zend_builtin_functions.c#982
5.6 - http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
>From what I can tell there is at least one difference between 5.3 and 5.6
-- zend_unmangle_property_name_ex does not exist before 5.5. Can anyone
recommend how to make code that'll work in 5.3-5.6? Also, with 7 coming out
I'd like it work there too.

Any answers or assistance would be greatly appreciated.


Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-22 Thread j adams
Thank you, Sean. Still looking for a couple of answers...

> 1) 'Default Properties' or properties stored on the class (not object)
can be found on the zend_class_entry[0], they are just accessed by offset
[1]
> This isn't a stable/public API, but good for a cool hack!

I'm afraid I don't follow. Could you elaborate? I've seen one way to get
'default properties' from a zend_class_entry object:
zendClassEntry->default_properties;
This gets us a list of default properties. I've also seen
zendClassEntry->properties_info;
Which, if I'm not mistaken, involves more elaborate parsing logic but also
tells you whether properties are accessible.

Seems like numerous ways to skin a cat. What is the orthodox approach here?
Also, what do you suggest to distinguish 'sealed' (i.e., default)
properties from dynamic ones? Is there some counterpart to
default_properties that returns non_default_properties -- i.e., just the
dynamic ones? Or should I just get all of the object's properties and check
each key to see if it's one of the default_properties by searching a
HashTable of these default properties?


> 3) Never used this, but it seems to be to confirm that a mangled prop
name matches a zend_property_info *

Not sure I follow. We create a separate zobj of type zend_object using the
function:
zobj = zend_objects_get_address(obj TSRMLS_CC);
And then use zobj to check access:
if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) ==
SUCCESS) {

I find it odd that our native zval type would not encompass member
accessibility. I'm wondering if zend_object might be some kind of
historical add-on concept to expand very old PHP functionality or if
there's some reason for this distinct object type.



On Tue, Sep 22, 2015 at 12:32 PM, Sean DuBois  wrote:

> On Tue, Sep 22, 2015 at 11:16:46AM -0700, j adams wrote:
> > I'm working on a data serialization routine wherein I must iterate
> through
> > an object's properties while distinguishing between "sealed" properties
> > (i.e., those specified by class definitions) and "dynamic" properties"
> > (i.e., those assigned ad-hoc to some object that are not party of any
> class
> > definition).
> >
> > I found the source of the php function get_object_vars():
> > http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
> > However, I am still pretty confused. PHP source is *full* of macros and
> has
> > basically no comments. Hoping for some tips to keep me on the right
> track.
> > I'm pretty sure I can get something kludgy working, but I want my code to
> > be orthodox and work well.
> >
> > QUESTIONS
> > 1) Sadly, this approach is unable to distinguish "sealed" properties from
> > dynamic ones. If anyone can refer me to some source (or outline a general
> > approach) which can first iterate sealed properties and then iterate only
> > dynamic ones, that would be extremely helpful.
> >
> > 2) What does zend_objects_get_address do? This reference looks very
> > different than the usual macro, e.g. Z_OBJ_HT_P
> >
> > 3) Am I correct in understanding that zend_check_property_access simply
> > checks if the property in question is availabe in the scope in which this
> > function call gets executed? Is this the canonical/orthodox way to make
> > this check?
> >
> > 4) What does zend_unmangle_property_name do? Why is this function changed
> > to zend_unmangle_property_name_ex in 5.5 and later?
> >
> > 5) Why do we call Z_ADDREF_PP(value) here? Is this reference counting to
> > prevent garbage collection?
> >
> > 6) An IS_INTERNED check is added in php 5.6 and yet the macro for
> > IS_INTERNED is zero. What's that all about?
> >
> > 7) The code looks quite different between the different versions:
> > 5.3 - http://lxr.php.net/xref/PHP_5_3/Zend/zend_builtin_functions.c#950
> > 5.5 - http://lxr.php.net/xref/PHP_5_5/Zend/zend_builtin_functions.c#982
> > 5.6 - http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
> > From what I can tell there is at least one difference between 5.3 and 5.6
> > -- zend_unmangle_property_name_ex does not exist before 5.5. Can anyone
> > recommend how to make code that'll work in 5.3-5.6? Also, with 7 coming
> out
> > I'd like it work there too.
> >
> > Any answers or assistance would be greatly appreciated.
> Hey,
>
> 1) 'Default Properties' or properties stored on the class (not object)
> can be found on the zend_class_entry[0], they are just accessed by offset
> [1]
>
> This isn't a stable/public API, but good for a cool hack!
>
> 3) 

Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-23 Thread j adams
> Welcome to the jungle

Thank you, Francois. Malheuresement, plus de questions...


> PHP uses an object store.
Am I correct in understanding that the object store is a global data
structure? Wouldn't this tend to discourage any attempts at
multithreading/multiprocessing within one's PHP script--unless the object
store is protected by a lock...


It would appear that for some zend_object ,zobj, that if the object has any
dynamic properties at all then zobj->properties will be defined a HashTable
that contains not just the dynamic properties, but all the default object
properties (i.e., those defined explicitly by the class) as well. At least
that appears to be the case from my code below.

Is there not any way to first iterate through the default properties and
then iterate through *only the dynamic properties* ?  If so, please
advise?  If not, it sounds like I must iterate through all properties and
check each property's key to see if it's included among the default
properties.

Also -- and this is *very* important:
1) Will this code ALWAYS return the properties in the same sequence? E.g.,
if I am iterating through N objects of type MyClass, will each instance
iterate the properties in the same order?
2) Will this code ALWAYS iterate over default properties (i.e., "sealed"
properties, those explicitly defined by class definitinos) FIRST and then
iterate any dynamically assigned properties?
These questions are very important for my serialization algorithm.

zobj = zend_objects_get_address(*val TSRMLS_CC);

if (!zobj->properties) {
php_printf("***No dynamic properties!\n");
} else {
php_printf("***we got dynamic properties...sadly, this will
also iterate through default properties too\n");
zend_hash_internal_pointer_reset_ex(zobj->properties, &pos);
while (zend_hash_get_current_data_ex(zobj->properties,
(void **) &value, &pos) == SUCCESS) {
if (zend_hash_get_current_key_ex(zobj->properties,
&key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
if (zend_check_property_access(zobj, key, key_len-1
TSRMLS_CC) == SUCCESS) {

zend_unmangle_property_name(key, key_len - 1,
&class_name, &prop_name);

php_printf("dynamic property is %s, key_len is
%d\n", prop_name, key_len);
}
}
zend_hash_move_forward_ex(zobj->properties, &pos);
}
        }

On Tue, Sep 22, 2015 at 5:42 PM, François Laupretre 
wrote:

> Hi,
>
> Hope this can help.
>
> Le 22/09/2015 20:16, j adams a écrit :
>
>> I'm working on a data serialization routine wherein I must iterate through
>> an object's properties while distinguishing between "sealed" properties
>> (i.e., those specified by class definitions) and "dynamic" properties"
>> (i.e., those assigned ad-hoc to some object that are not party of any
>> class
>> definition).
>>
>> I found the source of the php function get_object_vars():
>> http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
>> However, I am still pretty confused. PHP source is *full* of macros and
>> has
>> basically no comments.
>>
>
> Welcome to the jungle
>
> 2) What does zend_objects_get_address do? This reference looks very
>> different than the usual macro, e.g. Z_OBJ_HT_P
>>
>
> PHP uses an object store. This allows handling objects by reference. Every
> object instance is defined by a numeric handle (an offset in the object
> store). Object zvals contain the object handle. The object address is
> obtained through the object store. Look
> http://lxr.php.net/xref/PHP_5_6/Zend/zend_objects_API.c#274
>
> Z_OBJ_HT() is used to call an object's handlers. This information is also
> present in the zend_object but, for a better performance AFAIK, also made
> available in the zval struct.
>
> 3) Am I correct in understanding that zend_check_property_access simply
>> checks if the property in question is availabe in the scope in which this
>> function call gets executed?
>>
>
> Yes
>
>
>> 4) What does zend_unmangle_property_name do? Why is this function changed
>> to zend_unmangle_property_name_ex in 5.5 and later?
>>
>
> Properties are stored using 'mangled' names. The format of a mangled name
> is '', where  is a null
> byte. Class name and property name are 'decoded' by
> zend_unmangle_property_name(). Look
> http://lxr.php.net/xref/PHP_5_6/Zend/zend_compile.c#5373
>
> 5) Why do we call Z_ADDREF_PP(valu

Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-23 Thread j adams
Not my intention to be combative, but what about http://php.net/pcntl_fork
? I've used that before in a robust distributed application that runs
without any intervention for months. It's my understanding that PHP is
thread safe, but not itself multithreaded. I believe there are some
extensions which aren't thread safe. Also correct me if I'm wrong but
Apache 2 should be run in it's prefork mode when using PHP.

Also, any thoughts on my other questions? Sorry if I'm pressing my luck but
they are far more pressing for me currently:
1) Is there not any way to first iterate through the default properties and
then iterate through *only the dynamic properties* ?
zend_object->properties appears to contain ALL properties if the object has
a single dynamically-assigned property.  If so, please advise?  If not, it
sounds like I must iterate through all properties and check each property's
key to see if it's included among the default properties. Please confirm?
2) Will this code ALWAYS return the properties in the same sequence? E.g.,
if I am iterating through N objects of type MyClass, will each instance
iterate the properties in the same order?
3) Will this code ALWAYS iterate over default properties (i.e., "sealed"
properties, those explicitly defined by class definitinos) FIRST and then
iterate any dynamically assigned properties?
These questions are very important for my serialization algorithm.

CODE:


zobj = zend_objects_get_address(*val TSRMLS_CC);

if (!zobj->properties) {
php_printf("***No dynamic properties!\n");
} else {
php_printf("***we got dynamic properties...sadly, this will
also iterate through default properties too\n");
zend_hash_internal_pointer_reset_ex(zobj->properties, &pos);
while (zend_hash_get_current_data_ex(zobj->properties,
(void **) &value, &pos) == SUCCESS) {
if (zend_hash_get_current_key_ex(zobj->properties,
&key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
if (zend_check_property_access(zobj, key, key_len-1
TSRMLS_CC) == SUCCESS) {

zend_unmangle_property_name(key, key_len - 1,
&class_name, &prop_name);

php_printf("dynamic property is %s, key_len is
%d\n", prop_name, key_len);
}
}
zend_hash_move_forward_ex(zobj->properties, &pos);
}
}

On Wed, Sep 23, 2015 at 1:33 PM, Rowan Collins 
wrote:

> On 23 September 2015 20:48:33 BST, j adams  wrote:
> >> PHP uses an object store.
> >Am I correct in understanding that the object store is a global data
> >structure? Wouldn't this tend to discourage any attempts at
> >multithreading/multiprocessing within one's PHP script--unless the
> >object
> >store is protected by a lock...
>
> PHP is inherently single-threaded as far as the user is concerned. There
> are many things which would break if you changed that.
>
> The only way I know of to write multi-threaded PHP is using the pthreads
> extension, which comes with some rather large caveats, and uses specific
> objects to communicate between threads.
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-24 Thread j adams
Thanks, Rowan, for the clarification! And no, this is not my primary
question. At the risk of irritating everyone, here are the questions I need
answered:

1) Is there not any way to first iterate through the default properties and
then iterate through *only the dynamic properties* ?
zend_object->properties appears to contain ALL properties if the object has
a single dynamically-assigned property.  If so, please advise?  If not,
please confirm?
2) Will the code below ALWAYS return the properties in the same sequence?
E.g., if I am iterating through N objects of type MyClass, will each
instance iterate the properties in the same order?
3) Will the code below ALWAYS iterate over default properties (i.e.,
"sealed" properties, those explicitly defined by class definitinos) FIRST
and then iterate any dynamically assigned properties?

CODE:

zobj = zend_objects_get_address(*val TSRMLS_CC);

if (!zobj->properties) {
php_printf("***No dynamic properties!\n");
} else {
php_printf("***we got dynamic properties...sadly, this will
also iterate through default properties too\n");
zend_hash_internal_pointer_reset_ex(zobj->properties, &pos);
while (zend_hash_get_current_data_ex(zobj->properties,
(void **) &value, &pos) == SUCCESS) {
if (zend_hash_get_current_key_ex(zobj->properties,
&key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
if (zend_check_property_access(zobj, key, key_len-1
TSRMLS_CC) == SUCCESS) {

zend_unmangle_property_name(key, key_len - 1,
&class_name, &prop_name);

php_printf("dynamic property is %s, key_len is
%d\n", prop_name, key_len);
}
}
zend_hash_move_forward_ex(zobj->properties, &pos);
    }
}


On Thu, Sep 24, 2015 at 1:34 PM, Rowan Collins 
wrote:

> On 23/09/2015 22:16, j adams wrote:
>
>> Not my intention to be combative, but what abouthttp://php.net/pcntl_fork
>> ? I've used that before in a robust distributed application that runs
>> without any intervention for months. It's my understanding that PHP is
>> thread safe, but not itself multithreaded. I believe there are some
>> extensions which aren't thread safe. Also correct me if I'm wrong but
>> Apache 2 should be run in it's prefork mode when using PHP.
>>
>
> Process forking is very different from multi-threading. Your original
> question was whether a central object store could cause problems, but as I
> understand it a forked process shares no memory with its parent, so that's
> not a problem.
>
> The internal thread safety mode ("ZTS") does indeed have to duplicate the
> object store for each thread, though. The general idea (in Zend Engine 2 /
> PHP 5, at least) being that a structure is passed around via TSRM* macros
> and ultimately used by the EG macro in place of a true global:
> http://lxr.php.net/xref/PHP_5_6/Zend/zend_globals_macros.h#45
>
> All of this is something of an aside from what you really wanted to know,
> though. :)
>
>
> Regards,
>
> --
> Rowan Collins
> [IMSoP]
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-24 Thread j adams
Thank you for this, Sean! I'm making headway for php 5.5/5.6. This should
come in handy when/if I get around to PHP 7.

On Wed, Sep 23, 2015 at 3:35 PM, Sean DuBois  wrote:

> On Wed, Sep 23, 2015 at 02:16:39PM -0700, j adams wrote:
> > Not my intention to be combative, but what about
> http://php.net/pcntl_fork
> > ? I've used that before in a robust distributed application that runs
> > without any intervention for months. It's my understanding that PHP is
> > thread safe, but not itself multithreaded. I believe there are some
> > extensions which aren't thread safe. Also correct me if I'm wrong but
> > Apache 2 should be run in it's prefork mode when using PHP.
> >
> > Also, any thoughts on my other questions? Sorry if I'm pressing my luck
> but
> > they are far more pressing for me currently:
> > 1) Is there not any way to first iterate through the default properties
> and
> > then iterate through *only the dynamic properties* ?
> > zend_object->properties appears to contain ALL properties if the object
> has
> > a single dynamically-assigned property.  If so, please advise?  If not,
> it
> > sounds like I must iterate through all properties and check each
> property's
> > key to see if it's included among the default properties. Please confirm?
> > 2) Will this code ALWAYS return the properties in the same sequence?
> E.g.,
> > if I am iterating through N objects of type MyClass, will each instance
> > iterate the properties in the same order?
> > 3) Will this code ALWAYS iterate over default properties (i.e., "sealed"
> > properties, those explicitly defined by class definitinos) FIRST and then
> > iterate any dynamically assigned properties?
> > These questions are very important for my serialization algorithm.
> >
> > CODE:
> >
> >
> > zobj = zend_objects_get_address(*val TSRMLS_CC);
> >
> > if (!zobj->properties) {
> > php_printf("***No dynamic properties!\n");
> > } else {
> > php_printf("***we got dynamic properties...sadly, this
> will
> > also iterate through default properties too\n");
> > zend_hash_internal_pointer_reset_ex(zobj->properties,
> &pos);
> > while (zend_hash_get_current_data_ex(zobj->properties,
> > (void **) &value, &pos) == SUCCESS) {
> > if (zend_hash_get_current_key_ex(zobj->properties,
> > &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
> > if (zend_check_property_access(zobj, key,
> key_len-1
> > TSRMLS_CC) == SUCCESS) {
> >
> > zend_unmangle_property_name(key, key_len - 1,
> > &class_name, &prop_name);
> >
> > php_printf("dynamic property is %s, key_len
> is
> > %d\n", prop_name, key_len);
> > }
> > }
> > zend_hash_move_forward_ex(zobj->properties, &pos);
> > }
> > }
> >
> > On Wed, Sep 23, 2015 at 1:33 PM, Rowan Collins 
> > wrote:
> >
> > > On 23 September 2015 20:48:33 BST, j adams 
> wrote:
> > > >> PHP uses an object store.
> > > >Am I correct in understanding that the object store is a global data
> > > >structure? Wouldn't this tend to discourage any attempts at
> > > >multithreading/multiprocessing within one's PHP script--unless the
> > > >object
> > > >store is protected by a lock...
> > >
> > > PHP is inherently single-threaded as far as the user is concerned.
> There
> > > are many things which would break if you changed that.
> > >
> > > The only way I know of to write multi-threaded PHP is using the
> pthreads
> > > extension, which comes with some rather large caveats, and uses
> specific
> > > objects to communicate between threads.
> > >
> > > Regards,
> > > --
> > > Rowan Collins
> > > [IMSoP]
> > >
> > >
> > > --
> > > PHP Internals - PHP Runtime Development Mailing List
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
>
> In PHP7 this is how you can all the default properties (defined on the
> class) you will have to adjust. This is breaking public APIs, but just
> to illustrate how to get you closer.
>
> You should the

[PHP-DEV] recommended .gitignore for PHP/PECL extensions

2015-09-25 Thread j adams
I have made good progress on a PHP extension and I'd like to post it on
github to get some review and help from some others. The folder has quite a
few files and I'm hoping to avoid putting anything in git that doesn't need
to be there.

I see that php 5.6 has this .gitignore file:
http://git.php.net/?p=php-src.git;a=blob_plain;f=.gitignore;hb=f5751638dbd77136ce5c90e7d8bd090aa655c2a3

But that one is for the root of the php project. I just want my git repo to
contain my code in the ext/extension-name folder.

Can anyone recommend a good .gitignore file for extensions? I looked around
in a bunch of the PECL dirs and found a couple:
http://git.php.net/?p=pecl/languages/v8js.git;a=tree
http://git.php.net/?p=pecl/networking/ssh2.git;a=tree


[PHP-DEV] good example of unserialization fundamentals?

2015-09-30 Thread j adams
I have completed a first draft of serialization functionality which is
intended to be an updated to amfext. It's on github[0] if anyone is
interested. I would now like to write all the unserialization routines and
would like some suggestions from experienced php devs. I've been reading
Sara Golemon's book, but am still a little unsure.

In particular, I want my userland function, amf_decode to accept as a
parameter a string (and possibly other args). This is not so difficult but
I must call upon another function, php_amf_decode, which needs to be able
to handle recursive calls.

Something like this:

// userland function
static PHP_FUNCTION(amf_decode) {
char *buf; // char buffer, contains serialize data string
int buf_len, buf_cursor=0; // the length of the buffer
long flags = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &buf,
&buf_len, &flags) == FAILURE) {
return;
}

if (!buf_len) {
RETURN_NULL();
}

php_amf_decode(return_value, buf, buf_len, &buf_cursor, flags
TSRMLS_CC);
}

// proposed recursive decoding function
PHP_AMF_API void php_amf_decode(zval *return_value, char *buf, int buf_len,
int *buf_cursor, long flags TSRMLS_DC)
{

// is it safe to use these macros in this recursive function?
RETVAL_BOOL(1);

// or this
RETURN_LONG(42);


}


[0] https://github.com/sneakyimp/amfext


Re: [PHP-DEV] good example of unserialization fundamentals?

2015-09-30 Thread j adams
Thanks for your response. I do follow the concept of macros (and my IDE
expands them for me if I need), however, I just want to confirm that it's
OK to be using these in a *recursive function*? I'm aware from S. Golemon's
book that these (deeply nested) macros also have the effect of incrementing
refcounts and such. For instance, I'm sure the RETURN_* macros will break
your code if you don't have a zval *return_value defined in the current
scope. Are there other caveats or heuristic rules to avoid abusing these
macros?

OH, and perhaps I forgot to ask with my original post. Can anyone point me
to a good example of a function that takes some userland input and
recursively interprets it as possibly nested arrays or objects? I've been
looking at php_json_decode_ex[0] but it is allocating and freeing memory
for utf16/8 converters and JSON_Parser_structs and so on.


[0] http://lxr.php.net/xref/PHP_5_6/ext/json/json.c#683

On Wed, Sep 30, 2015 at 1:58 PM, Sean DuBois  wrote:

> On Wed, Sep 30, 2015 at 01:39:26PM -0700, j adams wrote:
> > I have completed a first draft of serialization functionality which is
> > intended to be an updated to amfext. It's on github[0] if anyone is
> > interested. I would now like to write all the unserialization routines
> and
> > would like some suggestions from experienced php devs. I've been reading
> > Sara Golemon's book, but am still a little unsure.
> >
> > In particular, I want my userland function, amf_decode to accept as a
> > parameter a string (and possibly other args). This is not so difficult
> but
> > I must call upon another function, php_amf_decode, which needs to be able
> > to handle recursive calls.
> >
> > Something like this:
> >
> > // userland function
> > static PHP_FUNCTION(amf_decode) {
> > char *buf; // char buffer, contains serialize data string
> > int buf_len, buf_cursor=0; // the length of the buffer
> > long flags = 0;
> >
> > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &buf,
> > &buf_len, &flags) == FAILURE) {
> > return;
> > }
> >
> > if (!buf_len) {
> > RETURN_NULL();
> > }
> >
> > php_amf_decode(return_value, buf, buf_len, &buf_cursor, flags
> > TSRMLS_CC);
> > }
> >
> > // proposed recursive decoding function
> > PHP_AMF_API void php_amf_decode(zval *return_value, char *buf, int
> buf_len,
> > int *buf_cursor, long flags TSRMLS_DC)
> > {
> >
> > // is it safe to use these macros in this recursive function?
> > RETVAL_BOOL(1);
> >
> > // or this
> > RETURN_LONG(42);
> >
> >
> > }
> >
> >
> > [0] https://github.com/sneakyimp/amfext
>
> Yep those are safe!
>
> RETVAL_* expands out so you don't have to repeat the variable
> `return_value`
> ZVAL_LONG(return_value, l)
>
> RETURN_* expands out so you don't have to call return OR specify the
> variable `return_value`
>ZVAL_LONG(return_value, l)
>return;
>
> Here they are in 5.6 http://lxr.php.net/xref/PHP_5_6/Zend/zend_API.h#618
> ---
>
> A great tool to look these things up quickly is lxr, sure beats grep!
>
> http://lxr.php.net/search?q=&defs=RETURN_LONG&refs=&path=&hist=&project=PHP_5_6
>


[PHP-DEV] amfext: a little weird behavior, a couple of memory leaks

2015-10-02 Thread j adams
I'm making slow progress on an updated version of AMFEXT. Most of the
encoding functionality is complete but I'm struggling a bit with the
decoding functions because I need to return zvals and other objects. In
particular, I'm getting some memory leak notifications and I'm also getting
some weird behavior when I add values to a HashTable and retrieve them
later.  I'd very much appreciate some guidance. A code review would be
awesome if anyone is willing.

I've posted the extension's source on github at
https://github.com/sneakyimp/amfext

=== Problem 1: I pass a *zval to one of my functions by reference and it
gets pointed to a zval object representing a string. I was trying to check
Z_TYPE_P(myzval)==IS_STRING and even though it is a string with a type
value of 6, the check says otherwise, though. I'm baffled by this because
my code looks just like examples I've seen in 'Extending and Embedding
PHP.' Code:
zval *assoc_key;
MAKE_STD_ZVAL(assoc_key);
amf_read_string(buf, buf_len, buf_cursor, assoc_key, flags,
htComplexObjects, htObjectTypeTraits, htStrings TSRMLS_CC);

// had to remove this check because it was failing on empty strings
for some reason
if (Z_TYPE_P(assoc_key) == IS_STRING) {
// the baffling thing is it returns "String expected, but
returned object type is 6"
php_error_docref(NULL TSRMLS_CC, E_ERROR, "String expected, but
returned object type is %d", (unsigned int)Z_TYPE_P(assoc_key));
}
Here's a link to the source on github:
https://github.com/sneakyimp/amfext/blob/master/amf.c#L1242

=== Problem 2: Similar to the previous problem, but the issue is that
string zval is retrieved from a HashTable and when it comes out, the type
value is messed up value. Code:
// make sure it's a string
// WTF? Z_TYPE_P(strz) is never IS_STRING and Z_STRVAL_P returns
messed up values
// e.g., "ZVAL stored at index 0 is not a string, type=-30420640"
if (Z_TYPE_P(strz) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "ZVAL stored at index
%d is not a string, type=%d\n", (unsigned int)str_index, Z_STRVAL_P(strz));
}
Here's a link to the source on github:
https://github.com/sneakyimp/amfext/blob/master/amf.c#L1300

=== Problem 3: Memory leaks!

I concocted this test PHP script for my amf_decode function. It retrieves a
data file containing an amf3-serialized array:
array("abc", "abc", "abc", "a" => 1, "b" => 2, "c" => 3)

And then decodes it.  The PHP script:

  int(1)
  ["b"]=>
  int(2)
  ["c"]=>
  int(3)
  [0]=>
  string(3) "abc"
  [1]=>
  string(3) "abc"
  [2]=>
  string(3) "abc"
}
[Fri Oct  2 12:00:21 2015]  Script:
'/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php'
/home/jaith/src/php-5.5.29/ext/amf/amf.c(1324) :  Freeing 0x7F30D2091080
(32 bytes), script=/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php
Last leak repeated 3 times
[Fri Oct  2 12:00:21 2015]  Script:
'/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php'
/home/jaith/src/php-5.5.29/ext/amf/amf.c(1330) :  Freeing 0x7F30D2091270 (2
bytes), script=/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php
Last leak repeated 2 times
[Fri Oct  2 12:00:21 2015]  Script:
'/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php'
/home/jaith/src/php-5.5.29/ext/amf/amf.c(1325) :  Freeing 0x7F30D20914F0 (2
bytes), script=/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php
Last leak repeated 3 times
[Fri Oct  2 12:00:21 2015]  Script:
'/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php'
/home/jaith/src/php-5.5.29/ext/amf/amf.c(1238) :  Freeing 0x7F30D2092348
(32 bytes), script=/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php
[Fri Oct  2 12:00:21 2015]  Script:
'/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php'
/home/jaith/src/php-5.5.29/ext/amf/amf.c(1333) :  Freeing 0x7F30D2092AB8 (1
bytes), script=/home/jaith/src/php-5.5.29/ext/amf/jta/read_arr_test2.php
=== Total 13 memory leaks detected ===


Re: [PHP-DEV] [RFC] deprecate md5_file and sha1_file

2020-02-10 Thread j adams
I disagree. While MD5 and SHA1 might not be suitable for modern
cryptographic operations, these functions might be needed for legacy
situations -- e.g., munging through old data.


On Mon, Feb 10, 2020 at 1:50 PM Tom Van Looy via internals <
internals@lists.php.net> wrote:

> Hi
>
> While in some environments the use of MD5 and SHA1 are still acceptable for
> some use cases like file integrity verification etc. the use of these
> algorithms should be discouraged and not be your choice when developing new
> applications.
>
> I suggest to deprecated the functions md5_file() and sha1_file(). This will
> make people think about upgrading to a better alternative. If you still
> need this functionality you can always switch to the hash_file() function.
>
> Carrying around these two dedicated functions seems a bit too much for a
> modern PHP. What do you think?
>
> My feeling was that this is a no brainer. Should I open an RFC for this?
>
> Kind regards,
>
> Tom Van Looy
>


[PHP-DEV] Problems with mysqli code and documentation

2020-02-14 Thread j adams
I had considerable difficulty getting mysqli_connect to use SSL/TSL to
connect to a db and I think some things need to be improved. I apologize
for also describing documentation issues here, but I'll describe the coding
issues first. I may need some help to prompt the documentation team to
remedy some issues. It is my feeling that PHP's credibility as a viable
modern language depends in large part on reliable and well-documented
encryption functionality to satisfy security best practices for vital
database connectivity. PHP's documentation has been one of its great assets
over the years and I hope to see that great tradition continued robustly.

CONTEXT
An email from Amazon informed me they are upgrading the certificates for
their Relational Database Servers (RDS). This prompted me to try and
connect from PHP to an RDS MySQL server using SSL/TSL. The experience was
difficult and unhappy. It's tricky mostly because the documentation on
mysqli features relating to SSL/TLS is poor, but also because the
underlying PHP code doesn't make use of a variable (or more?) in the
underlying source code.

CODING/DEV ISSUES
1) As pointed out here
,
the constant MYSQLI_OPT_SSL_VERIFY_SERVER_CERT is defined in PHP

but apparently doesn't do anything at all. A decision needs to be made
about whether to remove this constant or to somehow reconcile its relation
to the constant MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT. The former
constant is supplied to the function mysqli_options and does absolutely
nothing, the latter is a flag to the function mysqli_real_connect and does
appear to prevent validation of the server's SSL/TLS certificate during
handshaking. There may be other orphaned variables that are not used, I
don't know.

2) If one specifies "localhost" as the host when trying to mysqli_connect
using SSL/TLS, then the connection will fail with these warnings:
PHP Warning:  mysqli_real_connect(): this stream does not support
SSL/crypto in /path/to/file.php on line XX
PHP Warning:  mysqli_real_connect(): Cannot connect to MySQL by using SSL
in /path/to/file.php on line XX
PHP Warning:  mysqli_real_connect(): [2002]  (trying to connect via (null))
in /path/to/file.php on line XX
PHP Warning:  mysqli_real_connect(): (HY000/2002):  in /path/to/file.php on
line XX

That's four warnings and a highly cryptic problem which is not easily
diagnosed because there is no documentation or user comments to clarify the
issue. Using 127.0.0.1 instead of localhost seems to remedy the problem for
some reason surely related to transport, but it would certainly be
preferable if the PHP code was smart enough to recognize the situation
enough to provide a single, more meaningful warning.

DOCUMENTATION (AND POSSIBLY CODING) ISSUES
A) mysqli_ssl_set  has no
usage examples and the parameter descriptions border on useless. For
example:

key
The path name to the key file.
cert
The path name to the certificate file.
ca
The path name to the certificate authority file.

No mention is made of format. No effort is made to describe whether these
are client keys/certs or server keys/certs. Is this a private key or public
key? I admit my knowledge of the relation between certificates and the
certificate authority file is a little fuzzy, but I'm hardly a novice
programmer and feel this documentation leaves a lot to be desired. Most of
the coding examples I find using this function set only the ca, leaving the
majority of the numerous other parameters empty. The documentation does not
describe what happens when these values are NULL or what happens of the
specified file paths don't exist. It doesn't describe what string values
are permissible -- which is especially disconcerting for the cipher
parameter, which surely admits only certain constants? For some reason this
function always returns a TRUE value, and does not throw any exceptions
(e.g., if the files don't exist). What doe these parameters do? What does
this function do?

B) documentation for mysqli_real_connect
 does not
sufficiently describe how it differs from mysqli_connect. E.g., it doesn't
mention that mysqli_real_connect is helpful in lieu of mysqli_connect if
you must set options like connect timeouts, etc. It does not provide any
examples that use the flags parameter. Why do we have these two distinct
functions? Is there some way to use mysqli_ssl_set with mysqli_connect? Or
must one always use mysqli_real_connect?

In digging further into the MySQLi documentation, I see that there is a lot
of helpful detail on the Quick Start articles, and would suggest that the
level of detail in Quick Start should be the bare minimum, with

[PHP-DEV] english documentation list?

2021-01-04 Thread j adams
Hello! I apologize for troubling this list. I found a problem with the
english language documentation on mysqli_query and have attempted to send
an email to php...@lists.php.net but am totally unsure if anyone will ever
receive it. In any case, I expect the documentation people may need some
help correcting the documentation. The text of my issue report follows:



There is a problem with the return value description for mysqli_query,
displayed here:
https://www.php.net/manual/en/mysqli.query.php

Under 'Return Values,' it says:

>Returns *false* on failure. For successful SELECT, SHOW, DESCRIBE or
EXPLAIN queries *mysqli_query()* will return a mysqli_result
 object. For other
successful queries *mysqli_query()* will return *true*

This is not correct. I can provide one counterexample, which is when you
run an optimize query:

OPTIMIZE TABLE my_table;

This query will return a result set with two records whether the table
exists or not.


I believe I found the file that should be altered on github here:
https://github.com/php/doc-en/blob/master/reference/mysqli/mysqli/query.xml#L111

I do not know what the return value description should be under all the
various circumstances.


[PHP-DEV] incorrect mysqli_query return value? or documentation problem?

2021-01-09 Thread j adams
I apologize for troubling the list again, but I sent an email on the 5th
which has so far received no response. Archived here:
https://news-web.php.net/php.internals/112755

Put simply, the mysqli_query function does not return a boolean value as
the documentation says it should. Is this an error with mysqli_query or a
problem with the documentation? Or is the OPTIMIZE TABLE query beyond the
scope of standard SQL?


[PHP-DEV] PHP support for matrix operations - BLAS, LAPACK.

2022-12-04 Thread j adams
I apologize if I have the wrong mailing list here. I'm hoping ot ask the
PHP developer community if there's any appetite for functions to handle
matrix operations and scientific computing.

I took a course on machine learning which had us code solutions using
matlab/octave. This year I embarked on trying to translate those functions
to PHP and have been quite surprised to learn that pure php is quite
inefficient for matrix multiplication. I've been trying to chase down an
effective way to perform matrix operations in PHP and posting my questions
and progress on this forum at PHPBuilder:
https://board.phpbuilder.com/d/10403480-converting-matlab-machine-learning-routines-to-php-need-matrix-operations

Fast matrix operations seem to be absolutely critical for machine learning,
at least for Support Vector Machines and Neural Networks. I know that there
is a FANN extension, but it seems to me that it would be beneficial for
PHP's use in scientific applications if it had support -- either natively
or via some extension -- for matrix operations and possibly other
statistical or scientific computations. Python has numpy, for example.

How does everyone feel about BLAS or LAPACK extension for PHP? I'm poorly
equipped to cook up such a thing, but these libraries already exist and
could offer great improvements in performance.


[PHP-DEV] Re: PHP support for matrix operations - BLAS, LAPACK.

2022-12-17 Thread j adams
Christopher:

I have carefully followed the instructions under 'Manually compiling the
extension' in your first link[1]. When I attempted `make`, it failed,
ending with the following errors. I'll be filing an issue.

/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c: In
function ‘zephir_function_exists’:
/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:285:101:
warning: comparison between pointer and integer
  285 |  if (zend_hash_str_exists(CG(function_table),
Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)) != NULL) {
  |
^~
/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c: In
function ‘zephir_function_exists_ex’:
/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:301:76:
warning: comparison between pointer and integer
  301 |  if (zend_hash_str_exists(CG(function_table), function_name,
function_len) != NULL) {
  |
   ^~
/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c: In
function ‘zephir_get_arg’:
/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:571:9:
error: too many arguments to function ‘zend_forbid_dynamic_call’
  571 | if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
  | ^~~~
In file included from /usr/include/php/20220829/main/php.h:35,
 from
/home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:16:
/usr/include/php/20220829/Zend/zend_API.h:782:39: note: declared here
  782 | static zend_always_inline zend_result zend_forbid_dynamic_call(void)
  |   ^~~~
make: *** [Makefile:213: kernel/main.lo] Error 1


[1] <https://github.com/RubixML/Tensor#optional-to-compile-extension>

On Tue, Dec 6, 2022 at 6:29 AM Christoph M. Becker 
wrote:

> On 05.12.2022 at 20:05, j adams wrote:
>
> > Christoph, thanks for this tip.
> >
> > Unfortunately, pecl refuses to install Tensor either on my Macbook Pro or
> > on my Ubuntu 20 workstation. Both machines complain about being unable to
> > find cblas.h. I ran 'sudo pecl install tensor' which has quite a bit of
> > output. The problem seems to happen when it attempts to run make:
> >
> > running: make
> > /bin/bash /tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/libtool
> > --mode=compile cc -I. -I/tmp/pear/temp/tensor/ext
> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/include
> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/main
> > -I/tmp/pear/temp/tensor/ext -I/usr/include/php/20210902
> > -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM
> > -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext
> > -I/usr/include/php/20210902/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -O3
> > -ffast-math -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/tensor/ext/tensor.c
> > -o tensor.lo  -MMD -MF tensor.dep -MT tensor.lo
> > libtool: compile:  cc -I. -I/tmp/pear/temp/tensor/ext
> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/include
> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/main
> > -I/tmp/pear/temp/tensor/ext -I/usr/include/php/20210902
> > -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM
> > -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext
> > -I/usr/include/php/20210902/ext/date/lib -DHAVE_CONFIG_H -g -O2 -O3
> > -ffast-math -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/tensor/ext/tensor.c
> > -MMD -MF tensor.dep -MT tensor.lo  -fPIC -DPIC -o .libs/tensor.o
> > /tmp/pear/temp/tensor/ext/tensor.c:25:10: fatal error: cblas.h: No such
> > file or directory
> >25 | #include "cblas.h"
> >   |  ^
> > compilation terminated.
> > make: *** [Makefile:208: tensor.lo] Error 1
> > ERROR: `make' failed
>
> I think you need to install the OpenBLAS dev package[1].
>
> If in doubt, file an issue at the tensor bug tracker[2].
>
> [1] <https://github.com/RubixML/Tensor#optional-to-compile-extension>
> [2] <https://github.com/RubixML/Tensor/issues>
>
> --
> Christoph M. Becker
>


[PHP-DEV] Re: PHP support for matrix operations - BLAS, LAPACK.

2023-01-04 Thread j adams
I have supplied this information as issue #34 on the github project that
appears to maintain the tensor extension.
https://github.com/RubixML/Tensor/issues/34

I had commented on issue #33, where someone attempts to fix tensor for php
8.2 about 3 weeks ago, but there have been no responses:
https://github.com/RubixML/Tensor/issues/33

It's surprisingly difficult to get fast matrix operations in PHP, given how
fundamental they are to machine learning.


On Sat, Dec 17, 2022 at 11:51 AM j adams  wrote:

> Christopher:
>
> I have carefully followed the instructions under 'Manually compiling the
> extension' in your first link[1]. When I attempted `make`, it failed,
> ending with the following errors. I'll be filing an issue.
>
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c: In
> function ‘zephir_function_exists’:
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:285:101:
> warning: comparison between pointer and integer
>   285 |  if (zend_hash_str_exists(CG(function_table),
> Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)) != NULL) {
>   |
>   ^~
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c: In
> function ‘zephir_function_exists_ex’:
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:301:76:
> warning: comparison between pointer and integer
>   301 |  if (zend_hash_str_exists(CG(function_table), function_name,
> function_len) != NULL) {
>   |
>  ^~
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c: In
> function ‘zephir_get_arg’:
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:571:9:
> error: too many arguments to function ‘zend_forbid_dynamic_call’
>   571 | if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
>   | ^~~~
> In file included from /usr/include/php/20220829/main/php.h:35,
>  from
> /home/jaith/biz/machine-learning/tensor/Tensor/ext/kernel/main.c:16:
> /usr/include/php/20220829/Zend/zend_API.h:782:39: note: declared here
>   782 | static zend_always_inline zend_result
> zend_forbid_dynamic_call(void)
>   |   ^~~~
> make: *** [Makefile:213: kernel/main.lo] Error 1
>
>
> [1] <https://github.com/RubixML/Tensor#optional-to-compile-extension>
>
> On Tue, Dec 6, 2022 at 6:29 AM Christoph M. Becker 
> wrote:
>
>> On 05.12.2022 at 20:05, j adams wrote:
>>
>> > Christoph, thanks for this tip.
>> >
>> > Unfortunately, pecl refuses to install Tensor either on my Macbook Pro
>> or
>> > on my Ubuntu 20 workstation. Both machines complain about being unable
>> to
>> > find cblas.h. I ran 'sudo pecl install tensor' which has quite a bit of
>> > output. The problem seems to happen when it attempts to run make:
>> >
>> > running: make
>> > /bin/bash /tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/libtool
>> > --mode=compile cc -I. -I/tmp/pear/temp/tensor/ext
>> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/include
>> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/main
>> > -I/tmp/pear/temp/tensor/ext -I/usr/include/php/20210902
>> > -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM
>> > -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext
>> > -I/usr/include/php/20210902/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -O3
>> > -ffast-math -DZEND_COMPILE_DL_EXT=1 -c
>> /tmp/pear/temp/tensor/ext/tensor.c
>> > -o tensor.lo  -MMD -MF tensor.dep -MT tensor.lo
>> > libtool: compile:  cc -I. -I/tmp/pear/temp/tensor/ext
>> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/include
>> > -I/tmp/pear/temp/pear-build-root7MZ6PH/tensor-3.0.2/main
>> > -I/tmp/pear/temp/tensor/ext -I/usr/include/php/20210902
>> > -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM
>> > -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext
>> > -I/usr/include/php/20210902/ext/date/lib -DHAVE_CONFIG_H -g -O2 -O3
>> > -ffast-math -DZEND_COMPILE_DL_EXT=1 -c
>> /tmp/pear/temp/tensor/ext/tensor.c
>> > -MMD -MF tensor.dep -MT tensor.lo  -fPIC -DPIC -o .libs/tensor.o
>> > /tmp/pear/temp/tensor/ext/tensor.c:25:10: fatal error: cblas.h: No such
>> > file or directory
>> >25 | #include "cblas.h"
>> >   |  ^
>> > compilation terminated.
>> > make: *** [Makefile:208: tensor.lo] Error 1
>> > ERROR: `make' failed
>>
>> I think you need to install the OpenBLAS dev package[1].
>>
>> If in doubt, file an issue at the tensor bug tracker[2].
>>
>> [1] <https://github.com/RubixML/Tensor#optional-to-compile-extension>
>> [2] <https://github.com/RubixML/Tensor/issues>
>>
>> --
>> Christoph M. Becker
>>
>


[PHP-DEV] filter_var url validation needs help

2017-05-11 Thread j adams
Forgive me if I'm contacting the wrong list. If I am, someone please tell
me who I should contact about this.

I have been telling noob programmers for years to use filter_var with
FILTER_VALIDATE_URL to validate urls but recently ran into some pretty
disappointing behavior with it. It would appear from this 10-year-old bug
report and the source code that il...@php.net made some pretty drastic
changes to "fix" a problem:
https://bugs.php.net/bug.php?id=39898

A friend helping me look into it says there was apparently a change between
5.2.0 and 5.2.1 that removed some important-looking flag handling:

> diff museum.php.net/php5/php-5.2.0/ext/filter/logical_filters.c
museum.php.net/php5/php-5.2.1/ext/filter/logical_filters.c > diff.txt

...
488,491c457,460
< if (
< ((flags & FILTER_FLAG_SCHEME_REQUIRED) && url->scheme == NULL) ||
< ((flags & FILTER_FLAG_HOST_REQUIRED) && url->host == NULL) ||
< ((flags & FILTER_FLAG_PATH_REQUIRED) && url->path == NULL) ||
< ((flags & FILTER_FLAG_QUERY_REQUIRED) && url->query == NULL)
< ) {
 if (
> url->scheme == NULL ||
> /* some schemas allow the host to be empty */
> (url->host == NULL && (strcmp(url->scheme, "mailto") &&
strcmp(url->scheme, "news") && strcmp(url->scheme, "file"))) ||
> ((flags & FILTER_FLAG_PATH_REQUIRED) && url->path == NULL) || ((flags &
FILTER_FLAG_QUERY_REQUIRED) && url->query == NULL)
> ) {
>bad_url:
> php_url_free(url);
> RETURN_VALIDATION_FAILED

The docs here also say that this function supports the nearly-20-year-old
RFC 2396, which has been obsoleted by RFC 3986 (which, in turn, is updated
by 6874 and 7320)
http://php.net/manual/en/filter.filters.validate.php

Contrary to what the docs say, FILTER_FLAG_SCHEME_REQUIRED and
FILTER_FLAG_HOST_REQUIRED don't do anything.

This is very disappointing and should probably be remedied -- at the very
least the documentation should be updated to remove the ignored flags.
There appear to be quite a few problems with the function:
https://bugs.php.net/search.php?cmd=display&search_for=FILTER_VALIDATE_URL


[PHP-DEV] what's the official position on apache threaded environments

2018-03-21 Thread j adams
So what's the story with PHP and multithreaded environments these days?
Does this statement on the PHP website still stand?
http://www.php.net/manual/en/faq.installation.php#faq.installation.apache2

Seems a bit archaic these days to eschew multithreaded environments,
doesn't it?

More specific questions:
* is there any kind of authoritative list of PHP modules that are NOT
threadsafe? If so, where might I find it?
* What warnings, indications, failures, or errors, if any, might I
encounter if I am experiencing undesirable behavior by using PHP in an
event or worker environment?
* Does anyone have any comment on the recommended means of acquiring PHP
within Apache as described on the apache wki here:
https://wiki.apache.org/httpd/php