Re: [PHP-DEV] Pb : access control
Can you cut down the script to like 10 lines and say what your result is and what you'd expect? At 05:37 PM 3/17/2003 +0100, Fabrice Le Coz wrote: Hi, I'm playing with PHP5 and have some trouble wtith access control, here's the code I run with last php5 from snaps.php.net under windows XP : ?php class pere { private $var3; public$var1; protected $var2; function __construct() { $this-var1 = public; $this-var2 = protected; $this-var3 = private; } function show() { echo pere::show() \n; echo var1 : $this-var1\n; echo var2 : $this-var2\n; echo var3 : $this-var3\n; echo \n; } } class fils extends pere { protected $var = fils; private $var4 = test; function __construct() { parent::__construct(); } function show_fils() { echo fils::show() \n; echo var1 : $this-var1\n; echo var2 : $this-var2\n; echo var3 : $this-var3\n; echo var : $this-var\n; echo \n; } } function show_var($obj) { $obj_vars = get_object_vars($obj); foreach ($obj_vars as $name = $value) { if($name != ) echo $name : $value\n; } echo \n; } $test1 = new pere(); $test1-show(); echo Affichage des variables visibles de test1 :\n; show_var($test1); $test2 = new fils(); $test2-show_fils(); echo Affichage des variables visibles de test2 :\n; show_var($test2); $test2-show(); echo var3 : .$test2-var3.\n; echo var4 : .$test2-var4.\n; ? and I've the following result : pere::show() var1 : public var2 : protected var3 : private Affichage des variables visibles de test1 : var1 : public fils::show() var1 : public var2 : protected var3 : private var : fils Affichage des variables visibles de test2 : var1 : public var2 : var3 : private pere::show() var1 : public var2 : protected var3 : private var3 : private Fatal error: Cannot access private property fils::$var4 in D:\www\test\heritier.php on line 59 Normally in the instance of fils object ($test2), I mustn't see $this-var3 which is private variable of the parent. if I comment the line 'echo var3 : $this-var3\n;' in the show_fils method, $test2-var3 is empty but do not generate an error ! The show_var($test2) function expose a var2 variable which normally must send an Fatal error. Fabrice Le Coz [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] Possible problem in the parser
You are right that it doesn't behave the same as C. However, personally although it might have been better for it to work like C I don't think it's a good idea to change it now. First of all it would break backwards compatibility in a way which would be hard for people to find where the bug is and how to fix it. Secondly, not meaning to insult anyone here, but I think people who write such code without using parentheses should improve their coding style :) Andi At 12:01 PM 3/14/2003 +, Ford, Mike [LSS] wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 13 March 2003 19:33 To: Ford, Mike [LSS] Cc: 'Andrey Hristov'; [EMAIL PROTECTED] Subject: RE: [PHP-DEV] Possible problem in the parser At 14:58 13.03.2003, Ford, Mike [LSS] wrote: Just to make this completely clear, in left-associative PHP b = a==1? 4:a==2? 5:6; is equivalent to b = (a==1? 4:a==2)? 5:6; NO it is not equal. Either '==' has higher precedence OR '?:' has. See one of my previous mails where i showed where the error is. Yes, it is -- believe me, I've researched this extensively. It is NOT about precedence, but associativity. If you want me to be totally completist about this: Starting from: b = a==1? 4:a==2? 5:6; precedence rules make this equivalent to: b = (a==1)? 4:(a==2)? 5:6; but this is still ambiguous -- which ?: phrase do you evaluate first? Associativity provides the answer: in PHP, where ?: is left associative (i.e. the left most ?: is evaluated first), the result is equivalent to: b = ((a==1)? 4:(a==2))? 5:6; On the other hand, in c, where ?: is right associative, the equivalent is: b = (a==1)? 4:((a==2)? 5:6); which, apart from the additional (unnecessary) parentheses around the == comparisons, is exactly what I said before. QED Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /tests/classes interface_class.phpt interface_doubled.phpt interface_implemented.phpt interface_instantiate.phpt interface_member.phpt interface_method.phpt interface_method_final.phpt interface_method_private.phpt interface_must_be_implemented.phpt
At 08:53 AM 3/12/2003 -0500, Andrei Zmievski wrote: I have 2 questions: 1. Do the interface functions have to be explicitly specified as abstract? Nope. It shouldn't be allowed to be abstract because it's abstract by definition. interface Foo { function bar(); } Because this runs fine for me with no errors. 1. What is the difference between the following: interface Foo { } class Boo extends Foo { } This shouldn't work. I guess there's a bug someplace. It's new code so I'm sure there will be some small things which need to be fixed. Andi and class Zoo implements Foo { } -Andrei http://www.gravitonic.com/ In this age, which believes that there is a short cut to everything, the greatest lesson to be learned is that the most difficult way is, in the long run, the easiest. -Henry Miller, The Books in My Life -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Moderate PHP-DEV
This discussion itself is creating more spam than those emails people send. I agree with Sascha that we shouldn't take drastic measures. We still want to make it easy for people to join the PHP developer's community. I think the most interesting idea so far was Shane's first post response system. We have all of the necessary infra-structure ready. Hopefully we can reach an agreement ASAP because I can't handle all of these emails anymore :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Newbie developer's information
At 04:17 PM 3/12/2003 -0500, David Hill \(php.net\) wrote: As a newbie commiter, still wet behind the ears, I would have *really* appreciated a page that was a little clearer and a bit more up to date than what I started with. My sources of information README.CVS-RULES, the building from cvs web page) were very good, but missed some vital clues. While many have been very patient with me (thanks), I found it frustrating to ask questions that seem to be obvious to others like: * trying to build php4 head for two days, only to be told that I should be building PHP_4_3 or php5 head. * forgetting about re2c, which is not mentioned anywhere that I could find, but I found through freshmeat and had a lovely time trying to build :-) I am taking note of the problems I encountered and was planning on updating something (README.CVS-RULES ?) after another week or so. Improvements would be welcome. I'm not sure where the best place would be. Maybe on the web site? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Moderate PHP-DEV
At 11:01 PM 3/12/2003 +0100, Sascha Schumann wrote: I wouldn't consider 3rd one that drastic. It has worked very well for me, I haven't got any spam to my php.net addy, but people who really wanted to send me email got through.. Well, maybe I am an exception, but I usually don't bother to register myself anywhere, unless there is a really good reason. Thus, the proposed measure increases the bar for contributions significantly. We don't lose anything by giving the first two items some time to prove their usefullness. On the other hand, it is very likely that we will lose useful input, if we implement the third item prematurely. I disagree. Anyone here can handle replying because we already have the anti-spam protection. The only thing we're doing is adding to the message an explanation of the post ethics. I wouldn't call this drastic at all. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [patch] solaris getcwd() brokeness
I think the patch is OK. I'm not extremely happy with it because I don't think it's very beautiful but I didn't have time to think of a better way of fixing it. I think he can go ahead and commit it but I'd like there to be comments in the source code to explain why those checks on state-cwd_length are being made. This will help ppl understand this weirdness later on... Andi At 04:38 PM 3/10/2003 +0200, Jani Taskinen wrote: Andi, what's the status with this? --Jani On Sun, 23 Feb 2003, Wez Furlong wrote: Hi Andi (and James) Andi: I'd appreciate your comments on this patch, specifically if there are any concerns about it doing the right thing. Most people here: http://bugs.php.net/bug.php?id=21310edit=1 report that it fixes their problems with solaris. I've held off from looking at this, as I didn't want to duplicate any effort you have been making. --Wez. On Sun, 16 Feb 2003, Andi Gutmans wrote: At 03:41 PM 2/13/2003 -0500, James E. Flemer wrote: RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v retrieving revision 1.41 diff -u -b -r1.41 tsrm_virtual_cwd.c --- TSRM/tsrm_virtual_cwd.c 6 Nov 2002 18:07:22 - 1.41 +++ TSRM/tsrm_virtual_cwd.c 13 Feb 2003 20:40:07 - @@ -303,7 +303,7 @@ return (0); #if !defined(TSRM_WIN32) !defined(NETWARE) - if (IS_ABSOLUTE_PATH(path, path_length)) { + if (IS_ABSOLUTE_PATH(path, path_length) || (state-cwd_length 1)) { if (use_realpath realpath(path, resolved_path)) { path = resolved_path; path_length = strlen(path); Will realpath() work in cases where getcwd() didn't work? (btw it's nicer to check state-cwd_length == 0 than 1 IMO). @@ -363,6 +363,7 @@ } + if (state-cwd_length 0 || IS_ABSOLUTE_PATH(path, path_length)) { ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, tok); while (ptr) { ptr_length = strlen(ptr); @@ -416,6 +417,11 @@ state-cwd[state-cwd_length+1] = '\0'; state-cwd_length++; } + } else { + state-cwd = (char *) realloc(state-cwd, path_length+1); + memcpy(state-cwd, path, path_length+1); + state-cwd_length = path_length; + } I'm trying to think if there's some other way of doing this. What is the main problem in this loop? Does it add / or c:\ in the beginning of the string? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- - For Sale! - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] - fix for 64 bit issues with OnUpdateInt
At 11:03 PM 3/4/2003 +0100, Sascha Schumann wrote: On Tue, 4 Mar 2003, Jani Taskinen wrote: Yup, that was the idea. I'll first change them all to OnUpdateInteger, and then use your patch to change the ones that need to be long to use OnUpdateLong. Is there any specific reason why a single API (OnUpdateLong) is not sufficient? Is not it a safe assumption that those modules which still use 'int's are simply the result of a mistake on the developer's side? A single API is probably sufficient but I can understand that extension writers might want to use ints. The INI flag might have nothing to do with an internal zval and an int might be more than enough. I don't really mind but I wouldn't introduce OnUpdateInteger. I guess we should either move everything to OnUpdateLong() and nuke OnUpdateInt() in ZE2 or we change OnUpdateInt to work with ints and fix the whole code. It might be less confusing to just have one. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] - fix for 64 bit issues with OnUpdateInt
At 01:29 PM 3/5/2003 +0800, James Devenish wrote: In message [EMAIL PROTECTED] on Wed, Mar 05, 2003 at 07:24:20AM +0200, Andi Gutmans wrote: It might be less confusing to just have one. Hasn't worked so far ;) Well we're talking about changing the name from OnUpdateInt to OnUpdateLong. It should reduce confusion. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] ZE2 constructors
The patch look OK. Go ahead and commit it. Andi At 08:20 PM 2/28/2003 +0100, Marcus Börger wrote: Hi Zeev, according to the plans the following test file should PASS: --TEST-- The new constructor/destructor is called --SKIPIF-- ?php if (version_compare(zend_version(), '2.0.0-dev', '')) die('skip ZendEngine 2 needed'); ? --FILE-- ?php class early { function early() { echo early::early\n; } function __construct() { echo early::__construct\n; } function __destruct() { echo early::__destruct\n; } } class late { function __construct() { echo late::__construct\n; } function late() { echo late::late\n; } function __destruct() { echo late::__destruct\n; } } $t = new early(); $t-early(); unset($t); $t = new late(); $t-late(); //unset($t); delay to end of script echo Done\n; ? --EXPECTF-- early::__construct early::early early::__destruct late::__construct late::late Done late::__destruct # However it fails and this patch is needed which also fixees the last final problem mentioned already: # Index: Zend/zend_compile.c === RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.375 diff -u -r1.375 zend_compile.c --- Zend/zend_compile.c 25 Feb 2003 10:03:26 - 1.375 +++ Zend/zend_compile.c 28 Feb 2003 19:14:52 - @@ -916,6 +916,9 @@ ((current_access_type-u.constant.value.lval ZEND_ACC_PPP_MASK) != (new_modifier-u.constant.value.lval ZEND_ACC_PPP_MASK))) { zend_error(E_COMPILE_ERROR, Multiple access type modifiers are not allowed); } + if (((current_access_type-u.constant.value.lval | new_modifier-u.constant.value.lval) (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) { + zend_error(E_COMPILE_ERROR, Cannot use the final modifier on an abstract class member); + } if (((current_access_type-u.constant.value.lval | new_modifier-u.constant.value.lval) (ZEND_ACC_PRIVATE | ZEND_ACC_FINAL)) == (ZEND_ACC_PRIVATE | ZEND_ACC_FINAL)) { zend_error(E_COMPILE_ERROR, Cannot use the final modifier on a private class member); } @@ -974,7 +977,7 @@ fn_flags |= ZEND_ACC_PUBLIC; } - if ((short_class_name_length == name_len) (!memcmp(short_class_name, name, name_len))) { + if ((short_class_name_length == name_len) (!memcmp(short_class_name, name, name_len)) !CG(active_class_entry)-constructor) { CG(active_class_entry)-constructor = (zend_function *) CG(active_op_array); } else if ((function_name-u.constant.value.str.len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) (!memcmp(function_name-u.constant.value.str.val, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME { CG(active_class_entry)-constructor = (zend_function *) CG(active_op_array); # regards marcus -- -- Marcus Börger - Looking for all sorts of freelance work - just ask... Did i help you? Consider a gift: http://www.amazon.de/exec/obidos/wishlist/ho722v0rg1u0 -- -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] - fix for 64 bit issues with OnUpdateInt
Hi, The reason the zend_parse_parameters() API only exposes long is because the Zend zval (container which holds the engine values) only supports longs and not ints. So anything which touches scripting engine values should be using long. However, extensions which have INI parameters may want to use ints for their internal logic. The INI directive retrieval really doesn't have anything to do with zval's. So I think the fix of adding OnUpdateLong() is the correct fix. We could add some support in ZEND_DEBUG mode to catch some common errors. For example, we could make the zend_parse_parameters() function a macro and make sure that people are passing long's and not ints. I'm not really sure it's worth it though. Andi At 06:19 PM 2/28/2003 +0800, James Devenish wrote: Hi, Preface: This e-mail uses the distribution list (To and CC addresses) that the original poster used. I have moved everyone other than php-dev to Bcc so that this doesn't get perpetuated (I have no idea of the significance of the other addresses that were e-mailed, nor do I know Dave Hill's standing in the PHP community). In message [EMAIL PROTECTED] on Thu, Feb 27, 2003 at 02:52:28PM -0500, Dave Hill wrote: Proposed Patch to address 64 bit issues in PHP v4.3.1 Diff -u against php4-STABLE-200302241430 Also needed in 4.5.x and 5.x Addresses bugs 20994, 21002, 21822, 20268 There was some discussion on php-dev in November 2002 after I posted patches for bug #20268 (the earliest-numbered one in Dave's list). I chose to address this problem by creating OnUpdateLong (in addition to to existing OnUpdateInt) and sweep though the code changing the call where needed to match the stucture item. An equally valid fix would be to change all of those longs to ints. (a) I also chose to create OnUpdateLong (and this has been working well for me since 4.3.0pre2 using the patches I posted). Since I posted those patches, PHP has progressed and more of these problems have been introduced (bad) but at the same time some of the test cases have been revised to be more portable (good). (b) I found that sometimes ints needed to stay as ints and longs needed to stay as longs, which is why I chose to separate OnUpdateLong from OnUpdateInt. (c) In discussions on php-dev in November, the subject of the thread was 64-bit PHP 4.3 (extensive long vs int problems) http://marc.theaimsgroup.com/?t=10369029101r=1w=2 (d) Jason Greene responded as a person who was working on this problem. Disfavour of the OnUpdateLong solution was expressed (on- and maybe off-list, too). After performing that sweep, I found there was a small number of other errors of the int/long type that my compiler found that I corrected and are included here. There might be more mix and match problems, I only addressed the ones in the modules I have enabled. Deja vu! Now the reason I am responding and the reason I have BCCed the people in Dave's list was that I wanted to mention something about Zend. Really, this bug has its roots in Zend though it is manifested in PHP modules. Firstly, OnUpdateInt assigns to long storage but uses zend_atoi -- clearly there is confusion already. But the more disturbing thing that I found in November was the Zend documentation for zend_parse_parameters (a site of extensive long/int problems). That is why I have written this e-mail. I know nothing about the Zend engine but I will refer to this document: http://www.zend.com/apidoc/zend.arguments.retrieval.php It is entitled Accepting Arguments / Retrieving Arguments and describes the zend_parse_parameters function. It lists a type specifier: l - long But it does not list an int type. In the actual code, it is entirely long-based, not int-based, so there is clearly a mismatch. But moreover, there is no acknowledgement of the significance of int versus long. So it is not surprising that so many developers have made mistakes arising from this. Therefore, I thought that a proper solution to this problem would have to involve some consideration of the Zend API (or at least copious acknowledgments and warnings in its documentation). There is potentially a huge developer education problem, too. That is why I chose to add OnUpdateLong. And given the choice, I would have 'i - int' added to the type specifiers of zend_parse_parameters. Firstly, having the OnUpdateLong function allows quick rectification of these problems without having to try to stuff ints into longs or longs into ints -- we can instead just choose the one that fits the task. Moreover: by having two functions and two type specifiers (one for ints and one for longs), the situation would almost be self-documenting: developers that would usually neglect to consider the difference between int and long would at least see that there is a 'int' variant and a 'long' variant and therefore be prompted -- without extensive re-education -- to consider using the correct 'hole' for the 'peg'. If Zend is to settle on everything being longs or everything being
Re: [PHP-DEV] CVS Account Request: jay
Have you submitted a CVS account request? At 09:41 PM 2/27/2003 +, J Smith wrote: A few weeks ago, I kind of volunteered to maintain testing scripts for ZE2 on the ZE2 mailing list. (See the thread beginning at http://www.zend.com/lists/engine2/200302/msg3.html ) Just to make good on my volunteering, I guess I'll be needing a CVS account. I suppose I'd need access to php(4|5)/tests. I have a bunch of tests ready to go, and will be adding more as features get added, tweaked, etc. within ZE2. As for experience, I've submitted various patches to the project over the past year or so and written a few extensions that will eventually make it to PECL. I've also offered the use of a Solaris server to the group for debugging Solaris SPARC issues and can do some debugging on it myself if there's a need for it. J, aka darkpanda -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Weak references in PHP
Hi, I don't quite understand. If you are thinking of implementing something similar to JDO then your persistent object manager will only hold the objects which are retrieve by the script. At the end of the request it'll persist the changes and will free the objects. Why would you want them to be destroyed during the request? Andi At 02:39 PM 2/28/2003 +0300, Konstantin Knizhnik wrote: To be able to implmenet interface of object-oriented database to PHP I need to have object cache which will map persistent object identifier (OPID) to loaded instance of the object. This cache should be weak, i.e. it should not prevent garbage collection from deallocating unused instances of peristent object (otherwise all database will be soon loaded in memory).. As far as I understand, PHP uses GC bases on refernce couters. Also I do not find something like weak reference in language manual. There are two other ways how to solve the problem without weak references: 1. Be able to check valye of reference counter (so I can check the it is equal to 1 and if so remove this object from object cache) 2. Be able to detect the moment when object is removed by GC (in this case I can make object cache invisible for GC and when object is deleted, it will be also unlinked frmo object cache). Can anybody tell me if such features are available in PHP (I failed to find them myself). Or may be there is some other way to solve the problem? Thanks in advance Konstantin -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] - fix for 64 bit issues with OnUpdateInt
At 04:28 PM 2/28/2003 +0100, Sascha Schumann wrote: So I think the fix of adding OnUpdateLong() is the correct fix. I was under the impression that OnUpdateInt was actually expecting a long. I remember changing some int's to long's to address 64 bit issues. Do I remember this incorrectly? No, you are correct but misunderstood me. We should introduce OnUpdateLong() for ppl using longs and use OnUpdateInt() for ppl who want to use ints. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] - fix for 64 bit issues with OnUpdateInt
At 04:47 PM 2/28/2003 +0100, Sascha Schumann wrote: No, you are correct but misunderstood me. We should introduce OnUpdateLong() for ppl using longs and use OnUpdateInt() for ppl who want to use ints. Well, and how are you planning to mitigate the BC issues? Remember that not all extension code is under our direct control. I don't think there's much choice. Do you have a better idea? If so, please explain it. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] - fix for 64 bit issues with OnUpdateInt
At 04:50 PM 2/28/2003 +0100, Sascha Schumann wrote: I think that simply adding OnUpdateLong and deprecating OnUpdateInt is fine while retaining its current semantics. I just don't see any value in changing the meaning of OnUpdateInt; at least that's how I interpreted Andi's message. That's also an option but I think OnUpdateInt() is confusing and how do we stop ppl from using it in new extensions which who's commit messages aren't followed via php-cvs? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] #php.bugs invite only?
At 12:12 PM 2/28/2003 -0500, Ilia A. wrote: On February 28, 2003 11:50 am, George Schlossnagle wrote: #php.bugs seems to be invite only now. How do I go about getting myself invited? It would appear someone had accidentaly set the channel to invite only, it is fixed now. I mailed Jani with the same question :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP-DEV] Weak references in PHP
At 08:00 PM 2/28/2003 +0300, Konstantin Knizhnik wrote: Hello Andi, The problem is that script can fetch very large number of objects and all of them doesn't fit in the memory. Lets say we have very large list of objects (several millions objects or more). And our script traverse the list and fetch objects one by one and do some calculations (for example calculates total sum). So at each moment of time only one persistent object is actually needed. But without weak references we will have to keep all these millions of objects in memory. If you need to go over a list of million objects you are doing something wrong :) Also performance of OODBBS greatly depends on efficient caching of objects. If we throw away all objects after each request and has to reload them from the server for each request, then performance will we awful. It is very significant to be able to cache most frequently used objects. LRU or some other discipline can be used for it. But any not depending from the discipline we use we need some mechanism which allows to map OPIDs to instances and do not prevent GC from collecting the objects. I disagree. JDO performs well and doesn't cache the objects as usually pessimistic locking is used with it. Of course, if you want to use optimistic locking and the nature of your application allows you to do so efficiently the caching might make sense (or it's mainly a read-only app). That is why almost all languages with implicit memory deallocation have some kind of weak references. And I was wondered when do not find such facility in PHP. Using __destruct method (thanks to George) it may be possible to implement what I need, but only if object cache is implemented in C (and so is not visible for PHP garbage collector). So no pure PHP solution exits. Unfortunately I didn't fins any reference to __destruct method in PHP manual and do not understand how it works. If I just declare __destruct method in class, it is not invoked when object is destructed. I don't quite understand why you need __destruct() as other systems in Java don't use this but I might be completely misunderstanding what you want to do. Yes, you'll need to do this with a C extension. Anyway, good luck. I hope the Engine 2 solves some of your problems (such as object handles which allow you to always access the same DB object). Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Flex never-interactive mode
At 12:48 PM 2/26/2003 -0800, Rasmus Lerdorf wrote: I think we can add %option never-interactive to the ini-scanner lexer to speed it up a tiny little bit. Speeding up the ini scanner might be important for the folks running the cgi version. More importantly, to me anyway, when we know we are not interactive, should we not programmatically set is_interactive to false for the language scanner as well? I did this here and the ioctl syscalls that come from the isatty() calls in the lexer dropped away speeding things up nicely. Do you have any figures? (req/s wise) I think we can set it to false when we know we're not interactive. It shouldn't be a problem. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Name of variable
You can't get the name of the variable. For what purpose do you need it? Andi At 03:45 PM 2/22/2003 +0100, Ivan Rodriguez wrote: Hello, i need to get the name of the variables who passed in one function, for example: switch ((*struc)-type) { case IS_BOOL: fprintf(_dyn_log_file_fp, %sbool:%s\n, COMMON, ((*struc)-value.lval?true:false)); break; With this i get the typo of variable, and what can i do to get the name of variable?¿? Thx. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Name of variable
I think xdebug might do it (http://xdebug.derickrethans.nl/) although I've never used it. Andi At 03:56 PM 2/22/2003 +0100, Ivan Rodriguez wrote: I need to get the because i doing a simple debugger, and i get the type of variable and his information , and i would like to get his name, any possible way does not exist?¿ thx El sáb, 22-02-2003 a las 15:42, Andi Gutmans escribió: You can't get the name of the variable. For what purpose do you need it? Andi At 03:45 PM 2/22/2003 +0100, Ivan Rodriguez wrote: Hello, i need to get the name of the variables who passed in one function, for example: switch ((*struc)-type) { case IS_BOOL: fprintf(_dyn_log_file_fp, %sbool:%s\n, COMMON, ((*struc)-value.lval?true:false)); break; With this i get the typo of variable, and what can i do to get the name of variable?¿? Thx. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Announcement: Next generation ext_skel
It'd be nice to see an example of the XML. I liked the simplicity of today's prototype file, I'm not sure XML isn't an overkill. Andi At 11:24 AM 2/19/2003 +0100, Hartmut Holzgraefe wrote: i've just added the first working results of a replacement for the good old ext_skel script in php/scripts/ext_skel_ng ext_skel_ng is meant to replace the current ext_skel completely, and IMHO it is already at least as capable as the old one. ext_skel_ng is a 'pure' php solution, it only depends on php itself and the xml extension which is enabled by default instead of a simple proto file and some command line options it is now completely driven by an XML file similar to (and inspired by) the PEAR package.xml format code generation is already a little more clever than the previous template apporach, and preliminary support for M$ developer studio .dsp project files has just been added :) see the attached README file below for further info ... - php/scripts/ext_skel_ng/README sorry, no real documentation yet ... just a short look at what is going on ext_skel_ng.php gets an extension description from an extension.xml file and generates working code and documentation stubs from that call php ext_skel_ng.php to see it at work, it will create a dummy extension including - module globals and ini paramter setup - function registration and stubbs - documentation framework - config.m4 (only minimal for now) - ... almost every aspect of an extension may now be configured using one xml description file instead of the old mixture of command line parameters and a proto file it is even possible to embed function code into the xml description right away, so it should be possible to create complete working extensions from just the xml description without further editing in a not to distant future for now almost all the 'helpfull comments' have been removed from the generated code. some of them (like 'uncomment this if you have ini params) just don't make sense anymore, others will come back (configurable) at a later state ... have fun! -- Six Offene Systeme GmbH http://www.six.de/ i.A. Hartmut Holzgraefe Email: hartmut@xx Tel.: +49-711-99091-77 Sie finden uns auf der CeBIT in Halle 6/H44 http://www.six.de/cebit2003/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [patch] solaris getcwd() brokeness
At 03:41 PM 2/13/2003 -0500, James E. Flemer wrote: RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v retrieving revision 1.41 diff -u -b -r1.41 tsrm_virtual_cwd.c --- TSRM/tsrm_virtual_cwd.c 6 Nov 2002 18:07:22 - 1.41 +++ TSRM/tsrm_virtual_cwd.c 13 Feb 2003 20:40:07 - @@ -303,7 +303,7 @@ return (0); #if !defined(TSRM_WIN32) !defined(NETWARE) - if (IS_ABSOLUTE_PATH(path, path_length)) { + if (IS_ABSOLUTE_PATH(path, path_length) || (state-cwd_length 1)) { if (use_realpath realpath(path, resolved_path)) { path = resolved_path; path_length = strlen(path); Will realpath() work in cases where getcwd() didn't work? (btw it's nicer to check state-cwd_length == 0 than 1 IMO). @@ -363,6 +363,7 @@ } + if (state-cwd_length 0 || IS_ABSOLUTE_PATH(path, path_length)) { ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, tok); while (ptr) { ptr_length = strlen(ptr); @@ -416,6 +417,11 @@ state-cwd[state-cwd_length+1] = '\0'; state-cwd_length++; } + } else { + state-cwd = (char *) realloc(state-cwd, path_length+1); + memcpy(state-cwd, path, path_length+1); + state-cwd_length = path_length; + } I'm trying to think if there's some other way of doing this. What is the main problem in this loop? Does it add / or c:\ in the beginning of the string? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [patch] solaris getcwd() brokeness
Hey, The fchdir() part of the patch looks fine but I didn't quite understand the rest. PHP only uses realpath() if it doesn't fail, so what is the exact problem? What does that other code do? Andi At 03:29 PM 2/12/2003 -0500, James E. Flemer wrote: Well all the fancy new streams code in 4.3.0 seems to tickle a Solaris issue with getcwd(). It seems that under certain cases solaris' getcwd() fails when other os' work. Consequently 4.3.0 causes a huge ammount of breakage for some sites running solaris. Below is a patch that seems to work around the problem. This may not be the best approach, but it was an attempt at a quick-fix so that 4.3.0 would be usable for now. This problem has bug number: #21310 [1]. Comments welcome. I'd like to commit this (or similar) before any more releases are made. -James [EMAIL PROTECTED] [1] http://bugs.php.net/21310 ]] Patch sponsored by: The University of Vermont [[ Index: TSRM/tsrm_virtual_cwd.c === RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v retrieving revision 1.41 diff -u -b -u -r1.41 tsrm_virtual_cwd.c --- TSRM/tsrm_virtual_cwd.c 6 Nov 2002 18:07:22 - 1.41 +++ TSRM/tsrm_virtual_cwd.c 12 Feb 2003 04:39:11 - @@ -303,7 +303,7 @@ return (0); #if !defined(TSRM_WIN32) !defined(NETWARE) - if (IS_ABSOLUTE_PATH(path, path_length)) { + if (IS_ABSOLUTE_PATH(path, path_length) || (state-cwd_length 1)) { if (use_realpath realpath(path, resolved_path)) { path = resolved_path; path_length = strlen(path); @@ -363,6 +363,7 @@ } + if (state-cwd_length 0 || IS_ABSOLUTE_PATH(path, path_length)) { ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, tok); while (ptr) { ptr_length = strlen(ptr); @@ -416,6 +417,11 @@ state-cwd[state-cwd_length+1] = '\0'; state-cwd_length++; } + } else { + state-cwd = (char *) realloc(state-cwd, path_length+1); + memcpy(state-cwd, path, path_length+1); + state-cwd_length = path_length; + } if (verify_path verify_path(state)) { CWD_STATE_FREE(state); Index: main/main.c === RCS file: /repository/php4/main/main.c,v retrieving revision 1.512.2.5 diff -u -b -u -r1.512.2.5 main.c --- main/main.c 16 Dec 2002 15:44:06 - 1.512.2.5 +++ main/main.c 12 Feb 2003 04:39:12 - @@ -1507,7 +1507,11 @@ { zend_file_handle *prepend_file_p, *append_file_p; zend_file_handle prepend_file, append_file; +#ifdef VIRTUAL_DIR char *old_cwd; +#else + int old_cwd_fd; +#endif char *old_primary_file_path = NULL; int retval = 0; @@ -1515,9 +1519,11 @@ if (php_handle_special_queries(TSRMLS_C)) { return 0; } +#ifdef VIRTUAL_DIR #define OLD_CWD_SIZE 4096 old_cwd = do_alloca(OLD_CWD_SIZE); old_cwd[0] = '\0'; +#endif zend_try { #ifdef PHP_WIN32 @@ -1528,7 +1534,11 @@ if (primary_file-type == ZEND_HANDLE_FILENAME primary_file-filename) { +#ifdef VIRTUAL_DIR VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1); +#else + old_cwd_fd = open(., 0); +#endif VCWD_CHDIR_FILE(primary_file-filename); } @@ -1578,10 +1588,14 @@ } zend_end_try(); +#ifdef VIRTUAL_DIR if (old_cwd[0] != '\0') { VCWD_CHDIR(old_cwd); } free_alloca(old_cwd); +#else + fchdir(old_cwd_fd); +#endif return retval; } /* }}} */ Index: main/safe_mode.c === RCS file: /repository/php4/main/safe_mode.c,v retrieving revision 1.51 diff -u -b -u -r1.51 safe_mode.c --- main/safe_mode.c6 Nov 2002 18:07:23 - 1.51 +++ main/safe_mode.c12 Feb 2003 04:39:12 - @@ -121,6 +121,8 @@ VCWD_REALPATH(filename, path); *s = DEFAULT_SLASH; } else { + path[0] = '.'; + path[1] = '\0'; VCWD_GETCWD(path, sizeof(path)); } } /* end CHECKUID_ALLOW_ONLY_DIR */ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] (resend) fix for bug #21600 and #22231
We'll review it. I think we'll use it almost as-is except that we won't do the old check variable_ptr_ptr != value_ptr_ptr If you don't see anything on this front in the next couple of days please remind me. Andi At 03:58 AM 2/16/2003 +0900, Moriyoshi Koizumi wrote: Hi, Could anyone who has ZE karma review this patch again? Thanks, Moriyoshi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] new idate() - sunrise() - sunset() functions
I haven't been following this whole discussion. However, the function names should follow the coding standards and be named something like date_sunrise(), date_sunset() (or whatever other prefix makes sense). Andi At 05:02 PM 2/6/2003 +0200, Moshe Doron wrote: Zeev Suraski [EMAIL PROTECTED] wrote in message 5.1.0.14.2.20030206161428.050f11c0@localhost">news:5.1.0.14.2.20030206161428.050f11c0@localhost... At 13:36 06/02/2003, moshe doron wrote: b. sunrise() c. sunset() Hrm, what are these functions? * {{{ proto mixed sunrise(mixed time[, double latitude][, double longitude][, double zenith,][ double gtm_offset][, int format]) Returns time of sunrise for a given day location */ /* {{{ proto mixed sunset(mixed time[, double latitude][, double longitude][, double zenith,][ double gtm_offset][, int format]) Returns time of sunset for a given day location */ i wrote those functions as infrastructures for the calendar extension for returning optionaly the 'real' date depending on the calendar native e.g, the jewish dayes are come by the night mean the day is changed on sunset. the information is is also used for other religion tasks (e.g, jewish and arabic prayer times), for astronomy studies and for travelers design. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] new idate() - sunrise() - sunset() functions
At 12:47 PM 2/7/2003 +0200, moshe doron wrote: Andi Gutmans [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I haven't been following this whole discussion. However, the function names should follow the coding standards and be named something like date_sunrise(), date_sunset() (or whatever other prefix makes sense). here is part of my replay to Leon Atkinson: Also, shouldn't sunrise() and sunset() be cal_sunrise() and cal_sunset()? well, since sunset() sunrise() have aspects more then cal_* related, i thought the right place is standard. new astronomy extension, or linking against exisint lib, 'll be overhead since i want use it on the calendar extension, that is build by default on VC. Even functions in standard have a prefix. Only ancient ones don't and we didn't fix them for BC reasons. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] new idate() - sunrise() - sunset() functions
At 02:37 PM 2/7/2003 +0200, moshe doron wrote: well, what about sun_set(), sun_rise()? I hope you're kidding. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: Bug # 13551, bcmath scale:: when to apply
At 11:31 AM 2/4/2003 -0800, Sara Golemon wrote: BTW, is php_str2num() only supposed to work on whole or decimal values? What about exponents? bc_str2num() only allows whole or decimal values so that's all I wrote php_str2num to allow for. By 'exponents' do you mean scientific notation? I don't see any support for that in the bc conversion functions. I don't suppose it would take much to add that capability, but that'd be a feature change and should probably be done separately (and only in HEAD). Nah, if it doesn't support scientific notation then I'd leave it. IMO, just go ahead and commit. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] RE: zend_API.c
Hey, I think the discussion you guys are having is much broader than just mysqli. We should probably come up with a general approach which we will use consistently for PHP 5. I suggest we move this discussion to the PHP 5 dev list and try and come up with a good solution. Obviously we will keep the functional support for all extensions like PHP 4. The only question is, if and how we support an OO paradigm. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP 5 mailing list
At 03:22 PM 2/3/2003 -0500, Dan Kalowsky wrote: To all concerned, I would like to request that yet again the PHP5 mailing list be made public and no longer kept private. Given that comments in the past few hours have centered around the existence of the mailing list, it seems rather absurd to continue the secrecy notion. To those who will say it is open for joining, I submit to you the following considerations. First there is no mention of said mailing list existing on the mailing-list tab of the PHP main web site. Second there is still no publicly viewable record of what has transpired on the mailing list (which means the 'read the archives' comment is futile). I for one find it really annoying to find changes to PHP being done without discussion. Only later to find through an IRC channel what was done and why. As far as I know the mailing list is open for anyone to subscribe (it is moderated). I think a new archive was created which starts about a week ago but I'm not sure where it can be accessed. I am very happy that the mailing-list tab on the PHP main web site doesn't include it yet. I'd prefer only people who are active in the developer's community (i.e. php-dev, php-qa) to be part it. The last thing we need is to have the whole PHP users community on it. We won't get anything done and that was the whole reason to keep things small. Andi P.S.-I don't think your negative tone was called for. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: Bug # 13551, bcmath scale:: when to apply
Hi, Indeed I wasn't aware of this bug report. It seems as if your patch is fine although I could only look at it briefly. It does look strange that you need to initialize the resulting scale manually. I thought the BC functions are supposed to take care of returning the results as the right scale. In any case, it probably makes sense for you to go ahead and commit it. BTW, is php_str2num() only supposed to work on whole or decimal values? What about exponents? I think you're probably right but I just want to make sure you thought about it. Thanks, Andi At 01:51 PM 2/3/2003 -0800, Sara Golemon wrote: Andi, Nicos assigned this bug to you a month ago, but since I've seen no activity (and it's entirely possible you didn't know he'd assigned it) I went ahead and took a crack at it. Would you care to give me the go ahead to commit/close for you? ...or tell me to mind my own bugs? :) Patches against PHP_4_3 and HEAD can be found at: http://frankenbox.alphaweb.net/test/php_4_3.bcmath.diff.txt and http://frankenbox.alphaweb.net/test/HEAD.bcmath.diff.txt The idea being to automagically determine the scale of the input numbers so that they are not truncated prior to the op. Then, once the op has been performed, reduce the scale to whatever was requested. The result-n_scale = scale; line might look a little dangerous, but since it only comes after lines which create 'result' with a scale of *at minimum* 'scale' it means that 'result-n_scale' will always be = 'scale' and hence assigning it to 'scale' will always result in a reduction (or no change at all) and bc_num2str won't go looking in undefined sections of the bc_num val. -Pollita P.S. - This one's for you sniper ;) -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Again scope
At 10:20 PM 2/2/2003 +0100, Maxim Maletsky wrote: On Sun, 2 Feb 2003 22:06:24 +0100 (CET) Derick Rethans [EMAIL PROTECTED] wrote: On Sun, 2 Feb 2003, Maxim Maletsky wrote: stranno, dovrebbe comunque funzionare datto che ZEND_CHANGES.txt ha quasi un anno mentre il tuo CVS checkout e, credo, sia un sacco piu fresco. Sicuro che non funzioni? No problem if you answer in italian, but there is no need to CC the list then :-) Sorry, guys - haven't noticed that Michele added php-dev to the conversation :) (Should have guessed why his answer was in english) Anyway, what he talked about was why that code didn't work for him. Sounded strange to me since it was noted in ZEND_CHANGES.txt. The file isn't up-to-date. I'll make sure it's correct once namespaces are finalized. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Reducing the number of system calls for includes
At 04:51 PM 1/24/2003 -0800, Rasmus Lerdorf wrote: Which broken systems? Certainly not on FreeBSD or Linux. A little test: stat(/home/rasmus/foo/u2.inc,sb); That ends up doing just a single stat on FreeBSD: stat(/home/rasmus/foo/u2.inc,0x9fbffa0c) = 0 (0x0) and on Linux: stat64(/home/rasmus/foo/u2.inc, {st_mode=S_IFREG|0644, st_size=12, ...}) = 0 Yes you are right. But I still think the advantages of having a canonical file path is good. It improves error messages, it allows for open_basedir and include_once() to work 100%. I don't think it's worth killing good stable functionality for this. What needs to be taken from your timings is not the relative time of stat() vs. realpath() but the absolute times. You can see that on Linux the speed of realpath() is 12 microsecond. I don't believe you can feel this in a script even if you have tens of realpath()'s per script (at least vs. stat()). Now on FreeBSD it takes about half a millisecond. That is much more but I'm not sure it's still worth breaking functionality for this. That said, we could possibly have a fast mode and use fstat() to get some device information on the open file. I am worried about functionality though. I'm not sure it's worth breaking. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Reducing the number of system calls for includes
At 02:30 AM 1/25/2003 -0800, Rasmus Lerdorf wrote: That said, we could possibly have a fast mode and use fstat() to get some device information on the open file. I am worried about functionality though. I'm not sure it's worth breaking. Yes, fstat() is fast. And perhaps it isn't worth breaking functionality across the board, but in my particular case I don't really have a choice. It is simply too slow to handle the loads that it needs to handle and either I need to get twice as many machines or I need to lose some functionality. Another idea would be to try to streamline the normal case for an absolute pathname. How about doing a readlink() on it. If that tells us that it is a link, then we know there is something funky and we can do a realpath, otherwise we just assume it is canonical assuming there are no . .. or // in the filename in which case we fall back to a realpath() as well. Hmm I'm not sure this would give you what you're looking for. I think it only works if the last element of the path is a symbolic link but I might be wrong. I'm not quite sure of the semantics of readlink(). Or, the really straightforward dumbass solution, have some hint we can pass along that tells the parser to treat what follows as a canonical filename. include \001/home/rasmus/foo/u2.inc; A bit too hacky I guess. Perhaps something like: include_canonical /home/rasmus/foo/u2.inc; And we would simply assume that this is a canonical filename and skip all the checks. This last one is probably what I will need to do, but I will do some tests on the readlink() optimization and see if that buys me anything. I think both of these solutions are too hacky. If we end up deciding that it makes sense to have a mode which uses fstat() then we should probably just document what we believe could break and with a use this with care! warning. I'm going to try and think if there are other options which won't break functionality. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Reducing the number of system calls for includes
I can't really think of any way of getting around this. include_once() and require_once() are basic language constructs and they require this. There is no way I can think of to cache these results because they often depend on include_path and cwd which might change. Yes, we could try and think of all the things which could effect it and use those as part of a hash key but frankly, smart OS's like Linux don't take too long and the file system cache usually works pretty well. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Reducing the number of system calls for includes
At 04:06 PM 1/24/2003 -0800, Rasmus Lerdorf wrote: 5. Looking at Linux's syscall implementation and implementing the good ideas in FreeBSD. Well yes, but fixing the os is pretty drastic. For now I will be patching things here to short-circuit all that stuff, but I think it is also something we should look at in general for PHP. As for numbers, I basically doubled the req/sec rate of a box by eliminating a bunch of system calls caused by include_path and open_basedir stat'ing, so in my particular situation here eliminating as many syscalls as I can is having a direct effect. What OS are you running on? Are you running over NFS? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Reducing the number of system calls for includes
At 04:32 PM 1/24/2003 -0800, Rasmus Lerdorf wrote: I can't really think of any way of getting around this. include_once() and require_once() are basic language constructs and they require this. Well, they require us to be able to uniquely identify a file, they do not necessarily require us to know the canonical filename. This could be done in a single stat where we grab the device number and inode. Yeah but on broken systems single stat's also stat each directory (AFAIK). I don't think it's any faster or at least not noticably. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Reducing the number of system calls for includes
At 02:42 AM 1/25/2003 +0200, Andi Gutmans wrote: At 04:32 PM 1/24/2003 -0800, Rasmus Lerdorf wrote: I can't really think of any way of getting around this. include_once() and require_once() are basic language constructs and they require this. Well, they require us to be able to uniquely identify a file, they do not necessarily require us to know the canonical filename. This could be done in a single stat where we grab the device number and inode. Yeah but on broken systems single stat's also stat each directory (AFAIK). I don't think it's any faster or at least not noticably. Just want to correct myself. I don't think it's broken systems but I do think stat() is more or less the same as realpath(). It will still internally stat() each directory. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] bcmath, calendar, ftp, wddx on Win32
At 12:25 PM 1/10/2003 +0100, Lukas Smith wrote: From: Andi Gutmans [mailto:[EMAIL PROTECTED]] Sent: Friday, January 10, 2003 12:14 PM At 06:36 PM 1/9/2003 +0100, Sebastian Bergmann wrote: For as long as I can remember, the bcmath, calendar, ftp and wddx extensions are enabled by default on Win32. But why? I mean, they are not enabled by default on *NIX, so why the inconsistency? Because building this stuff on Windows is harder and it's probably easiest for Windows users to have stuff in by default. So once the PEAR installer is able to handle binaries for windows in a reliable fashion this could be changed? The big difference between Windows and UNIX is that you can usually compile on UNIX systems. But if PEAR handles binaries this way, if and when that happens, then yes. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PROPOSAL: default value handling
This has been discussed in the past and won't be done. PHP behaves like C where the result of the boolean or operation is true or false. Andi At 12:38 AM 1/11/2003 -0500, Nyk Cowham wrote: As a convert from Perl one of the 'features' I miss from Perl is the short-circuit behavior of the or operand (||) and how it can be used to set default values if a passed value is false (0 or ). Thus, in a passed parameter you can write: $result = $value || $default; In perl if the $value variable is false (0 or empty string) then $value will be set to the default value. In PHP the or operand does not short-circuit in this way. Instead I find myself having to write something like: $result = ($_REQUEST['value']) ? $_REQUEST['value'] : 'my default value'; This is not only ugly and difficult to read but has the redundancy of naming the $_REQUEST['value'] variable twice. Another nice feature of using Perl's short-circuit or operand is that defaults can be chained so: $result = $value || $alt_value || $default; Will return the default only if $value and $alt_value have both evaluated as false. In other words the first expression that evaluates as true (actually 'not false' would be more accurate) will be returned, all preceding and subsequent values will be ignored. I don't propose the || operant in PHP should be short-circuited like Perl, but rather either a new operand or new function be added that would have this specific behavior. As an operand it might look like: $result = $value ?: $alt_value ?: [ ...] ?: $default; // reusing the terniary operator in this context would be a reasonable mnemonic. Alternatively if implemented as a function it might look like: $result = choose($value, $alt_value, [ ... ], $default); I would be happy to volunteer to do the work to provide this feature if there is enough support for it's inclusion. Thoughts? Nyk Cowham -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Non threadsafe Windows build
At 07:13 AM 1/11/2003 +0100, Sebastian Bergmann wrote: The project file(s) for the non threadsafe Windows build are out of sync with the thread safe one(s). IIRC, there was already some discussion to ditch the non threadsafe version. That way we didn't have to maintain two sets of files, etc. What do you think? The non-threadsafe version is useful for Windows CGI and debugging. On the other hand, it's quite a drag to maintain. Unless someone steps up and takes responsibility to keep it in sync, or we make a new rule that people have to remember to update both projects, then I think nuking it is OK. What do others think? (I'm interested in hearing from Windows users) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: php4 /ext/standard file.c formatted_print.c
At 12:38 AM 1/12/2003 +0100, Sascha Schumann wrote: On Sun, 12 Jan 2003, Moriyoshi Koizumi wrote: On Sun, Jan 12, 2003 at 12:12:39AM +0100, Sascha Schumann wrote: As many past security advisories have shown, signedness issues are the frequent cause for severe vulnerabilities in software (recent examples include MySQL, OpenBSD kernel). Actually codes like below produce vulnerble runtimes because the length of string is expected to be a positive integer value... Yes, unfortunately. Basically the same problem as in the OpenBSD kernel and its select syscall: http://www.phrack.org/phrack/60/p60-0x06.txt Quote: Whilst there is a check [1] on the 'nd' argument (nd represents the highest numbered descriptor plus one, in any of the fd_sets), which is checked against the p-p_fd-fd_nfiles (the number of open descriptors that the process is holding), this check is inadequate -- 'nd' is declared as signed [6], so it can be negative, and therefore will pass the greater-than check [1]. Then 'nd' is put through a macro [2], in order to calculate an unsigned integer, 'ni', which will eventually be used as the the length argument for the copyin operation. I might be misunderstanding the problem and I didn't have time to read the phrack article, but doesn't this mean that leaving it unsigned is better? It wouldn't pass the length check and thus, memcpy() wouldn't convert a negative number to something huge. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Include a file from inside an extension...
You are probably best off using zend_eval_string() and eval include $myfile.inc;. Andi At 04:51 PM 1/7/2003 +, Stefano Corsi wrote: Hello, does someone understand if this is the right procedure to include a filename from inside a C extension? MAKE_STD_ZVAL(filename_z); ZVAL_STRING(filename_z, myfile.inc, 1); op = compile_filename(ZEND_INCLUDE, filename_z); zend_execute(op TSRMLS_CC); Thanks, Stefano -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] size of session vars
Hi, Lately, when people start asking php-general questions on php-dev people give them the answer and add but you should have asked on the php-general list. Having received a good answer from php-dev gives them incentive to mail us again :) I suggest we keep to the standard polite reply that they should please mail php-general without giving them the answers. Andi At 04:26 AM 1/8/2003 -0700, Rick Widmer wrote: At 10:52 AM 1/8/03 +0100, Hannes Smit wrote: Does anyone know how much space can be stored in a session? How much free space do you have on the drive that holds the session data? I don't think there is an arbitrary limit on session size. Just the limitations of the resources of your machine. This thread probably belongs on php-general. This list is for the development _of_ php, not _with_ php. Rick -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] bcmath, calendar, ftp, wddx on Win32
At 06:36 PM 1/9/2003 +0100, Sebastian Bergmann wrote: For as long as I can remember, the bcmath, calendar, ftp and wddx extensions are enabled by default on Win32. But why? I mean, they are not enabled by default on *NIX, so why the inconsistency? Because building this stuff on Windows is harder and it's probably easiest for Windows users to have stuff in by default. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] What headers/libs does Win32 Snaps build use?
At 01:31 AM 1/8/2003 +0100, Edin Kadribasic wrote: Yes, Steph is right, the set of libraries used on the snaps machine is ~70MB (uncompressed) and I don't think it's practical to update win32build.zip to include them all. And this 70 MB does not include files needed for building ext/infromix, ext/interbase and sapi/pi3web. I actually think the more complete we can make the win32build.zip the better. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] ext_skel
Hi, Someone seems to have changed ext_skel to create the ZEND_FETCH_RESOURCE() call to be inside an if() statement to check the resource is non-zero, i.e.: if (myresource) { ZEND_FETCH_RESOURCE(); } What is the reason this was added? The resource mechanism checks for this automatically and handles relevant errors in a consistent way. I think this if() should be removed. Also does anyone object to ZEND_FETCH_RESOURCE() being commented. I think it's beneficial for newly generated extensions to be able to compile right away so that ppl can see that their setup, buildconf, config.m4 and so on is OK for development. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /sapi/apache2filter php_apache.h sapi_apache2.c
At 08:25 PM 1/3/2003 +0100, Sascha Schumann wrote: On Fri, 3 Jan 2003, Anantha Kesari H Y wrote: hyanantha Fri Jan 3 10:59:02 2003 EDT Modified files: /php4/sapi/apache2filter php_apache.h sapi_apache2.c Log: Modifications for NetWare. I need to say it again. These modifications are *extremely* ugly. It's like spilling a glass of wine over important documents. You won't be able to remove the spilled substance without expensive labor. These modifications lack proper factoring. They repeat the same kind of change all over our code base. Instead of hiding some of netware's properties behind appropiate macros and typedefs, you duplicate existing code in a slightly changed manner all over the place. What do you guys think about this? I agree. The novell changes are butt ugly. They are just hacking at our code instead of fixing it nicely. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4 /sapi/apache2filter php_apache.h sapi_apache2.c
It doesn't make sense to me to have the following lines repeated all over PHP: +#if defined(NETWARE) defined(CLIB_STAT_PATCH) + struct stat_libc finfo; +#else struct stat finfo; +#endif You are making the PHP source tree very hard to maintain. If anything, we should probably create some kind of abstraction in TSRM and use that everywhere. These fixes might achieve your goal for making PHP work on netware but they are making our code butt ugly and hard to maintain. Andi At 03:59 PM 1/3/2003 +, Anantha Kesari H Y wrote: hyanantha Fri Jan 3 10:59:02 2003 EDT Modified files: /php4/sapi/apache2filterphp_apache.h sapi_apache2.c Log: Modifications for NetWare. Index: php4/sapi/apache2filter/php_apache.h diff -u php4/sapi/apache2filter/php_apache.h:1.19 php4/sapi/apache2filter/php_apache.h:1.20 --- php4/sapi/apache2filter/php_apache.h:1.19 Tue Dec 31 10:59:03 2002 +++ php4/sapi/apache2filter/php_apache.hFri Jan 3 10:59:02 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_apache.h,v 1.19 2002/12/31 15:59:03 sebastian Exp $ */ +/* $Id: php_apache.h,v 1.20 2003/01/03 15:59:02 hyanantha Exp $ */ #ifndef PHP_APACHE_H #define PHP_APACHE_H @@ -41,7 +41,11 @@ /* Index for reading from buffer */ int post_idx; /* stat structure of the current file */ +#if defined(NETWARE) defined(CLIB_STAT_PATCH) + struct stat_libc finfo; +#else struct stat finfo; +#endif /* Buffer for request body filter */ char *post_data; /* Whether or not we've processed PHP in the output filters yet. */ Index: php4/sapi/apache2filter/sapi_apache2.c diff -u php4/sapi/apache2filter/sapi_apache2.c:1.101 php4/sapi/apache2filter/sapi_apache2.c:1.102 --- php4/sapi/apache2filter/sapi_apache2.c:1.101Tue Dec 31 10:59:03 2002 +++ php4/sapi/apache2filter/sapi_apache2.c Fri Jan 3 10:59:02 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: sapi_apache2.c,v 1.101 2002/12/31 15:59:03 sebastian Exp $ */ +/* $Id: sapi_apache2.c,v 1.102 2003/01/03 15:59:02 hyanantha Exp $ */ #include fcntl.h @@ -29,7 +29,11 @@ #include SAPI.h #include ext/standard/php_smart_str.h +#ifndef NETWARE #include ext/standard/php_standard.h +#else +#include ext/standard/basic_functions.h +#endif #include apr_strings.h #include ap_config.h @@ -47,6 +51,10 @@ #include php_apache.h +#ifdef NETWARE +#undef shutdown /* To avoid Winsock confusion */ +#endif + /* A way to specify the location of the php.ini dir in an apache directive */ char *apache2_php_ini_path_override = NULL; @@ -160,9 +168,16 @@ ctx-finfo.st_uid = ctx-r-finfo.user; ctx-finfo.st_gid = ctx-r-finfo.group; ctx-finfo.st_ino = ctx-r-finfo.inode; +#if defined(NETWARE) defined(CLIB_STAT_PATCH) + ctx-finfo.st_atime.tv_sec = ctx-r-finfo.atime/100; + ctx-finfo.st_mtime.tv_sec = ctx-r-finfo.mtime/100; + ctx-finfo.st_ctime.tv_sec = ctx-r-finfo.ctime/100; +#else ctx-finfo.st_atime = ctx-r-finfo.atime/100; ctx-finfo.st_mtime = ctx-r-finfo.mtime/100; ctx-finfo.st_ctime = ctx-r-finfo.ctime/100; +#endif + ctx-finfo.st_size = ctx-r-finfo.size; ctx-finfo.st_nlink = ctx-r-finfo.nlink; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Happy New Year!
Happy New Year to everyone! It's already 2003 here in Israel. Thanks to everyone who has contributed. The way things look, 2003 will be a very fruitful year for PHP with hopefully a new major version! A special thanks to Derick for the cool Look Back of 2002! Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] option to start in PHP mode
At 01:45 AM 12/28/2002 +0100, Marcus Börger wrote: At 22:40 27.12.2002, Andi Gutmans wrote: I don't think it's beneficial to PHP to have two modes especially as the cli more you're talking about would support ? followed by a ?php. So all you're saving is the opening tag. I think any PHP programmer can handle it. Let's keep things similar across the board. Andi I agree here, too. But when you still want that stuff we can expand CLI by a new switch that executes the script in eval() mode. This way we do not have the problem with the closing ? tags mentioned by Andi (i just thought about starting a RFC on this). Why don't we have the ? problem? You can also use ? in eval()'s. Anyway, Rasmus mentioned that a switch already exists although I don't think it's such a great idea due to the previously mentioned reasons. I think all PHP code should be consistent. Andi marcus At 02:11 PM 12/27/2002 -0500, Andrei Zmievski wrote: We've talked about this in the past, but let's bring it up again. It is a bit awkward to use CLI when it requires those ?php and ? tags. We should probably have a command-line option that tells the parser to start in PHP mode instead of HTML/text. Any thoughts on this? -Andrei http://www.gravitonic.com/ * What were the first 15 billion years of the universe like for you? * -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] option to start in PHP mode
I don't think it's beneficial to PHP to have two modes especially as the cli more you're talking about would support ? followed by a ?php. So all you're saving is the opening tag. I think any PHP programmer can handle it. Let's keep things similar across the board. Andi At 02:11 PM 12/27/2002 -0500, Andrei Zmievski wrote: We've talked about this in the past, but let's bring it up again. It is a bit awkward to use CLI when it requires those ?php and ? tags. We should probably have a command-line option that tells the parser to start in PHP mode instead of HTML/text. Any thoughts on this? -Andrei http://www.gravitonic.com/ * What were the first 15 billion years of the universe like for you? * -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: PHP 4.3.0 released
I think you're right. I also see some weird language :) Andi At 12:18 AM 12/28/2002 +0100, Niels Leenheer wrote: [snip] What this means for users is that any I/O function that works with streams (and that is almost all of them) can access built-in protocols, such as HTTP/HTTPS and FTP/FTPS, as well as custom protocols registered from PHP scripts. For more information please see: * List of Supported Protocols/Wrappers http://www.php.net/manual/en/wrappers.php Does anyone else have problems understanding the content on this page? Seems to me like something went wrong with one of translations updates. Anyway, congratulations to all on the release of PHP 4.3.0. Niels [EMAIL PROTECTED] -- phpAdsNew, open source adserver www.phpadsnew.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP-DEV] ext_skel
To: David Gillies [EMAIL PROTECTED] From: Andi Gutmans [EMAIL PROTECTED] Subject: Re: [PHP-DEV] ext_skel Yeah but then it might make sense to print something like Argument passed = , no? Andi At 08:56 AM 12/23/2002 -0800, David Gillies wrote: Well, if nothing else, for the novice extension developer it gives an example of how to retrieve an argument, without having to go to the Zend API docs. Best Wishes David Gillies San Jose Costa RIca --- Andi Gutmans [EMAIL PROTECTED] wrote: Hey, What's the reason that confirm_myextension_compiled(..) takes a string as an argument? Why doesn't it just use the string myextension in it's message? For those who don't remember it prints out Congratulations! You have successfully modified ext/myextension/config.m4. Module myextension is now compiled into PHP.. The second appearance of myextension is the parameter passed to the function. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: Re: [PHP-DEV] ext_skel
Actually I think we should keep it as simple as it is today. I'd just change what the function prints out :) Andi At 12:43 PM 12/23/2002 -0800, David Gillies wrote: OK, how about a much-expanded version for 4.3.1, say? I'm a big fan of self-documenting code (use the source, Luke). Perhaps a default function with all the bells and whistles (checking for references, grabbing a resource, etc, all documented up the wazoo). Best Wishes David Gillies San Jose Costa Rica --- Andi Gutmans [EMAIL PROTECTED] wrote: To: David Gillies [EMAIL PROTECTED] From: Andi Gutmans [EMAIL PROTECTED] Subject: Re: [PHP-DEV] ext_skel Yeah but then it might make sense to print something like Argument passed = , no? Andi At 08:56 AM 12/23/2002 -0800, David Gillies wrote: Well, if nothing else, for the novice extension developer it gives an example of how to retrieve an argument, without having to go to the Zend API docs. Best Wishes David Gillies San Jose Costa RIca --- Andi Gutmans [EMAIL PROTECTED] wrote: Hey, What's the reason that confirm_myextension_compiled(..) takes a string as an argument? Why doesn't it just use the string myextension in it's message? For those who don't remember it prints out Congratulations! You have successfully modified ext/myextension/config.m4. Module myextension is now compiled into PHP.. The second appearance of myextension is the parameter passed to the function. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/mime_magic mime_magic.c
At 08:50 AM 12/23/2002 +, Stefan Esser wrote: sesser Mon Dec 23 03:50:06 2002 EDT Modified files: /php4/ext/mime_magicmime_magic.c Log: fix compile error on IRIX Index: php4/ext/mime_magic/mime_magic.c diff -u php4/ext/mime_magic/mime_magic.c:1.19 php4/ext/mime_magic/mime_magic.c:1.20 --- php4/ext/mime_magic/mime_magic.c:1.19 Mon Nov 25 07:30:24 2002 +++ php4/ext/mime_magic/mime_magic.cMon Dec 23 03:50:05 2002 @@ -15,7 +15,7 @@ | Author: Hartmut Holzgraefe [EMAIL PROTECTED] | +--+ - $Id: mime_magic.c,v 1.19 2002/11/25 12:30:24 hholzgra Exp $ + $Id: mime_magic.c,v 1.20 2002/12/23 08:50:05 sesser Exp $ This module contains a lot of stuff taken from Apache mod_mime_magic, so the license section is a little bit longer than usual: @@ -358,7 +358,7 @@ fname = conf-magicfile; /* todo cwd? */ f = fopen(fname, rb); if (f == NULL) { - (int) conf-magic = -1; + *(int *)conf-magic = -1; return -1; } This is very ugly and this kind of code is prone to error. Can't you cast the right side? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Interesting result
It doesn't matter because the behavior here is undefined just like in C. You can't use a variable and it's post/pre increment value in the same expression. Andi At 03:26 PM 12/21/2002 +0200, Andrey Hristov wrote: Hi, i got an interesting case : ?php $a = 1; var_dump($a + $a++); $a = 1; $x = $a; var_dump($a + $a++); ? Result int(2) int(3) Can somebody explain why if there is reference to the var the result is different? Andrey -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Interesting result
Again, as it is undefined in PHP the question Why in itself is wrong :) Andi At 04:43 PM 12/21/2002 +0200, Andrey Hristov wrote: - Original Message - From: Andi Gutmans [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, December 21, 2002 4:17 PM Subject: Re: [PHP-DEV] Interesting result It doesn't matter because the behavior here is undefined just like in C. You can't use a variable and it's post/pre increment value in the same expression. Two years ago I've been told by a professort that a+++a+++a depends on the language and the compiler. Yesterday i found this page : http://www.blueshoes.org/en/developer/syntax_exam/ If a=1 - Java : 6 PHP : 6 gcc 2.95 : 3 I know that is on the edge and I will never use it in real script by I was curious why the reference change the result. Best wishes, Andrey At 03:26 PM 12/21/2002 +0200, Andrey Hristov wrote: Hi, i got an interesting case : ?php $a = 1; var_dump($a + $a++); $a = 1; $x = $a; var_dump($a + $a++); ? Result int(2) int(3) -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: #20993 [Ver]:Elementvaluechangeswithoutasking
Yes I object. Think of references as a symbolic link to the same place. Now you have such a reference in an array which you assign to an additional variable. Now two variables contain copies of an array but somewhere inside you have two copies of the symbolic link. Changing one will change the other. In many ways it makes sense, and even in cases where it's a bit weird and where it seems wrong, I think we should live with it because I don't like having to check the whole array each time. If you have deeply nested arrays it's really slow and doesn't make that much sense. Andi At 05:24 PM 12/21/2002 +0100, Melvyn Sopacua wrote: At 17:16 18-12-2002, Moriyoshi Koizumi wrote: Melvyn Sopacua [EMAIL PROTECTED] wrote: --snip OK so that's a deep copy. As much as I understand the motivation I don't think this should be done. It'll slow down lots of things in PHP. I think this should be solved by documentation. Yes, according to my trivial benchmark, my patch puts a considerable weight on the ZendEngine, to run twice as slowly as the current runtime in the worst case. Seems no way, but I suppose it also sounds a reasonable penalty of using references. Actually - the natural 'feeling' with references is speed increases - not slowdowns, since one expects a 'pointer', rather than a copy. Is there a way to warn when such a refstatement is detected, without causing slowdowns? Then try the new patch. It prints out notices in such cases. Attached is a slightly revised version against PHP_4_3 branch - just an 'english' fix. If there are no objections, can somebody commit it? I'll fix the test accordingly. With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] ext_skel
Hey, What's the reason that confirm_myextension_compiled(..) takes a string as an argument? Why doesn't it just use the string myextension in it's message? For those who don't remember it prints out Congratulations! You have successfully modified ext/myextension/config.m4. Module myextension is now compiled into PHP.. The second appearance of myextension is the parameter passed to the function. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: #20993 [Ver]:Elementvaluechangeswithoutasking
At 07:13 PM 12/21/2002 +0100, Melvyn Sopacua wrote: At 18:24 21-12-2002, Andi Gutmans wrote: Yes I object. Think of references as a symbolic link to the same place. Now you have such a reference in an array which you assign to an additional variable. Now two variables contain copies of an array but somewhere inside you have two copies of the symbolic link. Changing one will change the other. In many ways it makes sense, and even in cases where it's a bit weird and where it seems wrong, I think we should live with it because I don't like having to check the whole array each time. If you have deeply nested arrays it's really slow and doesn't make that much sense. Ok - so there's no way to detect this at the lexer level? Nope. I get the symlink anology, but IMO it doesn't apply here. A copy of the array is passed to the function - not a reference. Yeah but one of those values inside the array is a reference. In both the original and the copy of the array it's the same reference. If you wanna keep the anology, then this resembles symlinking a file, inside a directory and changing a *copy* of the directory, changes the original directory. So - IF it can't be warned about - then we need a big fat warning in the docs. Definitely I think a big warning is in place. Andi Andi At 05:24 PM 12/21/2002 +0100, Melvyn Sopacua wrote: At 17:16 18-12-2002, Moriyoshi Koizumi wrote: Melvyn Sopacua [EMAIL PROTECTED] wrote: --snip OK so that's a deep copy. As much as I understand the motivation I don't think this should be done. It'll slow down lots of things in PHP. I think this should be solved by documentation. Yes, according to my trivial benchmark, my patch puts a considerable weight on the ZendEngine, to run twice as slowly as the current runtime in the worst case. Seems no way, but I suppose it also sounds a reasonable penalty of using references. Actually - the natural 'feeling' with references is speed increases - not slowdowns, since one expects a 'pointer', rather than a copy. Is there a way to warn when such a refstatement is detected, without causing slowdowns? Then try the new patch. It prints out notices in such cases. Attached is a slightly revised version against PHP_4_3 branch - just an 'english' fix. If there are no objections, can somebody commit it? I'll fix the test accordingly. With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: #20993 [Ver]:Elementvaluechangeswithoutasking
I meant a big warning should be in place :) Andi At 08:18 PM 12/21/2002 +0200, Andi Gutmans wrote: At 07:13 PM 12/21/2002 +0100, Melvyn Sopacua wrote: At 18:24 21-12-2002, Andi Gutmans wrote: Yes I object. Think of references as a symbolic link to the same place. Now you have such a reference in an array which you assign to an additional variable. Now two variables contain copies of an array but somewhere inside you have two copies of the symbolic link. Changing one will change the other. In many ways it makes sense, and even in cases where it's a bit weird and where it seems wrong, I think we should live with it because I don't like having to check the whole array each time. If you have deeply nested arrays it's really slow and doesn't make that much sense. Ok - so there's no way to detect this at the lexer level? Nope. I get the symlink anology, but IMO it doesn't apply here. A copy of the array is passed to the function - not a reference. Yeah but one of those values inside the array is a reference. In both the original and the copy of the array it's the same reference. If you wanna keep the anology, then this resembles symlinking a file, inside a directory and changing a *copy* of the directory, changes the original directory. So - IF it can't be warned about - then we need a big fat warning in the docs. Definitely I think a big warning is in place. Andi Andi At 05:24 PM 12/21/2002 +0100, Melvyn Sopacua wrote: At 17:16 18-12-2002, Moriyoshi Koizumi wrote: Melvyn Sopacua [EMAIL PROTECTED] wrote: --snip OK so that's a deep copy. As much as I understand the motivation I don't think this should be done. It'll slow down lots of things in PHP. I think this should be solved by documentation. Yes, according to my trivial benchmark, my patch puts a considerable weight on the ZendEngine, to run twice as slowly as the current runtime in the worst case. Seems no way, but I suppose it also sounds a reasonable penalty of using references. Actually - the natural 'feeling' with references is speed increases - not slowdowns, since one expects a 'pointer', rather than a copy. Is there a way to warn when such a refstatement is detected, without causing slowdowns? Then try the new patch. It prints out notices in such cases. Attached is a slightly revised version against PHP_4_3 branch - just an 'english' fix. If there are no objections, can somebody commit it? I'll fix the test accordingly. With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /sapi/cli php_cli.c
At 11:57 PM 12/20/2002 +0900, Moriyoshi Koizumi wrote: Andi Gutmans [EMAIL PROTECTED] wrote: At 01:28 PM 12/19/2002 +, Wez Furlong wrote: Actually, it does seem valid to me; streams based on FILE* are not registered in the persistent list, so does it make sense to have the associated resources registered as persistent resources when they will get cleaned up by the engine at request shutdown? If these are per-request constants then you are correct and the patch was OK. I thought these were constants which survive requests. Well, only in cli are the constants STDIN, STDOUT, and STDERR registered. So can I commit the patch again? Yep. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] ZE2: accessing a class static variable
This is a known limitation. I will try and address this probably with some kind of special syntax. Andi At 04:49 PM 12/20/2002 +0100, Mickael Bailly wrote: Hello, One line to say this is my first post here, I thought about posting in php-general, but ZE2 is in development, so... I want to access a static variable of a class, but I CANNOT use directly the class name, so class name is in a variable. To be clear: ?PHP class foo { static $conf = 'configuration variable'; } $var = 'foo'; echo $var::$conf ; ? this produces a parsing error... How could I do ? Thanks -- Mickael Bailly -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /sapi/cli php_cli.c
At 01:28 PM 12/19/2002 +, Wez Furlong wrote: Actually, it does seem valid to me; streams based on FILE* are not registered in the persistent list, so does it make sense to have the associated resources registered as persistent resources when they will get cleaned up by the engine at request shutdown? If these are per-request constants then you are correct and the patch was OK. I thought these were constants which survive requests. Andi --Wez. On Wed, 18 Dec 2002, Andi Gutmans wrote: I don't like these voodoo patches. I think if the stream is destroyed twice that should be solved and not the constant itself. Unless you have a good reason please revert your patch and talk to Wez about fixing this properly. Thanks, Andi - ic.flags = CONST_CS | CONST_PERSISTENT; + ic.flags = CONST_CS; -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4 /sapi/cli php_cli.c
At 11:17 AM 12/17/2002 +0900, Moriyoshi Koizumi wrote: Andi Gutmans [EMAIL PROTECTED] wrote: I didn't understand the explanation. Why do you mind if the resources are destroyed before the constants? That's good, no? Sorry, I'm still unsure if my patch is the correct one, as I said in the first mail. As far as I've looked into it, the streams seem to be destructed and freed twice, once in deactivation and once in shutdown. If you think my patch is bogus, feel free to revert it unless I can give more reasonable explanation. Hi, I don't like these voodoo patches. I think if the stream is destroyed twice that should be solved and not the constant itself. Unless you have a good reason please revert your patch and talk to Wez about fixing this properly. Thanks, Andi Moriyoshi Andi At 03:22 PM 12/15/2002 +0900, Moriyoshi Koizumi wrote: It appears that the problem was because stream resources are finalized before the constants that contain those resources are destructed, as php_stream_open_wrapper_ex() doesn't return persistent resources. Moriyoshi Andi Gutmans [EMAIL PROTECTED] wrote: This doesn't look right to me. We always use CONST_PERSISTENT in all of PHP. What is the problem? Andi At 10:24 AM 12/11/2002 +, Edin Kadribasic wrote: edink Wed Dec 11 05:24:03 2002 EDT Modified files: /php4/sapi/cli php_cli.c Log: Fix for #20539 (patch by Moriyoshi Koizumi). Index: php4/sapi/cli/php_cli.c diff -u php4/sapi/cli/php_cli.c:1.55 php4/sapi/cli/php_cli.c:1.56 --- php4/sapi/cli/php_cli.c:1.55Mon Dec 9 06:45:46 2002 +++ php4/sapi/cli/php_cli.c Wed Dec 11 05:24:02 2002 @@ -375,19 +375,19 @@ php_stream_to_zval(s_err, zerr); ic.value = *zin; - ic.flags = CONST_CS | CONST_PERSISTENT; + ic.flags = CONST_CS; ic.name = zend_strndup(STDIN, 6); ic.name_len = 6; zend_register_constant(ic TSRMLS_CC); oc.value = *zout; - oc.flags = CONST_CS | CONST_PERSISTENT; + oc.flags = CONST_CS; oc.name = zend_strndup(STDOUT, 7); oc.name_len = 7; zend_register_constant(oc TSRMLS_CC); ec.value = *zerr; - ec.flags = CONST_CS | CONST_PERSISTENT; + ec.flags = CONST_CS; ec.name = zend_strndup(STDERR, 7); ec.name_len = 7; zend_register_constant(ec TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CGI and CLI
At 03:54 PM 12/18/2002 -0500, Andrei Zmievski wrote: On Wed, 18 Dec 2002, Xavier Spriet wrote: Experimental or not, people use it and have developed a need for it. Many apps out there are based on experimental technology, that's not a reason to break them all... So I strongly suggest that whoever has the necessary knowledge on how to merge CGI and CLI back together come forward and do this. Let's get 4.3.0 out the door and move on to the new great things. I doubt this will happen fast enough. We should just release the way we released 4.2.x, which as far as I know was php for CGI and php-cli for CLI or am I a bit behind things? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4 /sapi/cli php_cli.c
At 12:56 AM 12/19/2002 +0100, Edin Kadribasic wrote: Sorry, I'm still unsure if my patch is the correct one, as I said in the first mail. As far as I've looked into it, the streams seem to be destructed and freed twice, once in deactivation and once in shutdown. If you think my patch is bogus, feel free to revert it unless I can give more reasonable explanation. I comitted tha patch and I'll revert it. Just to clarify one thing: constanst throuout PHP should be created as CONST_PERSISTENT? Yeah in almost all cases. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: #20993 [Ver]: Element valuechangeswithoutasking
At 12:49 AM 12/17/2002 +0900, Moriyoshi Koizumi wrote: Andi Gutmans [EMAIL PROTECTED] wrote: I don't understand what you're doing here. Are you actually separating on every assignment and doing a deep copy? What I'm trying to do in my patch can be divided into two phases. In the first phase, it checks whether the array contains any referenced elements (of course it does nothing and return SUCCESS if the passed zval is a non-array value). If such an element exists, then entering the second phase, separates the array zval and duplicates each referenced element while it doesn't make copies, but only increments the refcount for non-referenced elements. OK so that's a deep copy. As much as I understand the motivation I don't think this should be done. It'll slow down lots of things in PHP. I think this should be solved by documentation. Andi Moriyoshi Andi At 04:09 PM 12/15/2002 +0900, Moriyoshi Koizumi wrote: Oops, the patch was wrong as the runtime occationally segfaults in a case like: ?php $a = 0; $a = $a; /* is_ref=1, refcount=1 */ ? Attached is the revised patch. Please try it out. And the result of a tiny benchmark follows: [Before patching] 1: 0.263245 2: 0.142505 3: 0.328045 4: 0.137149 [After patching] 1: 0.273811 2: 0.141965 3: 0.699429 4: 0.137010 Moriyoshi My proposal, was based on 2 things: fix or document. I'm sure Zeev/Andi had a good reason not to always separate, and that probably is performance. IF this impacts overall performance very negatively, then maybe the better choice is to document it. I'll try the patch though. With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM
It won't be supported but you can use eval() if you really need to. Andi At 08:47 PM 12/16/2002 +0100, Bertrand Mansion wrote: [EMAIL PROTECTED] wrote : On Mon, 16 Dec 2002, Bertrand Mansion wrote: [EMAIL PROTECTED] wrote : Its neither, its a fact of the language, the following: $classname::method is illegal, you recieved a parse error to that effect. the best thing to do is:: I don't understand why it is illegal... It's just not supported by PHP. Will it be supported ? This would allow call_user_func(array($className, 'method'), $param1, $param2); This won't work because, in my case, I don't want to make an instance of $className but rather use $className methods as if they were plugged inside my main object. This doesn't make an instance at all. Sorry, I didn't choose the right way to explain. :) I meant that call_user_func needs an instanciated object which I can't provide as what I really want to do is use a method from a class, not from an instanciated object. (not sure it's clearer ?) And keep an access to $this from inside the object calling the external method because my parsing is actually recursive. For an example of my current code, you can have a look at Container.php in the Config package of PEAR (in CVS only). I am having hard time to figure out what would be the best way to implement this in PHP. Bertrand Mansion Mamasam -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] $this scope (was T_PAAMAYIM_NEKUDOTAYIM)
At 11:26 AM 12/17/2002 +0800, Alan Knowles wrote: It would be usefull to have a direction on this, - It's come up a number of times in bug reports. It has a number of uses (primarily breaking large classes up, into smaller components..), and a clearer way to write code than using a huge inheritance tree.. - It may not be correct OO code, by the book, but it is usefull in certian situations. It can be regarded as a feature, but if it is going to change at some point in the future, it's better to make that very clear now, rather than get a big backlash when we change it, and more people have worked out this little trick (and start to rely on it...) Technically I guess overload is the real way it should be done in ZE2. It should be documented that this behavior shouldn't be relied on. There's a good chance that this will change in ZE2. It has always been considered a bug and not a feature. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Constants inside strings, sometimes
At 05:16 PM 12/17/2002 +, Philip Olson wrote: Hello, I stumbled upon this feature today and am wondering why it exists: ?php error_reporting(E_ALL); ini_set('display_errors', 1); define('a', 'b'); $arr = array('a' = 'apple', 'b' = 'banana', 'c' = 'cranberry'); echo a $arr[a] \n; // apple echo b {$arr[a]} \n; // banana (???) echo c {$arr['a']} \n; // apple echo d $arr[b] \n; // banana echo e {$arr[b]} \n; // banana and E_NOTICE for // undefined constant echo f {a} \n; // {a} echo $arr[a];// banana (expected) echo $arr['a']; // apple ? In otherwords, constants are looked for inside strings under the following conditions: a) It's an array key b) {braces} are around the array This seems like inconsistent behavior as that's the only time they are looked for. This makes sense outside of strings but inside of them only if braces are used and with arrays? Please explain. It seems to me that if someone wants to use constants with array keys, don't put them in strings. Hi, The support for $arr[a] is a special support to make working with array offsets and strings easier. The {...} support should allow you to put any PHP expression in there. Basically echo $arr[a] and {$arr[a]} should behave exactly the same. There's a difference between $arr[a] and {$arr[b]} as 'a' is a defined constant and 'b' isn't so PHP is behaving correctly. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: #20993 [Ver]: Element value changeswithoutasking
I don't understand what you're doing here. Are you actually separating on every assignment and doing a deep copy? Andi At 04:09 PM 12/15/2002 +0900, Moriyoshi Koizumi wrote: Oops, the patch was wrong as the runtime occationally segfaults in a case like: ?php $a = 0; $a = $a; /* is_ref=1, refcount=1 */ ? Attached is the revised patch. Please try it out. And the result of a tiny benchmark follows: [Before patching] 1: 0.263245 2: 0.142505 3: 0.328045 4: 0.137149 [After patching] 1: 0.273811 2: 0.141965 3: 0.699429 4: 0.137010 Moriyoshi My proposal, was based on 2 things: fix or document. I'm sure Zeev/Andi had a good reason not to always separate, and that probably is performance. IF this impacts overall performance very negatively, then maybe the better choice is to document it. I'll try the patch though. With kind regards, Melvyn Sopacua ?php include(not_reflecting_employers_views.txt); ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] loading modules
Hi, You are really best off loading those dso's from your PHP INI. There is a dl() but it does have its issues (performance wise and in some cases stability wise). I think quite a lot of your memory will be shared between the processes so make sure you don't only look at the size of each process but also at how much is shared. Andi At 08:03 PM 12/11/2002 -0800, Gustavo A. Baratto wrote: Greetings, I'm not sure if this is the right place to ask, but here it goes... We have a multihosted environment for apache/php and we try to accept all requests to add new php extensions. The problem is that each apache process is using now 20MB of memory... We compile apache with shared object (SO) support for php (and everything else). The php modules are static, but we are planning to chang this to SO as well. Since just a few users will use some of the extensions, is it an overkill to load all php extesions with the web-server startup Aparentely, the SO support for php does not load the extension libraries in runtime (as needed), but it loads them in the startup. I know one could use the function dl(), but this is out of question because too much code have to be rewritten. What could be to ease up the memory usage? I'm not a good coder, but maybe I could help to write something like a dl() for loading a library just as needed... If someone could give me a feedback if there is another way to do what I need, or which part of the code I should look at (I just never even looked into php source :)) Thanks -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/bcmath bcmath.c php_bcmath.h
I think this is one of those exceptions where we should probably not go by our standard and call the function bcpowmod(). It looks a bit funny that all of the BC functions don't have underscores but only one does. It'll probably confuse people more than it helps. What do you guys think? Andi At 07:04 PM 12/10/2002 +, Sara Golemon wrote: pollita Tue Dec 10 14:04:29 2002 EDT Modified files: /php4/ext/bcmathbcmath.c php_bcmath.h Log: Added support for libbcmath's bc_raisemod function as bc_powmod() Index: php4/ext/bcmath/bcmath.c diff -u php4/ext/bcmath/bcmath.c:1.43 php4/ext/bcmath/bcmath.c:1.44 --- php4/ext/bcmath/bcmath.c:1.43 Thu Dec 5 16:51:45 2002 +++ php4/ext/bcmath/bcmath.cTue Dec 10 14:04:27 2002 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bcmath.c,v 1.43 2002/12/05 21:51:45 helly Exp $ */ +/* $Id: bcmath.c,v 1.44 2002/12/10 19:04:27 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -42,6 +42,7 @@ PHP_FE(bcsqrt, NULL) PHP_FE(bcscale, NULL) PHP_FE(bccomp, NULL) + PHP_FE(bc_powmod, NULL) {NULL, NULL, NULL} }; @@ -324,6 +325,38 @@ } bc_free_num(first); bc_free_num(second); + bc_free_num(result); + return; +} +/* }}} */ + +/* {{{ proto string bc_powmod(string x, string y, string mod [, int scale]) + Returns the value of an arbitrary precision number raised to the power of another reduced by a modulous */ +PHP_FUNCTION(bc_powmod) +{ + char *left, *right, *modulous; + int left_len, right_len, modulous_len; + bc_num first, second, mod, result; + int scale=bc_precision; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_C, sss|l, left, left_len, right, right_len, modulous, modulous_len, scale) == FAILURE) { + WRONG_PARAM_COUNT; + } + + bc_init_num(first TSRMLS_CC); + bc_init_num(second TSRMLS_CC); + bc_init_num(mod TSRMLS_CC); + bc_init_num(result TSRMLS_CC); + bc_str2num(first, left, scale TSRMLS_CC); + bc_str2num(second, right, scale TSRMLS_CC); + bc_str2num(mod, modulous, scale TSRMLS_CC); + bc_raisemod(first, second, mod, result, scale TSRMLS_CC); + Z_STRVAL_P(return_value) = bc_num2str(result); + Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value)); + Z_TYPE_P(return_value) = IS_STRING; + bc_free_num(first); + bc_free_num(second); + bc_free_num(mod); bc_free_num(result); return; } Index: php4/ext/bcmath/php_bcmath.h diff -u php4/ext/bcmath/php_bcmath.h:1.12 php4/ext/bcmath/php_bcmath.h:1.13 --- php4/ext/bcmath/php_bcmath.h:1.12 Fri Nov 22 04:25:28 2002 +++ php4/ext/bcmath/php_bcmath.hTue Dec 10 14:04:27 2002 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_bcmath.h,v 1.12 2002/11/22 09:25:28 sander Exp $ */ +/* $Id: php_bcmath.h,v 1.13 2002/12/10 19:04:27 pollita Exp $ */ #ifndef PHP_BCMATH_H #define PHP_BCMATH_H @@ -60,6 +60,7 @@ PHP_FUNCTION(bcsqrt); PHP_FUNCTION(bccomp); PHP_FUNCTION(bcscale); +PHP_FUNCTION(bc_powmod); #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4 /ext/bcmath bcmath.c php_bcmath.h
At 05:10 PM 12/10/2002 -0800, Sara Golemon wrote: I'm hearing two options here: 1) Name the new function bcpowmod() to keep it similiar to existing functions, we'll worry about renaming the functions in this module later... 2) Name the new function bc_powmod(), rename the existing functions now, and create aliases. Possibly introduce an ini option to control whether or not deprecated functions are enabled or not. #2 Sounds like The Right Way to do it, but also sounds like something which needs a strong consensus before implementing and should perhaps be put off till the next revision (4.4 or 5.0 -- whichever it winds up being) I'd go for #1 now as this should be done anyway. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] huge memory usage in concat op, ZE2
Tom, This should be fixed now. Please update your Zend CVS and let me know if it works for you. Andi At 08:06 PM 12/8/2002 -0800, Tom Fishwick wrote: I was reading an email from stdin. But regardless of bad coding style :-), the script is using _way_ more memory than it should. $s = ''; while(strlen($s) 266768) { $s.= 'd'; } this code uses 151Megs on my system. the same code uses about 2megs with php4.3. php4.3 seems to realloc/memcpy when the string gets big, and php5 just does malloc's and memcpy's (I don't see calls to free() though). I'm thinking the problem might be in zend_mm_realloc? Tom Andi Gutmans [EMAIL PROTECTED] wrote: At 12:30 AM 12/8/2002 -0800, Tom wrote: hey there, I'm using the cvs and ZE2, there seems to be some huge memory usage when concatenating a string to a length over 262080 bytes, when the string length gets to that size the malloc call inside zend_mm_add_memory_block starts grabing memory 262168 bytes at a time, every 8th concatenation (i'm concatenating 1 byte at a time). anyone else seen this? It makes sense that this is happening to you. Reaching the point where you add to a string of such size is very bad coding practice (unless you really have no choice). This is because if the memory manager can't realloc() (it very often can't) then it'll have to allocate a new block and use a memcpy() to copy over all of the string. The current code is less than optimal in this case and I can choose various strategies to improve on it but there will always be times where the malloc()/memcpy() will be necessary. So what are you doing? Is it something you have to do? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] 4.3 when?
Hi, I'd like to start working towards a beta of ZE2 but it seems that 4.3 is still lingering and I'd like to wait until after 4.3. What's happening with that? Shouldn't we get it out before Christmas? If any bad bugs creep in that'd mean we can use the relatively silent 2-3 weeks following Christmas to fix them. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] 4.3 when?
At 02:13 PM 12/9/2002 +0200, Jani Taskinen wrote: On Mon, 9 Dec 2002, Andi Gutmans wrote: Hi, I'd like to start working towards a beta of ZE2 but it seems that 4.3 is still lingering and I'd like to wait until after 4.3. What's happening with that? Shouldn't we get it out before Christmas? Try checking the Verified and Critical bugs for e.g. Scripting Engine Problem once and a while.. That's the answer to my question? I don't see any bug there which is a show stopper for 4.3. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] 4.3 when?
At 02:24 PM 12/9/2002 +0200, Jani Taskinen wrote: On Mon, 9 Dec 2002, Andi Gutmans wrote: At 02:13 PM 12/9/2002 +0200, Jani Taskinen wrote: On Mon, 9 Dec 2002, Andi Gutmans wrote: Hi, I'd like to start working towards a beta of ZE2 but it seems that 4.3 is still lingering and I'd like to wait until after 4.3. What's happening with that? Shouldn't we get it out before Christmas? Try checking the Verified and Critical bugs for e.g. Scripting Engine Problem once and a while.. That's the answer to my question? I don't see any bug there which is a show stopper for 4.3. Heh..so it's a good reason not to bother fixing/looking into them? I have looked at some of them in the past and some of them I just haven't had time to look at. You did succeed in getting me to look at them again but it still doesn't mean they are show stoppers. As far as the engine is concerned 4.3 can roll. No new bugs since 4.2.x have been introduced as far as I know. I thought bugs marked as Critical were supposed to be fixed before release? I didn't mark them as critical. I don't think any of those are show stoppers. I suggest before people mark stuff as critical they check with the author if it makes sense. Many releases in the past have gone out with what you call critical bugs. Or we can have a new category show stopper where the difference between critical and show stopper is communication and agreement with the author. Now that still leave my original question about 4.3. Why the hell aren't we rolling it? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] 4.3 when?
Any idea how many more bugs are waiting to be addressed? Andi At 12:36 PM 12/9/2002 +, Wez Furlong wrote: Because we are still finding and fixing bugs in the RCs. --Wez. On Mon, 9 Dec 2002, Andi Gutmans wrote: Now that still leave my original question about 4.3. Why the hell aren't we rolling it? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] php.exe - php-cgi.exe
At 05:34 PM 12/9/2002 +0100, Marcus Börger wrote: At 14:52 09.12.2002, Mike Robinson wrote: Wez Furlong writes: On Sun, 8 Dec 2002, Mike Robinson wrote: Sorry. There's just no way this should happen. But it has happened, and it's going stay this way. Now, if you don't have anything positive to contribute, please stop stirring up threads like this (again) without first understanding the issues behind them. It just wastes time, which is better spent developing, bug fixing, documenting - doing just about anything else is more productive. You are correct in your assumption that I have difficulty understanding the issues behind this change. After asking several times for an explanation, and after having gone over the archives to find some related discussion (and asking for pointers to that as well), I came to conclusion that this change is totally wrong. This change has nothing to do with fixing anything. It's breaking BC in a huge way, at the historical level, for the sake of a minor convenience for a very small group of users. Throwing lame excuses at it, like it's evolution, doesn't cut it with me. I'm still at the same place. This is just wrong. It has nothing to do with stirring anything up. Regards Mike Robinson What do you want then? For historical reasons you will allow us only to introduce total new functionality and bug fixes? No more improvements that will have any influence on some working systems out there? Then i'll answer stay where you are and do not do any version upgrade evolution is not an excuse here. We want to use PHP on the command line and many people will do also. And we make the command line usage as easy as possible. Even if that requires some mauals being updated and marking some bug reports as bogus. ducking Maybe phpsh would be a good idea for the name of the CLI? It wouldn't confuse ppl as much as php-cli /ducking I'm really not that sure it makes sense to rename the CGI from php to php-cgi after such a long time. It's not as if we're breaking BC for the sake of adding very much needed functionality. Anyway, I'm -0 for the change and +0 to find a more suitable name for the CLI :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] huge memory usage in concat op, ZE2
At 12:30 AM 12/8/2002 -0800, Tom wrote: hey there, I'm using the cvs and ZE2, there seems to be some huge memory usage when concatenating a string to a length over 262080 bytes, when the string length gets to that size the malloc call inside zend_mm_add_memory_block starts grabing memory 262168 bytes at a time, every 8th concatenation (i'm concatenating 1 byte at a time). anyone else seen this? It makes sense that this is happening to you. Reaching the point where you add to a string of such size is very bad coding practice (unless you really have no choice). This is because if the memory manager can't realloc() (it very often can't) then it'll have to allocate a new block and use a memcpy() to copy over all of the string. The current code is less than optimal in this case and I can choose various strategies to improve on it but there will always be times where the malloc()/memcpy() will be necessary. So what are you doing? Is it something you have to do? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] huge memory usage in concat op, ZE2
I'll try and see what I can do about this. Andi At 11:56 AM 12/8/2002 -0800, Tom Fishwick wrote: I was reading an email from stdin. But regardless of bad coding style :-), the script is using _way_ more memory than it should. $s = ''; while(strlen($s) 266768) { $s.= 'd'; } this code uses 151Megs on my system. the same code uses about 2megs with php4.3. php4.3 seems to realloc/memcpy when the string gets big, and php5 just does malloc's and memcpy's (I don't see calls to free() though). I'm thinking the problem might be in zend_mm_realloc? Tom Andi Gutmans [EMAIL PROTECTED] wrote: At 12:30 AM 12/8/2002 -0800, Tom wrote: hey there, I'm using the cvs and ZE2, there seems to be some huge memory usage when concatenating a string to a length over 262080 bytes, when the string length gets to that size the malloc call inside zend_mm_add_memory_block starts grabing memory 262168 bytes at a time, every 8th concatenation (i'm concatenating 1 byte at a time). anyone else seen this? It makes sense that this is happening to you. Reaching the point where you add to a string of such size is very bad coding practice (unless you really have no choice). This is because if the memory manager can't realloc() (it very often can't) then it'll have to allocate a new block and use a memcpy() to copy over all of the string. The current code is less than optimal in this case and I can choose various strategies to improve on it but there will always be times where the malloc()/memcpy() will be necessary. So what are you doing? Is it something you have to do? Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Default Return-Path with mail() and qmail
Are you sure you should be using malloc()/free() and not emalloc()/efree()? Also please use strlcpy() instead of strncpy(). (Weird I mentioned it twice in one day :) http://www.courtesan.com/todd/papers/strlcpy.html Andi At 04:54 PM 12/7/2002 +0100, Daniel Lorch wrote: --- php-4.2.3/ext/standard/mail.c Sat Aug 24 13:38:13 2002 +++ php-4.2.3-daniel/ext/standard/mail.cMon Dec 2 01:24:35 2002 @@ -21,6 +21,7 @@ #include stdlib.h #include ctype.h #include stdio.h +#include string.h #include php.h #include ext/standard/info.h #if !defined(PHP_WIN32) @@ -124,6 +125,84 @@ } /* }}} */ +char *get_header_value(char *line) +{ + while(*line *line != ':') + line++; + + if(!*line) + return NULL; + + line++; + + while(isspace(*line)) + line++; + + return strdup(line); +} + +char *get_header(char *header_name, char *headers) +{ + char *line, *value=NULL; + int header_name_len = strlen(header_name); + int len=0; + + do { + if(*headers == '\n' || *headers == '\0') { + if(len header_name_len) { + len = 0; + continue; + } + + if((line = (char *)malloc(len + 1)) == NULL) + return NULL; + + headers -= len; + + strncpy(line, headers, len); + line[len] = '\0'; + + headers += len; + + if(strncmp(line, header_name, header_name_len) == 0) { + value = get_header_value(line); + } + + free(line); + + len = 0; + } else { + ++len; + } + } while(*headers++ value == NULL); + + return value; +} + +char *extract_address(char *address) +{ + char *start, *stop, *tmp; + + if((start = stop = strchr(address, '@')) == NULL) + return NULL; + + while(start = address !isspace(*start) *start != '') + start--; + + start++; + + while(*stop !isspace(*stop) *stop != '') + stop++; + + if((tmp = (char *)malloc(stop - start + 1)) == NULL) + return NULL; + + strncpy(tmp, start, stop - start); + tmp[stop-start] = '\0'; + + return tmp; +} + /* {{{ php_mail */ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd) @@ -135,6 +214,8 @@ int ret; char *sendmail_path = INI_STR(sendmail_path); char *sendmail_cmd = NULL; + char *return_path; + char *address; if (!sendmail_path) { #ifdef PHP_WIN32 @@ -169,6 +250,25 @@ fprintf(sendmail, To: %s\n, to); fprintf(sendmail, Subject: %s\n, subject); if (headers != NULL) { + + /* Existing Return-Path should not be overwritten */ + if((return_path = get_header(Return-Path, headers)) != NULL) { + free(return_path); + } + else { + + if((return_path = get_header(From, headers)) != NULL) { + + if((address = extract_address(return_path)) != NULL) { + fprintf(sendmail, Return-Path: %s\n, address); + free(address); + } + + free(return_path); + + } + } + fprintf(sendmail, %s\n, headers); } fprintf(sendmail, \n%s\n, message); -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4(PHP_4_3) /sapi/cgi cgi_main.c
I still haven't understood from your answer if this is a problem which was in 4.2.x. Andi At 09:45 PM 12/1/2002 -0800, Shane Caraveo wrote: It's not a matter of php cgi just having a couple bugs, it was completely broken. If we don't put it in 4.3, pull the cgi module out entirely because it's useless. Yet another point of view also, since no one has seriously complained about it's brokeness, it can't realy effect many people either if it is in 4.3. Shane Andi Gutmans wrote: Are you sure we should have this stuff in the branch of 4.3? Are these bugs which didn't exist in 4.2.3? If they did exist I'm -1. If they didn't exist then that's life and the patch should stay in but people familiar with CGI should review it carefully. Andi At 02:21 AM 12/2/2002 +, Shane Caraveo wrote: shane Sun Dec 1 21:21:01 2002 EDT Modified files: (Branch: PHP_4_3) /php4/sapi/cgi cgi_main.c Log: MFH Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.190.2.6 php4/sapi/cgi/cgi_main.c:1.190.2.7 --- php4/sapi/cgi/cgi_main.c:1.190.2.6 Sun Dec 1 18:27:14 2002 +++ php4/sapi/cgi/cgi_main.cSun Dec 1 21:21:01 2002 @@ -369,6 +369,7 @@ } else { snprintf(buf,len-1,%s=, name); } + #if PHP_FASTCGI /* when php is started by mod_fastcgi, no regular environment is provided to PHP. It is always sent to PHP at the start @@ -597,8 +598,10 @@ struct stat st; char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME,0 TSRMLS_CC); char *env_path_info = sapi_cgibin_getenv(PATH_INFO,0 TSRMLS_CC); + char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL,0 TSRMLS_CC); if (env_path_info) env_path_info = estrdup(env_path_info); - if (sapi_cgibin_getenv(REDIRECT_URL,0 TSRMLS_CC) || + + if (env_redirect_url || (env_script_name env_path_info strcmp(env_path_info,env_script_name)==0)) { /* @@ -611,6 +614,8 @@ */ _sapi_cgibin_putenv(SCRIPT_FILENAME,env_path_translated TSRMLS_CC); _sapi_cgibin_putenv(PATH_INFO,NULL TSRMLS_CC); + if (env_redirect_url) + _sapi_cgibin_putenv(SCRIPT_NAME,env_redirect_url TSRMLS_CC); } if (stat( env_path_translated, st ) == -1 ) { @@ -620,7 +625,7 @@ while( (ptr = strrchr(pt,'/')) || (ptr = strrchr(pt,'\\')) ) { *ptr = 0; - if ( lstat(pt, st) == 0 S_ISREG(st.st_mode) ) { + if ( stat(pt, st) == 0 S_ISREG(st.st_mode) ) { /* * okay, we found the base script! * work out how many chars we had to strip off; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: [PHP-CVS] cvs: php4(PHP_4_3) /sapi/cgi cgi_main.c
At 06:59 PM 12/2/2002 +0100, Sascha Schumann wrote: On Mon, 2 Dec 2002, Andi Gutmans wrote: I still haven't understood from your answer if this is a problem which was in 4.2.x. This problem has existed for a long time. There is not much which can break, because it has not been working since well before 4.2.x. Is it worth putting it in after RC2 has been released already? I really don't know what the issue is exactly that's why I'm asking. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend fast cache
At 05:27 PM 12/1/2002 -0500, Sterling Hughes wrote: At 07:17 PM 11/30/2002 -0500, Sterling Hughes wrote: hrm. :) My only question is really about sequential accesses. for the purpose of example let's pretend its just for zvals... (pool is our pool array of zval structs) ALLOC_ZVAL() - Do we have a zval available? - yes! - return pool[0][0] ALLOC_ZVAL() ... - return pool[0][1] ALLOC_ZVAL() ... - return pool[0][2] FREE_ZVAL() - Clear memory @ pool[0][1] ALLOC_ZVAL() - Do we have a zval available? - return pool[0][3] or do we return pool[0][1] The problem I see with an array approach from an api perspective is simply when a bucket is free'd, in order to have efficient memory usage, we'd need a second level array scan for every ALLOC_ZVAL(). Perhaps a linked list would be a better choice for this, as we can just be smart about bucket access, and eliminate the need for a scan (could be possible I'm missing something?) I think I was misunderstood. Of course I would want a free list. Check out the objects_store code in ZE2. The idea is to have something similar. When we free allocated buckets we add them to a linked list. The linked list is inside the structure itself, i.e., when the bucket isn't used we can use its memory for the pointer to the next element. So allocation just takes the bucket out of the free list. So basically the bucket is a union between sizeof(zval) and sizeof(*) (or sizeof(int)). If it's still not clear I can explain it in a longer letter later on. Ok, i understand - you basically are doing the linked list approach, but using a two-tiered storage paradigm to avoid fragmentation? My only thought now is the dirty specifics: 1) Thread-safety: Will we have to mutex access to this cache? We shouldn't get corruption (I'd assume that on threaded environments we'd use a shared cache) if we have multiple accesses, and if we mutex, we might as well malloc(). This pool would be per-thread. 2) Growing buffer sizes. Say we have a _really_ intensive script that does make us grow our zval/object/hashtable cache substantially, however, it is run once every blue moon. Do we after execution is finished than realloc() that huge buffer back down to a normal size? Or perhaps we should just malloc() after a certain size is reached (ok, 16k of prealloc'd stuff, if we don't have a free slot, just do uncached mallocs). We'd recreate the cache ever request. It wouldn't cost very much. By the way, I think you did misunderstand me. In my way there wouldn't be a huge buffer. We'd have X buffers. Basically my idea was a two-dimensional array: arr[0] - buffer of size n arr[1] - buffer of size n arr[2] - buffer of size n arr[3] - buffer of size n . And we allocate buffers as needed. Block 1*n+4 would be in arr[1] slot 5 Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PHP-CVS] cvs: php4(PHP_4_3) /sapi/cgi cgi_main.c
Are you sure we should have this stuff in the branch of 4.3? Are these bugs which didn't exist in 4.2.3? If they did exist I'm -1. If they didn't exist then that's life and the patch should stay in but people familiar with CGI should review it carefully. Andi At 02:21 AM 12/2/2002 +, Shane Caraveo wrote: shane Sun Dec 1 21:21:01 2002 EDT Modified files: (Branch: PHP_4_3) /php4/sapi/cgi cgi_main.c Log: MFH Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.190.2.6 php4/sapi/cgi/cgi_main.c:1.190.2.7 --- php4/sapi/cgi/cgi_main.c:1.190.2.6 Sun Dec 1 18:27:14 2002 +++ php4/sapi/cgi/cgi_main.cSun Dec 1 21:21:01 2002 @@ -369,6 +369,7 @@ } else { snprintf(buf,len-1,%s=, name); } + #if PHP_FASTCGI /* when php is started by mod_fastcgi, no regular environment is provided to PHP. It is always sent to PHP at the start @@ -597,8 +598,10 @@ struct stat st; char *env_script_name = sapi_cgibin_getenv(SCRIPT_NAME,0 TSRMLS_CC); char *env_path_info = sapi_cgibin_getenv(PATH_INFO,0 TSRMLS_CC); + char *env_redirect_url = sapi_cgibin_getenv(REDIRECT_URL,0 TSRMLS_CC); if (env_path_info) env_path_info = estrdup(env_path_info); - if (sapi_cgibin_getenv(REDIRECT_URL,0 TSRMLS_CC) || + + if (env_redirect_url || (env_script_name env_path_info strcmp(env_path_info,env_script_name)==0)) { /* @@ -611,6 +614,8 @@ */ _sapi_cgibin_putenv(SCRIPT_FILENAME,env_path_translated TSRMLS_CC); _sapi_cgibin_putenv(PATH_INFO,NULL TSRMLS_CC); + if (env_redirect_url) + _sapi_cgibin_putenv(SCRIPT_NAME,env_redirect_url TSRMLS_CC); } if (stat( env_path_translated, st ) == -1 ) { @@ -620,7 +625,7 @@ while( (ptr = strrchr(pt,'/')) || (ptr = strrchr(pt,'\\')) ) { *ptr = 0; - if ( lstat(pt, st) == 0 S_ISREG(st.st_mode) ) { + if ( stat(pt, st) == 0 S_ISREG(st.st_mode) ) { /* * okay, we found the base script! * work out how many chars we had to strip off; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend fast cache
At 02:59 PM 11/30/2002 -0500, Sterling Hughes wrote: Hey, I was checking the CVS logs, and I read :: revision 1.13 date: 2001/11/26 17:27:59; author: andi; state: Exp; lines: +1 -1 - Turn off fast cache until we make sure it performs well. - The best solution is probably to limit its size. I was just wondering what was wrong, and what it would take to get this thing up and running... Thies and I were looking at a little hack, similiar in nature to this, with preallocating a pool of zval's, and it yielded a 5% performance increase (all hacking credit goes to thies btw :). First of all, let me just say that I wouldn't be too excited about 5% performance difference either way. I already told Thies that from my experience 5% is within the error margin and can change according to compile flags, platform and so on. The reason why the fast cache didn't work well was because it created quite a bit of memory fragmentation which killed MT servers and also made PHP take up too much memory. If we preallocated some basic, often used types, i think we'd get a nice performance increase, perhaps even if we initialized in sapi modes a few structures in MINIT, we could reuse those instead of creating and destroying which is currently quite expensive? That said, I do think that if we can get very fast code to pre-allocate zval's it would be a good idea (hopefully we could get more than 5% increase). I already have an idea for how I would want such an API to look like and I was planning to write it. It would also be useful for Zend objects which are preallocated today but if a realloc() were to be reached it would take quite some time (although one or two realloc()'s wouldn't be terrible). My idea is a two dimensional array. We'd allocate 2^n of memory blocks and assign it to array[0]. Once these are full we'd allocate another 2^n memory blocks and realloc() array to size of 2 and make array[1] point to it. The index to a block would be X and to find the right position it'd be array[X/2^n][X%2^n] of course as the length of each array is a power of two we wouldn't actually need to use division and modulo so it'd be fast. As we don't have templates in C we might be able to put all of this inline in a header file and with macros create such a fast allocating pool for some of the most used types specifically I think it'd be useful for zval's, objects and possible hash tables. I wouldn't overdo the amount of types I'd add to this pool because unless they are allocated and freed extremely often we wouldn't notice a speed difference. But remember what I said about 5% :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend fast cache
At 07:17 PM 11/30/2002 -0500, Sterling Hughes wrote: hrm. :) My only question is really about sequential accesses. for the purpose of example let's pretend its just for zvals... (pool is our pool array of zval structs) ALLOC_ZVAL() - Do we have a zval available? - yes! - return pool[0][0] ALLOC_ZVAL() ... - return pool[0][1] ALLOC_ZVAL() ... - return pool[0][2] FREE_ZVAL() - Clear memory @ pool[0][1] ALLOC_ZVAL() - Do we have a zval available? - return pool[0][3] or do we return pool[0][1] The problem I see with an array approach from an api perspective is simply when a bucket is free'd, in order to have efficient memory usage, we'd need a second level array scan for every ALLOC_ZVAL(). Perhaps a linked list would be a better choice for this, as we can just be smart about bucket access, and eliminate the need for a scan (could be possible I'm missing something?) I think I was misunderstood. Of course I would want a free list. Check out the objects_store code in ZE2. The idea is to have something similar. When we free allocated buckets we add them to a linked list. The linked list is inside the structure itself, i.e., when the bucket isn't used we can use its memory for the pointer to the next element. So allocation just takes the bucket out of the free list. So basically the bucket is a union between sizeof(zval) and sizeof(*) (or sizeof(int)). If it's still not clear I can explain it in a longer letter later on. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] ZE2 and standard class initialization
Applied. Andi At 05:31 PM 11/28/2002 +0100, Marcus Börger wrote: In ZE2 zend.c there is a structure member not initialized for. See patch below. marcus Index: Zend/zend.c === RCS file: /repository/ZendEngine2/zend.c,v retrieving revision 1.191 diff -u -r1.191 zend.c --- Zend/zend.c 24 Nov 2002 20:15:56 - 1.191 +++ Zend/zend.c 28 Nov 2002 16:24:02 - @@ -289,6 +289,8 @@ zend_standard_class_def-handle_property_get = NULL; zend_standard_class_def-handle_property_set = NULL; zend_standard_class_def-refcount = 1; + zend_standard_class_def-constants_updated = 0; zend_hash_add(GLOBAL_CLASS_TABLE, stdclass, sizeof(stdclass), zend_standard_class_def, sizeof(zend_class_entry *), NULL); } -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] ZE2 question
At 04:30 PM 11/28/2002 +, James Cox wrote: it means double colon in hebrew... i think Zeev and Andi must not have known what to call it in english when they put it in... but hey, it was the first i18n'ized error message :) We are very attached to this token because it was put in when we were coding very late one night a few years ago :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] ZE2 + public/protected/private/final
At 06:25 PM 11/28/2002 +0100, Marcus Börger wrote: With current ZE2 it is possible to instanciate an abstract class. That is a class that has at least one abstract method. When we add a flag field to class_entry struct we can handle this. We simply need to set an abstract flag for the class entry when any abstract method is added or inherited. I updated the full patch to do it that way: http://marcus-boerger.de/php/ext/ze2/ze2-f3p-21128.diff.txt I thought about this but am not quite sure how I feel about this. I know that theoretically in C++ and Java you can't instantiate such classes but I'm not sure it'd be too bad in PHP. If I were to implement this I'd probably use a counter to *remember* how many abstract methods a class has. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: Hi! I'm new to this list, I want to know if there is any function which could return the actual call stack, or is it planned to be added? It could be very useful (for example in my case, now :-). debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] my own superglobals?
Hi, No, this mechanism is only meant for the special variables (see archives of php-dev). In any case, I suggest you do use $GLOBALS[] and not the 'global' keyword because it works better and the recommended way. Andi At 01:06 PM 11/27/2002 +0200, Alexander Radivanovich wrote: Hi Gurus Is there any way to make my own variables supeglobal like $_GET, $_POST, ... ? I don't like $GLOBALS and I don't want to write the 'global' keyword each time I use my global variable in functions, I want to have a method to make it superglobal by default. 'Superglobal' means that it is available in all scopes throughout a script. I suggest following syntax: ?php // will declare superglobal variables global $mySuperglobalVariable = Hello; // make it superglobal global $_FORM = array_merge($_GET, $_POST); // yet another superglobal function test() { echo($mySuperglobalVariable); print_r($_FORM); // don't need global $mySuperglobalVariable // don't need $GLOBALS['mySuperglobalVariable '] } ? I hope it isn't a stupid idea, thaks -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] call_stack
I'd probably go for class::function($arg1, $arg2). Also take into consideration that the args aren't always available. Andi At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote: Is there a concensus on how arguments should be printed out? I'm shooting right now for a 'cluck' style backtrave class::function() called at file:line Perhaps class::function() called at file:line Arguments: print_r(args) ?? Andi Gutmans wrote: That'd be cool. At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote: I'll do it, if you want. Andi Gutmans wrote: At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Andi Gutmans wrote: At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote: On Wed, 27 Nov 2002, Miham KEREKES wrote: debug_backtrace() will be available in PHP 4.3.0 and higher. if someone has time to implement debug_print_backtrace() that would be cool. Using the raw debug_backtrace() is a bitch. If you're trying to volunteer me it's not going to work :P Damn! Maybe someone else? :) Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php