[PHP-DEV] PHP 4 Bug Summary Report
PHP 4 Bug Database summary - http://bugs.php.net Num Status Summary (632 total including feature requests) ===[*Directory/Filesystem functions] 40661 Open cwd is reset when shutdown handler runs ===[*Programming Data Structures]= 40496 Assigned Test bug35239.phpt still fails ===[Apache2 related]== 38670 Open Whole 4.4.x branch has problem with open_basedir option nested from Apache2 38915 Open mod_php: system() (and similar) don't cleanup opened handles of Apache ===[Arrays related]=== 17307 Open sorting using usort() does not produce correct result anymore 31114 Assigned foreach modify array (works with PHP 5.1) 37451 Open array_multisort fails to trigger by val copy of data (works in PHP 5.1) 39764 Suspended array_key_exists inconsistent behavior ===[CGI related]== 38476 Open PATH_INFO, ORIG_PATH_INFO, and PHP_SELF not set in Lighttpd1.4.11/PHP4.4.3 ===[Class/Object related]= 39254 Open Refcount error with static variables and object references (PHP4 only) 39681 Open this assignment outside class breaks static function call (PHP4 only) ===[COM related]== 37899 Assigned [PATCH] php_char_to _OLECHAR copies junk bytes ===[Documentation problem] 29045 Suspended gzopen for URL 36663 Open unexpected difference between zlib.output_compression and ob_gzhandler 37009 Open I got wrong letter Å and å ! 37901 Verified Unable to find the wrapper file 38965 Open mssql_connect doesn't use TCP 1433 for external SQL Server 39874 Open gztell returns incorrect file pointer number 39894 Open IniFilePath and PHPRC 40450 Open fastio.com hasn't been available for some time ===[EXIF related]= 39617 Assigned Erroneously uses the GPS version tag to determine byte order of GPS fields ===[FDF related]== 34811 Assigned fdf_get_value max size ===[Feature/Change Request]=== 3066 Open Parameter for dns functions to select different DNS 3799 Suspended default_charset brings small incompatibility 3830 Open Function to timeout/break off a function 5007 Analyzed enable no-resolve mode for here docs 5169 Open Missing recursive behavior 5311 Analyzed implement checkdnsrr() and getmxrr() on windows 5575 Open open_basedir to ~ 5601 Analyzed @function() should not turn of error reporting for critical errors 5748 Assigned use 'App Paths' registry key to specify path for supporting dlls 5804 Open parser error if any spaces follow indentifier in with here doc syntax 5883 Assigned --enable-trans-sid modification request 5954 Open Informix can't reliably figure if a text result column is NULL 5975 Open version of strip_tags() that specifies tags to strip (instead of tags to keep) 6118 Open Can not supress runtime warnings on foreach 6268 Open ternary op return only by value 6399 Open checkdate should be able to validate a time as well as a date (timestamp) 6427 Open func_get_arg() does not support references 6503 Open no support for multiple resultset query? 6512 Analyzed sort() Does not sort stings as expected 6574 Open SMTP functions via IMAP c-client library 6680 Open regexps (ereg*) ignores locale settings 6771 Assigned Import LIB files needed in Win32 distribution 6911 Open Problem with array_merge(_recursive) 6927 Suspended 6932 Open Filesize / File_exists and include_path 6993 Open uninstalling is a pain in the ass 7006 Open preg_replace ( string pattern, array replacement, string subject ); 7028 Analyzed xml=shared and wddx do not work together 7132 Assigned fsockopen doesn't report dns lookup failure 7398 Open Stored procedure error return values not passed through 7507 Open Better ODBC error reporting/fetching 7541 Open please consider also support HPUX shl_* 7553 Open RFC: Uplevel Block structure 7559 Open zend_hash_get_current_key_ex returning persistent strings 7578 Open next() and current() do not return referenceing arrays 7808 Open variable value triggerd by function 7923 Analyzed htmlentities doesn't work for ISO 8859-2 7930 Open List() constructor reference assignment 8100 Assigned extract(), extra feature 8108 Analyzed implement trans-sid as output handler 8295 Open absolute path in extension= directive in php.ini not recognized 8395 Open
[PHP-DEV] PHP 5 Bug Summary Report
PHP 5 Bug Database summary - http://bugs.php.net Num Status Summary (690 total including feature requests) ===[*Compile Issues]== 39372 Suspended Incompatibility in the PHP API. ===[*Configuration Issues] 37919 Open PHP doesn't read the configurations propertly 40688 Feedback php configure error ===[*Directory/Filesystem functions] 39351 Open require and include fails to open file in current directory ===[*General Issues]== 40700 Assigned win32 5.2.1 MSI not installing correctly 40716 Assigned Installationproblem Win/Apache224 ===[Apache2 related]== 32220 Assigned [PATCH] thread_resources for thread not getting freed when apache kills thread 38141 Suspended $_SERVER['SCRIPT_NAME'] set incorrectly with mod_rewrite 39330 Assigned apache2handler does not call shutdown actions before apache child die 39484 Open intermittent include failure under symlinked virtual hosts ===[Arrays related]=== 35163 Assigned Array elements can lose references. 40334 Open natsort() does not work for some numbers... 40509 Assigned key() function changed behaviour if global array is used within function 40705 Open Iterating within function moves original array pointer ===[Bzip2 Related] 29521 Verified compress.bzip2 wrapper 40437 Assigned decompress.bzip2 is broken ===[Calendar related]= 40213 Open easter_date() returns wrong timestamp if ... ===[CGI related]== 28227 Assigned PHP CGI depends upon non-standard SCRIPT_FILENAME 31892 Verified PHP_SELF incorrect without cgi.fix_pathinfo, but turning on screws up PATH_INFO 40419 Open Trailing Slash in CGI request don't work 40556 Feedback Browser abort causes server hang with FastCGI ===[Class/Object related]= 33314 Open Child class variable change not propogated during function call 36694 Assigned unserialize method is not called on an object when session is restored 40248 Open Undefined members with combined operators produce no warning ===[COM related]== 31327 Assigned chinese char and word problem 32099 Assigned After opening ADO connection and closing it repeatedly, Apache stops service 34253 Assigned COM binary object/array issue (question marks?) 35872 Assigned CLI errors upon exit if class is left on IE 35875 Assigned IE event failure upon scheduling script 36360 Assigned PHP crashes when accessing an object that was just create by parent object 36959 Open ReadRecords Method (Crystal Reports XI) Hangs 37562 Open Unable to lookup ParameterFieldDefinitions 37965 Assigned Multi-dimensional array between PHP and COM 38719 Assigned COM Error during accessing function VirtualMachines 40424 Open Fatal error when setting the value of COM object's property array 40478 Open skype dll problem Skype4COM.dll 40480 Feedback COM: Cannot pass parameter by reference error since 5.2.1 40581 Open Pass Struct type to COM object from PHP 40664 Open String conversion functions wrong for multibyte chars ===[Compile Failure]== 37462 Open install fails for sapi/cgi/php 37610 Assigned win32build has incorrect expat, PHP non-buildable 38762 Assigned build dir != src dir results in Zend/zend_language_parser.c: No such file 40474 Open Segmentation fault during install-pear-installer 40663 Assigned ming doesn't compile ===[Compile Warning]== 38515 Suspended Warnings during compile 38702 Assigned Getting odbc warnings during compilations 40683 Feedback zend_operators.h generates discard qualifier compiler warning ===[Date/time related] 37358 Assigned date_sunrise() date_sunset() handle main zone offset but not count summer time 39139 Assigned Last month bug 39965 Assigned Latitude and longitude are backwards in date-sun-info 40037 Assigned Incorrect output from strtotime, when timestr is used with a relative term this 40100 Assigned strtotime() first occurance of weekday returns wrong date 40290 Assigned strtotime() returns unexpected result with particular timezone offset 40340 Assigned Creating a DateTime object using a string that is invalid due to DST transition 40691 Open Incorrect results of DateTime equality check 40717 Assigned date
[PHP-DEV] PHP 6 Bug Summary Report
PHP 6 Bug Database summary - http://bugs.php.net Num Status Summary (41 total including feature requests) ===[*General Issues]== 26771 Suspended register_tick_funtions crash under threaded webservers 27372 Verified parse error loading browscap.ini at apache startup (new parser required) ===[*Programming Data Structures]= 39216 Assigned call_user_func and friends don't accept array($this, func) callback anymore ===[Arrays related]=== 35277 Suspended incorrect recursion detection ===[Class/Object related]= 33595 Assigned recursive references leak memory ===[Compile Failure]== 34089 Open Configure fails build test for libxml2 ===[Feature/Change Request]=== 20377 Open php_admin_value affects _only_ .htaccess 27618 Open curl_multi_info_read does not appear to work 29479 Suspended changing current process name 34211 Open PDO_OCI: Allow for data type TIMESTAMP(0) WITH LOCAL TIME ZONE 34252 Open Base functions extension and refactoring 34527 Open trim functions extension 34775 Open parse_url() provide better error description on failure 34882 Open Unable to access *original* posted variable name with dot in 35309 Open Database connection pooling 37081 Open Make the include-errors mention faulty permissions 37380 Open DOMDocument-createAttribute[NS] can't set value 37546 Open DOMDocumentFragment-appendXML namespace support 37796 Open t_is_not_identical for ? 37814 Open Php shoul have class friends 38622 Open Proposed new security scheme for shared hosting (safe mode substitute) 38946 Open pecl/docblock should be merged into ext/tokenizer 39946 Open Native Singleton Implementation 40013 Open php_uname() doesnt return nodename 40014 Open try, catch -- Let's Empower It, Please!!! 40499 Open filter sapi does not register any highlightning filter 40713 Open set_magic_quotes_runtime(0) causes Fatal Error ===[Filesystem function related]== 27792 Assigned Functions fail on large files (filesize,is_file,is_dir) ===[GD related]=== 34670 Assigned imageTTFText for Indian scripts (Devanagari) ===[OpenSSL related]== 25614 Suspended openssl_pkey_get_public() fails when given a private key ===[Other web server]= 26495 Suspended Using WebSite Pro 2.5 with ISAPI, cookies are not working ===[PDO related]== 35368 Suspended PDO query does not work properly with serialize 39171 Assigned pdo_mysql configure script sets empty default socket ===[Program Execution] 39992 Open proc_terminate() leaves children of child running ===[Scripting Engine problem]= 29687 Open By-reference passed value inside foreach() is no longer working 33487 Assigned Memory allocated for objects created in object methods is not released ===[Session related]== 32330 Open session_destroy, Failed to initialize storage module, custom session handler ===[SimpleXML related] 37076 Assigned SimpleXML ignores .= ===[Unknown/Other Function]=== 39710 Open getprotobyname is not thread-safe ===[XSLT related]= 38218 Assigned php:functionString tries to access objects with their names in lowercase ===[Zlib Related]= 30153 Suspended FATAL erealloc() error when using gzinflate() Assigned bugs: (reminders sent) pollita 39216: call_user_func and friends don't accept array($this, func) callback anymore dmitry 33595: recursive references leak memory dmitry 33487: Memory allocated for objects created in object methods is not released wez 27792: Functions fail on large files (filesize,is_file,is_dir) wez 39171: pdo_mysql configure script sets empty default socket pajoye 34670: imageTTFText for Indian scripts (Devanagari) helly 37076: SimpleXML ignores .= tony200138218: php:functionString tries to access objects with their names in lowercase -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: #39163 [Com]: Invalid API call from php5isapi.dll causing IIS7 Application Pool failure.
hhh ruSS at GEobYTeS dot com php-bugs@lists.php.net wrote in message news:[EMAIL PROTECTED] ID: 39163 Comment by: ruSS at GEobYTeS dot com Reported By: tony dot stone at gmail dot com Status: Open Bug Type: Win32API related Operating System: Windows Vista RC 1 Build 5600 PHP Version: 5.1.6 New Comment: I am runnning Vista Buisness (Build 6000) on an Intel (Core 2 Duo) 6400 - same issue as first post. - System - Provider [ Name] Microsoft-Windows-IIS-W3SVC-WP [ Guid] {670080D9-742A-4187-8D16-41143D1290BD} [ EventSourceName] W3SVC-WP - EventID 2295 [ Qualifiers] 49152 Version 0 Level 2 Task 0 Opcode 0 Keywords 0x80 - TimeCreated [ SystemTime] 2007-03-05T09:34:05.000Z EventRecordID 562 Correlation - Execution [ ProcessID] 0 [ ThreadID] 0 Channel Application Security - EventData ModuleDll C:\inetpub\PHP\php-5.2.1-Win32\php5isapi.dll 7F00 Previous Comments: [2007-02-09 13:02:14] Dirk at KISSsoft dot nl It's a IIS 7/PHP bug. When i enable support for 32-bit (on AMD-64) in the default application pool it happens. [2007-02-06 14:01:27] andreasblixt at msn dot com This issue is also occurring for me on an AMD64 computer with IIS 7 running on Windows Vista x64 RTM using php-5.2.0-Win32. From what I can gather, the issue seems to be related to the fact that I'm running a 64-bit version of Windows Vista/IIS 7. [2007-01-15 12:21:35] miha_avzlahar at t-2 dot net I guess I have same problem with php5isapi.dll. Or am I? I am running Windows Vista Ultimate. Trying to set up MySQL 5.0.27 and PHP 5.2.0, but I always get this bull... in browser : Server Error in Application Default Web Site HTTP Error 500.0 - Internal Server Error Description: Calling LoadLibraryEx on ISAPI filter C:\php\php5isapi.dll failed Error Code: 0x800700c1 Notification: Unknown Module: IIS Web Core Requested URL: http://localhost:80/wp-admin/install.php Physical Path: E:\FTProot\www\mihavista\wp-admin\install.php Logon User: Not yet determined Logon Method: Not yet determined Handler: StaticFile __ And this in event viewer : ___ ISAPI Filter 'C:\php\php5isapi.dll' could not be loaded due to a configuration problem. The current configuration only supports loading images built for a AMD64 processor architecture. The data field contains the error number. To learn more about this issue, including how to troubleshooting this kind of processor architecture mismatch error, see http://go.microsoft.com/fwlink/?LinkId=29349. WTF ??? Any suggestions ? [2006-11-18 05:56:51] jussi dot palo at gmail dot com Having the same issue on 5.2.0 on Vista RTM. Have tried with php5isapi.dll as well as php-cgi.exe, both give me the same error as described in the bug report. This error occurs every time I try to access .php pages. [2006-10-22 14:55:18] tony dot stone at gmail dot com Is there anything else I can do to assist with this? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/39163 -- Edit this bug report at http://bugs.php.net/?id=39163edit=1 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: #40494 [Bgs]: Memory problem with ZipArchive::addFile()
foster dot graeme at gmail dot com php-bugs@lists.php.net wrote in message news:[EMAIL PROTECTED] ID: 40494 User updated by: foster dot graeme at gmail dot com Reported By: foster dot graeme at gmail dot com Status: Bogus Bug Type: Zip Related Operating System: Linux PHP Version: 5.2.1 Assigned To: pajoye New Comment: Would it be possible to add a brief description of this situation to the documentation, for example the following could be added to the description of ZipArchive::addFile Description bool ZipArchive::addFile ( string filename [, string localname] ) Adds a link to the ZIP archive from a given path. When the archive is closed the link is checked to ensure that the file still exists and will then be compressed and added to the archive. If a lot of files are being added then the number of file handles permitted by the OS may be exceeded, if that occurs then the status will be set to ZIPARCHIVE::ER_OPEN. This can be avoided by closing the archive before the limit is reached and then reopening the archive. for example: if ($zip-numfile % $limit == 0) { $zip-close(); $zip-open($filename,ZIPARCHIVE::CREATE); } Previous Comments: [2007-02-15 14:35:34] [EMAIL PROTECTED] I still think that it would be nice if there was some way for the system to manage this. It is in the TODO list. As I said three times already in this discussion. The solution is to add different modes: - commit at the end when the archive is close - immediate addition (will be much slower) And again, it is in my TODOs already. I cannot tell when they will be available (I do it on my free time). In the meantime a simple: if (($zip-numFiles % $yourlimit) == 0) {close; reopen;} will do it. the archive can be partially built prior to the ulimit being reached. This could be set as 250, with the ability to overload it. Maybe this would only be triggered if a flag was set when the archive was opened. This solution does not work.The limit is arbitrary. There is no way to get an exact value (and I doubt php is the only running process). [2007-02-15 14:02:51] foster dot graeme at gmail dot com Okay thanks for the explanation, I understand the problem a little better. I still think that it would be nice if there was some way for the system to manage this. I was thinking along the lines of a function to flush the files so that the archive can be partially built prior to the ulimit being reached. This could be set as 250, with the ability to overload it. Maybe this would only be triggered if a flag was set when the archive was opened. [2007-02-15 13:23:36] [EMAIL PROTECTED] See: http://pecl.php.net/bugs/bug.php?id=9443 it would be good if this wasn't necessary, in thatthe code could catch the problem and allocate extra file handles if that is the problem. This is not something I can control. The operating system defines it and there is no way for me to increase this value. I suggest you to close and reopen it every 1000 or so (or even 255 if you want to go on the safest way, ie old windows). Future releases will have a different mode, where the checks will done only when you close the archives. [2007-02-15 13:14:57] foster dot graeme at gmail dot com Maybe I need to explain this problem a little more. I am trying to archive a folder on the server, at the moment it contains 5609 folders and 11,221 files. The script loops through the files adding them to the archive using the addFile() method. After the first 1002 files I get a ZIPARCHIVE::ER_OPEN. If I close the archive and the open it again I still have that error. However, if I close the archive and open it before I get that error then I can archive all 11,221 files. Since closing the file and re-opening fixes the problem (so long as I do that before I get the error) Then may I suggest that closing an archive will clear the status. Obviously, it would be good if this wasn't necessary, in thatthe code could catch the problem and allocate extra file handles if that is the problem. [2007-02-15 11:41:24] [EMAIL PROTECTED] When adding files to an archive, (using successive ZipArchive::addFile() commands) the compression doesn't happen until the file is closed. Yes, we do it while finalizing the archive. This can result in an out of memory error, You will run out of file ID before running out of memory. It does not really use many memory, only the file names and file handlers. I suppose you are talking about the file handlers? It would certainly
Re: [PHP-DEV] DateTime object equality
It would be interesting to know what other internal classes falsely pass this non-identity comparison. Then two new documentation entities could be used to say that non-identity comparison is or is not possible with this class. In my installation, I have 95 built in classes (with no extensions added), or 106 with the extensions I use normally. I managed to get upto 198 built in classes (by adding ALL the extensions I could get working). I suppose the step after this would be to make the built in classes operate so that non-identity comparison operated based upon the USER's perception of what should happen. On 04/03/07, Hans Lellelid [EMAIL PROTECTED] wrote: Hi all, DateTime equality (not identity) appears to be broken. I've created a ticket for this issue (http://bugs.php.net/bug.php?id=40691), which keeps getting marked as bogus by Ilia. This may be a more appropriate issue to raise on list, as I seem to be having both a very hard time making my point about the inconsistency of the behavior and a very hard time being convinced that this is not a bug (at *least* a documentation problem, if nothing else) :) The basic problem is that a [non-identity] comparison (==) of *any* DateTime object with any other DateTime object will return TRUE. Now, I admit that I know little about the underlying layer, but as a developer the DateTime object has a very clear set of properties (namely date/time, maybe time zone) that I would expect would be compared by a == equality check. $d1 = new DateTime(2001-01-01); $d2 = new DateTime(2007-02-28); var_export($d1 == $d2); // Ouputs: TRUE This always-return-TRUE behavior is extremely counter-intuitive. It also appears to be very exceptional in the PHP core classes. Admittedly, I haven't looked through SPL, but the Exception object provides a perfect example for what I would expect (based on the text in the PHP manual about object comparison): $a = new Exception(foo); $b = new Exception(bar); $c = new Exception(foo); var_export($a == $b); // Outputs: FALSE var_export($a == $c); // Outputs: TRUE Obviously stdClass and user-defined classes exhibit this same behavior of testing the object properties -- just as I'd expect from the description in the manual. Is this DateTime comparison behavior actually intended to be different from everything else? If there's some reason that DateTime object properties cannot be compared to each other, wouldn't it be more appropriate for them to always return FALSE ? Thanks, Hans -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] RE : suggestion SplFileInfo
From: Pierre [mailto:[EMAIL PROTECTED] It is not about taste. A glob is not a URI-like data. It is a filter. I hope you understand my point now (for better glob support but no glob://), let see what the other developers think about that. I agree. PHP glob() needs to be rewritten to call a glob() hook in stream wrappers. And only the 'plain file' wrapper would then call the OS native glob(). Other stream wrappers like zip:, phar:, or phk: would provide their own implementations (provided they can use a reliable fnmatch()). I will take another way to understand why one can add URI wrappers in the core stream implementation without discussing it and even worst, without allowing any discussion about his choice. Agree again. François -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] CVS Account Request: doury
Publication of an experimental extension connecting PHP to Z/OS-IMS. This prototype includes execution of transactions using close copies filled through XML description. Link to previous discussion in PECL news : http://news.php.net/php.pecl.dev/4586 Link to Source Forge project : https://sourceforge.net/projects/php-ims-connect The actual release has been published in Source Forge, but I#039;d like to maintain in PECL CVS. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] php_mbstring.dll not found in latest snapshots
Hello, is there any problem with this dll? It is not found in /ext in latest snapshots. best regards -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Thread safe problem on module_registry (Zend API Feature/Change request)
Hello, I made a patch that mutex'ed module_registry and module_count. For the moment it doesn't solve the dl(). The patch for last CVS PHP_5_2 http://mykii.binarysec.com/PHP/module_registry_mutex/module_register_mutex.patch Small description : http://mykii.binarysec.com/PHP/module_registry_mutex/readme.txt Regards, Michael Vergoz - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: Michael Vergoz [EMAIL PROTECTED] Cc: internals@lists.php.net Sent: Thursday, March 01, 2007 11:06 PM Subject: Re: [PHP-DEV] Thread safe problem on module_registry (Zend API Feature/Change request) On Thu, March 1, 2007 7:29 am, Michael Vergoz wrote: I don't claim to understand this issue fully/deeply, but I'm definitely +1 on resurrecting 'dl' if this change fixes everything to everyone's satisfaction. Not that my vote actually counts, as I've never had the skills/time to actually contribute C code to PHP. I may be the only user on the planet with a shared host that lets me use 'dl' to pull in extensions, but there it is, and I kinda need it, as there are no other viable options to do what I need to do, other than changing to a new webhost I might not like... :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: DateTime object equality
Michael Wallner wrote: Hans Lellelid wrote: Is this DateTime comparison behavior actually intended to be different from everything else? If there's some reason that DateTime object properties cannot be compared to each other, wouldn't it be more appropriate for them to always return FALSE ? In my POV this is easily solvable with a custom comparison object handler. See attached patch. I also think that comparing to Datetime instances should give a reasonable result. Regards, -- Michael Index: ext/date/php_date.c === RCS file: /repository/php-src/ext/date/php_date.c,v retrieving revision 1.43.2.45.2.41 diff -u -p -d -r1.43.2.45.2.41 php_date.c --- ext/date/php_date.c 27 Feb 2007 03:04:39 - 1.43.2.45.2.41 +++ ext/date/php_date.c 5 Mar 2007 13:19:28 - @@ -297,6 +297,7 @@ static void date_object_free_storage_tim static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC); static zend_object_value date_object_clone_date(zval *this_ptr TSRMLS_DC); +static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC); static zend_object_value date_object_clone_timezone(zval *this_ptr TSRMLS_DC); /* This is need to ensure that session extension request shutdown occurs 1st, because it uses the date extension */ @@ -1459,6 +1460,7 @@ static void date_register_classes(TSRMLS date_ce_date = zend_register_internal_class_ex(ce_date, NULL, NULL TSRMLS_CC); memcpy(date_object_handlers_date, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); date_object_handlers_date.clone_obj = date_object_clone_date; + date_object_handlers_date.compare_objects = date_object_compare_date; #define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \ zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC); @@ -1530,6 +1532,27 @@ static zend_object_value date_object_clo return new_ov; } +static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC) +{ + if (Z_TYPE_P(d1) == IS_OBJECT Z_TYPE_P(d2) == IS_OBJECT + instanceof_function(Z_OBJCE_P(d1), date_ce_date TSRMLS_CC) + instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) { + php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC); + php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC); + + if (!o1-time-sse_uptodate) { + timelib_update_ts(o1-time, o1-time-tz_info); + } + if (!o2-time-sse_uptodate) { + timelib_update_ts(o1-time, o1-time-tz_info); + } + + return o1-time-sse == o2-time-sse ? 0 : o1-time-sse o2-time-sse ? -1 : 1; + } + + return 1; +} + static inline zend_object_value date_object_new_timezone_ex(zend_class_entry *class_type, php_timezone_obj **ptr TSRMLS_DC) { php_timezone_obj *intern; -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: DateTime object equality
Michael Wallner wrote: + if (!o2-time-sse_uptodate) { + timelib_update_ts(o1-time, o1-time-tz_info); + } Oh my, typo warning. -- Michael -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: DateTime object equality
Hans Lellelid wrote: Is this DateTime comparison behavior actually intended to be different from everything else? If there's some reason that DateTime object properties cannot be compared to each other, wouldn't it be more appropriate for them to always return FALSE ? In my POV this is easily solvable with a custom comparison object handler. See attached patch. I also think that comparing to Datetime instances should give a reasonable result. Regards, -- Michael -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] php_mbstring.dll not found in latest snapshots
Hi, An undesired change has sneaked into ext/mbstring/oniguruma. Marcus I think these snprintf changes should be reverted as this is an external library and PHP includes are not used in there meaning among other thing snprintf is not available on windows. Edin Holografix wrote: Hello, is there any problem with this dll? It is not found in /ext in latest snapshots. best regards -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: runtime JIT
Pierre, How's it going with this list you posted? Last I heard you had some issues with ext/session. Can you elaborate please? -Andrei On Feb 15, 2007, at 6:22 AM, Pierre wrote: Hi Dmitry! On 2/14/07, Dmitry Stogov [EMAIL PROTECTED] wrote: The patch is attached. To use runtime JIT you will need to change zend_register_auto_global() to zend_register_auto_global_ex() with 1 as the last argument. Compile-time JIT is still supported too. Note that the significant part of the patch is reverting of autoglobals CV patch, that is reimplemented using CG(auto_globals_cache). Any objections? The patch looks good and it implements the concept I described in my initial proposal. So no, no objection here. For the record, what needs to be done now is (after a short discussion with Dmitry): - implement the callback to decode the input - support multiple calls of http_input_encoding, GPC must be re-encoded (rearm JIT) a new function is required and a couple of changes in the hash creations (call dtor, etc.) - Add test cases - Implement unicode support in ext/filter I do not have the time to test and work on that until next week on Wednesday. If someone likes to work on one part or another, please raise the hand :) Thanks for your work! --Pierre -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] php_mbstring.dll not found in latest snapshots
Hello Edin, isn't there _snprintf along with a macro #define snprintf _snprintf? Not that it is exactly the same but it would work there. best regards marcus Monday, March 5, 2007, 5:14:38 PM, you wrote: Hi, An undesired change has sneaked into ext/mbstring/oniguruma. Marcus I think these snprintf changes should be reverted as this is an external library and PHP includes are not used in there meaning among other thing snprintf is not available on windows. Edin Holografix wrote: Hello, is there any problem with this dll? It is not found in /ext in latest snapshots. best regards Best regards, Marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] The way the engine works?
Ok, I am no C coder and I don't claim to be very smart about low level parts of PHP. But, IMO, this is bug. http://bugs.php.net/bug.php?id=36924 I have created a test script that shows the insanity of this bug: ?php $str = This is a medium length string; $start = memory_get_usage(); for($x=1;$x=100;$x++){ echo $str.: (3.5): .time().\n; } $first_growth = number_format(memory_get_usage() - $start); $start = memory_get_usage(); for($x=1;$x=100;$x++){ echo $str: (3.5): .time().\n; } $growth = number_format(memory_get_usage() - $start); echo first growth: $first_growth\nsecond growth: $growth\n; ? Now, you turn that into a script that is going to loop millions of times, building strings to build data and run for hours. The next thing you know, your cron job is using 450MB of memory and you try to figure out what YOU did wrong. Hours later you find this little jewel waiting for you and realize you did not do anything wrong. You just used the language. Everyone ignored my last email about memory waste and large arrays. I can only assume that you will ignore this one too. I am starting to see why Stefan became so bitter. I have always tried to squash the myth that putting variables inside strings in PHP was bad, but now, I think I will flip on that. I tested as far back as PHP 4.3.9 and as new as 5.2.1. -- Brian Moon - http://dealnews.com/ It's good to be cheap =) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Better implementation for ternary shortcut
Hello internals, attached is a much better implementation for the ternary shortcut. If noone sees a problem with it, I will be comitting this on thursday. best regards marcusIndex: Zend/zend_compile.c === RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.740 diff -u -p -d -r1.740 zend_compile.c --- Zend/zend_compile.c 16 Feb 2007 19:36:45 - 1.740 +++ Zend/zend_compile.c 5 Mar 2007 22:37:45 - @@ -4206,6 +4206,43 @@ void zend_do_end_silence(znode *strudel_ } +void zend_do_jmp_set(znode *value, znode *jmp_token, znode *colon_token TSRMLS_DC) +{ + int op_number = get_next_op_number(CG(active_op_array)); + zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + + opline-opcode = ZEND_JMP_SET; + opline-result.op_type = IS_TMP_VAR; + opline-result.u.var = get_temporary_variable(CG(active_op_array)); + opline-op1 = *value; + SET_UNUSED(opline-op2); + + *colon_token = opline-result; + + jmp_token-u.opline_num = op_number; + + INC_BPC(CG(active_op_array)); +} + + +void zend_do_jmp_set_else(znode *result, znode *false_value, znode *jmp_token, znode *colon_token TSRMLS_DC) +{ + zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + + opline-opcode = ZEND_QM_ASSIGN; + opline-extended_value = 0; + opline-result = *colon_token; + opline-op1 = *false_value; + SET_UNUSED(opline-op2); + + *result = opline-result; + + CG(active_op_array)-opcodes[jmp_token-u.opline_num].op2.u.opline_num = get_next_op_number(CG(active_op_array)); + + DEC_BPC(CG(active_op_array)); +} + + void zend_do_begin_qm_op(znode *cond, znode *qm_token TSRMLS_DC) { int jmpz_op_number = get_next_op_number(CG(active_op_array)); Index: Zend/zend_compile.h === RCS file: /repository/ZendEngine2/zend_compile.h,v retrieving revision 1.355 diff -u -p -d -r1.355 zend_compile.h --- Zend/zend_compile.h 16 Feb 2007 19:36:45 - 1.355 +++ Zend/zend_compile.h 5 Mar 2007 22:37:46 - @@ -506,6 +506,9 @@ void zend_do_exit(znode *result, znode * void zend_do_begin_silence(znode *strudel_token TSRMLS_DC); void zend_do_end_silence(znode *strudel_token TSRMLS_DC); +void zend_do_jmp_set(znode *value, znode *jmp_token, znode *colon_token TSRMLS_DC); +void zend_do_jmp_set_else(znode *result, znode *false_value, znode *jmp_token, znode *colon_token TSRMLS_DC); + void zend_do_begin_qm_op(znode *cond, znode *qm_token TSRMLS_DC); void zend_do_qm_true(znode *true_value, znode *qm_token, znode *colon_token TSRMLS_DC); void zend_do_qm_false(znode *result, znode *false_value, znode *qm_token, znode *colon_token TSRMLS_DC); Index: Zend/zend_execute_API.c === RCS file: /repository/ZendEngine2/zend_execute_API.c,v retrieving revision 1.397 diff -u -p -d -r1.397 zend_execute_API.c --- Zend/zend_execute_API.c 3 Mar 2007 13:46:19 - 1.397 +++ Zend/zend_execute_API.c 5 Mar 2007 22:37:46 - @@ -1376,6 +1376,7 @@ void execute_new_code(TSRMLS_D) case ZEND_JMPNZ: case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: + case ZEND_JMP_SET: opline-op2.u.jmp_addr = CG(active_op_array)-opcodes[opline-op2.u.opline_num]; break; } Index: Zend/zend_language_parser.y === RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.179 diff -u -p -d -r1.179 zend_language_parser.y --- Zend/zend_language_parser.y 4 Mar 2007 16:25:57 - 1.179 +++ Zend/zend_language_parser.y 5 Mar 2007 22:37:46 - @@ -611,9 +611,8 @@ expr_without_variable: | expr '?' { zend_do_begin_qm_op($1, $2 TSRMLS_CC); } expr ':' { zend_do_qm_true($4, $2, $5 TSRMLS_CC); } expr { zend_do_qm_false($$, $7, $2, $5 TSRMLS_CC); } - | expr '?' { zend_do_begin_qm_op($1, $2 TSRMLS_CC); } - ':' { zend_do_qm_true($1, $2, $4 TSRMLS_CC); } - expr { zend_do_qm_false($$, $6, $2, $4 TSRMLS_CC); } + | expr '?' ':' { zend_do_jmp_set($1, $2, $3 TSRMLS_CC); } + expr { zend_do_jmp_set_else($$, $5, $2, $3 TSRMLS_CC); } | internal_functions_in_yacc { $$ = $1; } | T_INT_CAST expr { zend_do_cast($$, $2, IS_LONG TSRMLS_CC); } | T_DOUBLE_CAST expr { zend_do_cast($$, $2, IS_DOUBLE TSRMLS_CC); } Index: Zend/zend_opcode.c === RCS file: /repository/ZendEngine2/zend_opcode.c,v retrieving revision 1.126 diff -u -p -d -r1.126 zend_opcode.c ---
Re: [PHP-DEV] The way the engine works?
On 03/06/2007 12:34 AM, Brian Moon wrote: Ok, I am no C coder and I don't claim to be very smart about low level parts of PHP. But, IMO, this is bug. http://bugs.php.net/bug.php?id=36924 I have created a test script that shows the insanity of this bug: ?php $str = This is a medium length string; $start = memory_get_usage(); for($x=1;$x=100;$x++){ echo $str.: (3.5): .time().\n; } $first_growth = number_format(memory_get_usage() - $start); $start = memory_get_usage(); for($x=1;$x=100;$x++){ echo $str: (3.5): .time().\n; } $growth = number_format(memory_get_usage() - $start); echo first growth: $first_growth\nsecond growth: $growth\n; ? Number of iterations | First growth | Second growth | Peak usage 100 480 bytes ~5Kb ~73Kb 100 000 556 bytes ~32Kb ~100Kb 1 000 000556 bytes ~32Kb ~100Kb Tested with PHP 5.2.1 and 5.2.2-dev on Linux (with --disable-debug). Now, you turn that into a script that is going to loop millions of times, building strings to build data and run for hours. The next thing you know, your cron job is using 450MB of memory and you try to figure out what YOU did wrong. Hours later you find this little jewel waiting for you and realize you did not do anything wrong. You just used the language. Yup, the language stole ~32Kb of your memory and used it to speedup the allocation of small chunks. Everyone ignored my last email about memory waste and large arrays. I can only assume that you will ignore this one too. I am starting to see why Stefan became so bitter. I have always tried to squash the myth that putting variables inside strings in PHP was bad, but now, I think I will flip on that. I tested as far back as PHP 4.3.9 and as new as 5.2.1. -- Wbr, Antony Dovgal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
Antony Dovgal wrote: Yup, the language stole ~32Kb of your memory and used it to speedup the allocation of small chunks. Ok, in my attempt to send a sane looking example, I cleaned up the problem. ?php $str = This is a medium length string; $start = memory_get_usage(); for($x=1;$x=100;$x++){ $var = $str. .$x.: (3.5): .time().\n; } $first_growth = number_format(memory_get_usage() - $start); $start = memory_get_usage(); for($x=1;$x=100;$x++){ $var = $str $x: (3.5): .time().\n; } $growth = number_format(memory_get_usage() - $start); echo first growth: $first_growth\nsecond growth: $growth\n; ? The introduction of $x into the string makes the difference. first growth: 892 second growth: 3,955,068 -- Brian Moon - http://dealnews.com/ It's good to be cheap =) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
The introduction of $x into the string makes the difference. first growth: 892 second growth: 3,955,068 Strange, I get: first growth: 820 second growth: 56 Which build did you test? -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
Brian Moon wrote: Antony Dovgal wrote: Yup, the language stole ~32Kb of your memory and used it to speedup the allocation of small chunks. Ok, in my attempt to send a sane looking example, I cleaned up the problem. ?php $str = This is a medium length string; $start = memory_get_usage(); for($x=1;$x=100;$x++){ $var = $str. .$x.: (3.5): .time().\n; } $first_growth = number_format(memory_get_usage() - $start); $start = memory_get_usage(); for($x=1;$x=100;$x++){ $var = $str $x: (3.5): .time().\n; } $growth = number_format(memory_get_usage() - $start); echo first growth: $first_growth\nsecond growth: $growth\n; ? The introduction of $x into the string makes the difference. first growth: 892 second growth: 3,955,068 I get: first growth: 704 second growth: 32,264 with current PHP_5_2 checkout. I don't have a 5.1.x handy with memory limits compiled in. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
I think what is happening is that the Engine caches small-sized memory blocks and does not really free them when they are deallocated, even when they are not referenced anymore. The cache size is limited, so I don't think you need to be concerned. If you still think it is a big problem for you, you could set USE_ZEND_ALLOC environment variable to 0 and have the engine user regular malloc/free. Note that this would probably harm your performance. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
Rasmus Lerdorf wrote: I get: first growth: 704 second growth: 32,264 with current PHP_5_2 checkout. I don't have a 5.1.x handy with memory limits compiled in. Starting to think this is more prevelant on Mac OS X. My huge numbers are coming from 5.2.0, on Mac OS X. On my Linux boxes I am getting smaller numbers, more like what you guys are reporting so I assume you are using Linux. Then there is this confusing result: $ php test.php first growth: 860 second growth: -12,145,628 That is on 5.2.0 on Linux. to get a -12MB, it had to be that big or bigger to start with at some point. Anyone know what that is about? Passing true to memory_get_usage only clouds things further as I get all 0 for memory growth on all platforms making me think that memory_get_usage() without the true param (=5.2) is useless. However, despite all those tests (which you can never trust to show real world perfectly) I changed the script I was writing to use NO vars in strings. It is a script that processes queued items. As long as there are items in the queue, it keeps running. The strings I was building were mostly SQL queries. It is now holding at 11MB and not growing. Before, I was having to kill it after an hour as it would grow to over 100MB of memory and growing. That was all determined by looking at ps. Also, what was taking hours, now only took 15 minutes while I was writing this email. All of this was on Linux. My fear is that Mac OS X is making an issue very obvious that is more subtle on Linux, but does exist. I will see if I can come up with a good example on Linux that makes this more prevelant. It may have to run for an hour, which I understand is not the primary target of PHP. I am a big proponent of that philosophy. But, there is a CLI and I am gonna use it. I would like it to be sane. =) -- Brian Moon - http://dealnews.com/ It's good to be cheap =) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
Brian Moon wrote: Rasmus Lerdorf wrote: I get: first growth: 704 second growth: 32,264 with current PHP_5_2 checkout. I don't have a 5.1.x handy with memory limits compiled in. Starting to think this is more prevelant on Mac OS X. My huge numbers are coming from 5.2.0, on Mac OS X. On my Linux boxes I am getting smaller numbers, more like what you guys are reporting so I assume you are using Linux. Nope, mine was from OSX: 3:45pm shiny:~ php uu first growth: 704 second growth: 32,264 3:45pm shiny:~ php -v PHP 5.2.2-dev (cli) (built: Feb 18 2007 00:11:29) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies 3:45pm shiny:~ uname -a Darwin shiny.lerdorf.com 8.8.0 Darwin Kernel Version 8.8.0: Fri Sep 8 17:18:57 PDT 2006; root:xnu-792.12.6.obj~1/RELEASE_PPC Power Macintosh powerpc -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
Starting to think this is more prevelant on Mac OS X. My huge numbers are coming from 5.2.0, on Mac OS X. On my Linux boxes I am getting smaller numbers, more like what you guys are reporting so I assume you are using Linux. I vaguely remember there was some problem with calculating exact memory usage sometime ago. Not sure it's 5.2.0 but it might be. I would first verify what happens in 5.2.1. Passing true to memory_get_usage only clouds things further as I get all 0 for memory growth on all platforms making me think that memory_get_usage() without the true param (=5.2) is useless. Why it's useless? 0 means your script didn't change real memory usage - but it wasn't supposed to - since PHP pre-allocated memory blocks anyway, so to change real memory usage you have to allocate something big and hold it. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] The way the engine works?
On 03/06/2007 02:33 AM, Brian Moon wrote: Rasmus Lerdorf wrote: I get: first growth: 704 second growth: 32,264 with current PHP_5_2 checkout. I don't have a 5.1.x handy with memory limits compiled in. Starting to think this is more prevelant on Mac OS X. My huge numbers are coming from 5.2.0, on Mac OS X. You should really upgrade to 5.2.1 first. On my Linux boxes I am getting smaller numbers, more like what you guys are reporting so I assume you are using Linux. -- Wbr, Antony Dovgal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] CVS Account Request: jryfibofbvc
gay twinks about [URL= http://www.palurl.com/?l271d9ln.com ]gay twinks[/URL] a href= http://www.palurl.com/?l271d9ln.net gay twinks/a information http://www.palurl.com/?l271d9ln.org gay twinks about x -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] php_mbstring.dll not found in latest snapshots
Hey Marcus, Yes, there is _snprintf, but macro isn't there. You'd have to define it in the files you modifed, Edin Marcus Boerger wrote: Hello Edin, isn't there _snprintf along with a macro #define snprintf _snprintf? Not that it is exactly the same but it would work there. best regards marcus Monday, March 5, 2007, 5:14:38 PM, you wrote: Hi, An undesired change has sneaked into ext/mbstring/oniguruma. Marcus I think these snprintf changes should be reverted as this is an external library and PHP includes are not used in there meaning among other thing snprintf is not available on windows. Edin Holografix wrote: Hello, is there any problem with this dll? It is not found in /ext in latest snapshots. best regards Best regards, Marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Confusing code in ext/curl
Ilia, I think you wrote this. Could you help me understand what you were trying to do in the open basedir check macro: #define PHP_CURL_CHECK_OPEN_BASEDIR(str, len, __ret) if (((PG(open_basedir) *PG(open_basedir)) || PG(safe_mode)) strncasecmp(str, file:, sizeof(file:) - 1) == 0) So this check is only applied to file: urls passed to curl when either safe_mode or open_basedir is set. Ok { php_url *tmp_url; if (!(tmp_url = php_url_parse_ex(str, len))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid URL '%s', str); \ php_curl_ret(__ret); } And this invalid URL check makes sense too. url_parse couldn't grok it. if (php_memnstr(str, tmp_url-path, strlen(tmp_url-path), str + len)) {\ php_error_docref(NULL TSRMLS_CC, E_WARNING, URL '%s' contains unencoded control characters., str); php_url_free(tmp_url); php_curl_ret(__ret); } This memnstr call makes no sense to me. str is going to be file:///some/path/some_file.txt so tmp_url-path is going to be /some/path memnstr returns the char * to the beginning of /some/path in file:///some/path/some_file.txt which would be str+7 which is obviously non-false which means the warning message about unencoded control chars is printed. Did you perhaps mean !php_memnstr there? But php_memnstr() is binary-safe, so you are relying on the url_parse function to have replaced the control chars in the middle of the path to make it not match? Or what exactly are you trying to catch with this check? -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] Native Singleton Implementation
Also posted in the bug report: Perhaps some nicer solutions to your got-cha's: - What happens when $members = new members() is called If the class is defined as a singleton, then PHP should create the instance as normal (this includes calling __construct() ) and store it in the hash table, or return the cached instance if it's already created. -- I say an exception being thrown and a suggestion to remove new You should still be able to use 'new', with the expectation that if the class is a singleton, you might actually get a cached instance, rather than a 'new' instance, but it's not very difficult to understand: $a = new members; $b = new members; $c = new members; // $a $b and $c are all the same instance because members is a singleton If you really think 'new' is too ambiguous, why not add a new token such as 'only', which is used for instantiation of singletons? $a = only members; $b = only members; $c = only members; // it's a bit more obvious $a $b and $c are the same instance. - Is it ok to go $members = members; ? That's too ambiguous. In that example 'members' could be a constant, singleton, or simply the string 'members'. - Singleton constructors should not have parameters Perhaps they could (and it might be useful), if it's done like this: $a = new members(1, 2, 3); // arguments are passed to __construct() $b = new members(3, 2, 1); // arguments are ignored, object has already been constructed $c = new members(4, 5, 6); // arguments are ignored, object has already been constructed - Perhaps a new function singleton_getobjects needs to be added to enable access to the internal hash table Not a bad idea. Getting in 'through the back door' is really important. Why not also a 'singleton_is_loaded()', and an 'is_singleton()'? Obviously this would eventually need to be visible through the Reflection classes (etc, etc). - Never have singleton abstract classes? I think that would be an unfair limitation. You should just need to: - add T_SINGLETON to the parser. - add an is_singleton flag for class definitions, activated by T_SINGLETON. - overload the 'new' operator to retrieve from the hash table if the class is a singleton (otherwise call __construct() as normal). - implement some of those helper functions such as singleton_getobjects(). regards, Peter --- [EMAIL PROTECTED] wrote: Sure, implementing singleton is easy enough. But you can't abstract it in PHP. In C++ you can use things called template classes or generics to abstract the singleton implementation. This way you dont have to duplicate the protected constructor, the instance and the accessor for each class. I guess I'm really talking about the bigger picture here, where you might have an application which has around 50 singleton classes. I dont want to duplicate code in each one. I have already implemented singleton in two different ways (see examples 1 and 2 in the bug report - http://bugs.php.net/bug.php?id=39946) and they both have drawbacks. Hmm... give the bug report a quick read over again :) -Original Message- From: Guilherme Blanco [mailto:[EMAIL PROTECTED] Sent: Monday, 5 March 2007 6:21 AM To: [EMAIL PROTECTED] Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Native Singleton Implementation Hi, The idea behing a native singleton class implementation should be really handy, but this is fairly simple to achieve. Take a look at PHP documentation to see some patterns implementation: http://www.php.net/manual/en/language.oop5.patterns.php I hope this helps. Best regards, On 3/4/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: *** Sorry - forgot to change the subject *** Hello All, I am new to the php internals mailing list. I am a fairly experienced programmer with a few ideas floating around. I have come from a C++ games development background and have now moved to primarily writing in php. One thing that I used extensively in C++ was the singleton design pattern. I assume that most of you know what that is, if not a quick google search will let you know. I have written an implementation of singleton in php, but it's slow, and you have to use strings to reference the classes, or duplicate a lot of code. (See methods 1 and 2 below) I recently submitted an RFC to bugs.php.net about this, but there was never feedback from the internals group, so I am going to try here. http://bugs.php.net/bug.php?id=39946 In a few months time, I would like to start helping the development of php, but I am too busy at the moment. I was wondering if anyone has the time to implement this winner feature. I think it would encourage good programming practise and speed up a lot of php apps. Also I would like people's thoughts and feedback on the idea. If no-one can implement this before me, I will have a go at it in a few months time. Thankyou, Scott McNaught
Re: [PHP-DEV] Native Singleton Implementation
Peter Hodge wrote: You should just need to: - add T_SINGLETON to the parser. - add an is_singleton flag for class definitions, activated by T_SINGLETON. - overload the 'new' operator to retrieve from the hash table if the class is a singleton (otherwise call __construct() as normal). - implement some of those helper functions such as singleton_getobjects(). Hi, This seems both to be excessively magical and inflexible. For instance, I have implemented global singletons, singleton per-configuration path (i.e. for a configuration object with cascading configuration files, one singleton per configuration file location), and other models for singleton that stray on the continuum between singleton and factory. The proposed implementation allows only the textbook singleton. The benefit of having singleton in the zend engine in my book is zero. If you have 10 gazillion classes that are all singletons, perhaps another look at the design is in order? I've never had to singleton-ize more than 2-3 classes in even the most complex projects I've been involved with. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php