summaryrefslogtreecommitdiff
path: root/README.UPDATE_5_2
blob: 92ea99828397674f9c89d6cd6596ea72314209e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
PHP 5.2 UPDATE INFO

===============================
Changes in PHP datetime support
===============================

Since PHP 5.1, there has been an extension named 'date' in the PHP core. This
is the new implementation of PHP's datetime support. Although it will attempt
to guess your system's timezone setting, you should set the timezone manually.
You can do this in any of three ways:

1) in your php.ini using the date.timezone INI directive
2) on your system using the TZ environmental variable
3) from your script using the convenience function date_default_timezone_set()

All supported timezones are listed in the PHP Manual at
http://www.php.net/manual/timezones.php.

With the advent of PHP 5.2, there are object representations of the date and
timezone, named DateTime and DateTimeZone respectively. You can see the methods
and constants available to the new classes by running

php --rc DateTime
php --rc DateTimeZone

under PHP CLI. All methods map to existing procedural date functions.

==================================
Items from the NEWS file explained
==================================

- Added new error mode E_RECOVERABLE_ERROR. (Derick, Marcus, Tony)

  Some of the existing E_ERROR conditions have been converted to something that
  you can catch with a user-defined error handler. If an E_RECOVERABLE_ERROR is
  not handled, it will behave in the same way as E_ERROR behaves in all versions
  of PHP. Errors of this type are logged as 'Catchable fatal error'.


- Changed E_ALL error reporting mode to include E_RECOVERABLE_ERROR. (Marcus)

  This change means that the value of the E_ALL error_reporting constant is now
  6143, where its previous value was 2047. If you are setting the error_reporting
  mode from either the Apache config file or the .htaccess files, you will need
  to adjust the value accordingly. The same applies if you use the numeric value
  rather than the constant in your PHP scripts.


- Added support for constructors in interfaces to force constructor signature
  checks in implementations. (Marcus)

  Starting with PHP 5.2, interfaces can have constructors. However, if you choose
  to declare a constructor in an interface, each class implementing that interface
  MUST include a constructor with a signature matching that of the base interface
  constructor. By 'signature' we mean the parameter and return type definitions,
  including any type hints and including whether the data is passed by reference
  or by value.


- Changed __toString to be called wherever applicable. (Marcus)

  The magic method __toString() will now be called in a string context, that
  is, anywhere an object is used as a string. When implementing your __toString()
  method in a class, you should be aware that the script will terminate if
  your function throws an exception.

  The PHP 5.0/5.1 fallback - returning a string that contains the object
  identifier - has been dropped in PHP 5.2. It became problematic because
  an object identifier cannot be considered unique. This change will mean
  that your application is flawed if you have relied on the object identifier
  as a return value. An attempt to use that value as a string will now result
  in a catchable fatal error (see above).

  Even with __toString(), objects cannot be used as array indices or keys. We
  may add built-in hash support for this at a later date, but for PHP 5.2 you
  will need to either provide your own hashing or use the new SPL function
  spl_object_hash().


- Added RFC2397 (data: stream) support. (Marcus)

  The introduction of the 'data' URL scheme has the potential to lead to a
  change of behaviour under Windows. If you are working with an NTFS
  filesystem and making use of meta streams in your application, and if you
  just happen to be using a file with the name 'data:' that is accessed without
  any path information - it won't work any more. The fix is to use the 'file:'
  protocol when accessing it.

  There is information about the RFC at http://www.faqs.org/rfcs/rfc2397.html.


- Added allow_url_include ini directive to complement allow_url_fopen. (Rasmus)

  This useful option makes it possible to differentiate between standard
  file operations on remote files, and the inclusion of remote files. While the
  former is usually desirable, the latter can be a security risk if used naively.
  Starting with PHP 5.2, you can allow remote file operations while
  disallowing the inclusion of remote files in local scripts. In fact, this
  is the default configuration.


- Dropped abstract static class functions. (Marcus)

  Due to an oversight, PHP 5.0 and 5.1 allowed abstract static functions in
  classes. In PHP 5.2, only interfaces can have them.


- Removed extensions (Derick, Tony)

  The filepro and hwapi extensions have been moved to PECL and are no longer
  part of the PHP distribution. The PECL package version of these extensions
  will be created on the basis of user demand.


- Added extensions (Rasmus, Derick, Pierre)

  The JSON extension implements the JavaScript Object Notation (JSON)
  data interchange format. This extension is enabled by default.

  The Filter extension validates and filters data, and is designed for
  use with insecure data such as user input. This extension is enabled
  by default; the default mode RAW does not impact input data in any way.

  The Zip extension enables you to transparently read or write ZIP
  compressed archives and the files inside them.

  Please refer to the PHP Manual for details.


- Improved memory manager and increased default memory limit (Dmitry)

  The new memory manager allocates less memory and works faster than the
  previous incarnation. It allocates memory from the system in large blocks,
  and then manages the heap by itself. The memory_limit value in php.ini is
  checked, not for each emalloc() call (as before), but for actual blocks
  requested from the system. This means that memory_limit is far more
  accurate than it used to be, since the old memory manager didn't calculate
  all the memory overhead used by the malloc library.

  Thanks to this new-found accuracy memory usage may appear to have increased,
  although actually it has not. To accommodate this apparent increase, the
  default memory_limit setting was also increased - from 8 to 16 megabytes.


- Changed priority of PHPRC environment variable on win32 (Dmitry)

  The PHPRC environment variable now takes priority over the path stored
  in the Windows registry.


- Added notice when accessing return value from __get() in write mode (Marcus)

  The reason for this is that __get() only returns variables in read mode, and
  it is therefore not possible to write to the returned variable. In previous
  releases there was no effective way to detect incorrect usage. Starting from
  PHP 5.2, an E_NOTICE will be emitted in this situation.

  WARNING: foreach() and functions that modify the internal array pointer will
  now also trigger the same E_NOTICE, since modification requires that the
  variable be accessed in write mode. To work around this, you should either
  cast the returned value from __get() to an array, or use SPL's ArrayObject
  instead of an array.

- CLI SAPI no longer checks cwd for php.ini or the php-cli.ini file (Edin)

  In PHP 5.1.X an undocumented feature was added that made the CLI binary
  check the current directory for PHP configuration file possibly leading to
  unpredictable behavior due to an un-expected configuration file being
  read. This functionality was removed in 5.2 and PHP will no longer search
  CWD for the presence of the php.ini or the php-cli.ini files.

- Added a notice when performing modulus 0 operation (Tony)

  In earlier versions of PHP performing integer % 0 did not emit any 
  warning messages, instead retuning an un-expected return value of false.
  As of PHP 5.2 this operation will emit E_WARNING as is the case in all
  other instance where division by zero is performed.
 
==============================
Backwards incompatible changes
==============================

Misc
====
- $php_errormsg now prepends the function name causing the error
- $php_errormsg doesn't get populated anymore when using custom error handler

Error messages
==============
<?php
/* PHP Warning:  bzopen(): filename cannot be empty in /usr/src/php/examples/bzopen.no.filename.php on line 3 */
bzopen("", "w");
?>

<?php
/* PHP Warning:  bzopen(): 'a' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. in /usr/src/php/examples/bzopen.wrong.stream.mode.php on line 3 */
bzopen("foo", "a");

$fp = fopen("foo", "a");
/* PHP Warning:  bzopen(): cannot read from a stream opened in write only mode in /usr/src/php/examples/bzopen.wrong.stream.mode.php on line 7 */
bzopen($fp, "r");
?>

<?php
/* PHP Warning: Invalid access mode -1 in /usr/src/php/examples/dbase.invalid.access.mode.php on line 3 */
dbase_open("foo", -1);
?>

<?php
/* PHP Fatal error:  Class bar cannot implement previously implemented interface foo in /usr/src/php/examples/impliment.implemented.php on line 4 */
interface foo {
}
class bar implements foo, foo {
}
?>

<?php
class foo {
	public $bar;
	function __get($var)
	{
		return $this->bar;
	}
}

$foo = new foo;
/* PHP Notice:  Indirect modification of overloaded property foo::$prop has no effect in /usr/src/php/examples/indirect.modification.of.overloaded.property.php on line 12 */
$bar =& $foo->prop;
?>

<?php
class foo implements iterator {
    public function current() {

    }
    public function next() {

    }
    public function key() {

    }
    public function valid() {

    }
    public function rewind() {

    }
}

$foo = new foo();
/* PHP Fatal error:  An iterator cannot be used with foreach by reference in /usr/src/php/examples/iterator.foreach.by_ref.php on line 22 */
foreach($foo as &$ref) {
}
?>

<?php
$key = "this is a secret key";

$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
/* PHP Warning: An empty string was passed in /usr/src/php/examples/mcrypt.generic.empty.string.php on line 8 */
$encrypted_data = mcrypt_generic($td, "");
?>

<?php
/* PHP Warning:  Division by zero in /usr/src/php/examples/modulus.by.zero.php on line 3 */
print 10%0;

?>

<?php
/* PHP Warning: Invalid character set name: bogus_charset in /usr/src/php/examples/oci.bogus.charset.php on line 3 */
oci_connect("user", "pass", "db", "bogus_charset");
?>

<?php
$oci = oci_connect("user", "pass", "db");
/* PHP Warning: username cannot be empty in /usr/src/php/examples/oci.no.empty.username.php on line 4 */
oci_password_change($oci, "", "old", "new");
/* PHP Warning: old password cannot be empty in /usr/src/php/examples/oci.no.empty.username.php on line 6 */
oci_password_change($oci, "user", "", "new");
/* PHP Warning: new password cannot be empty in /usr/src/php/examples/oci.no.empty.username.php on line 8 */
oci_password_change($oci, "user", "old", "");
?>

<?php
class foo {
    private function __construct() {
    }
}
class bar extends foo {
    public function __construct() {
        /* PHP Fatal error:  Cannot call private foo::__construct() in /usr/src/php/examples/private.ctor.php on line 9 */
        parent::__construct();
    }
}
new bar;
?>

<?php
echo " ";
/*  PHP Warning:  session_regenerate_id(): Cannot regenerate session id - headers already sent in /usr/src/php/examples/session.cannot.regenerate.id.php on line 4 */
session_regenerate_id();

?>

<?php
$obj = new SplFileObject(__FILE__);
/* PHP Warning:  SplFileObject::fgetcsv(): delimiter must be a character in /usr/src/php/examples/splfileobj.csv.must.be.char.php on line 4 */
$obj->fgetcsv("foo");
/* PHP Warning:  SplFileObject::fgetcsv(): enclosure must be a character in /usr/src/php/examples/splfileobj.csv.must.be.char.php on line 6 */
$obj->fgetcsv(",", "foo");

?>

<?php
/* PHP Strict Standards:  Static function foo::bar() should not be abstract in /usr/src/php/examples/static.abstract.method.php on line 3 */
abstract class foo {
    abstract static function bar();
}

?>

<?php
/* PHP Warning:  stream_filter_register(): Filter name cannot be empty in /usr/src/php/examples/stream.filter.cannot.be.empty.php on line 3 */
stream_filter_register("", "class");
/* PHP Warning:  stream_filter_register(): Class name cannot be empty in /usr/src/php/examples/stream.filter.cannot.be.empty.php on line 5 */
stream_filter_register("filter", "");
?>

<?php
/* PHP Warning:  str_word_count(): Invalid format value 4 in /usr/src/php/examples/string.wordcount.invalid.format.value.php on line 3 */
str_word_count("string", 4);
?>

<?php
/* PHP Notice:  strripos(): Offset is greater than the length of haystack string in /usr/src/php/examples/strripos.offset.greater.than.heystrack.php on line 3 */
strripos("foo", "f", 4);
?>

<?php
/* PHP Notice:  strrpos(): Offset is greater than the length of haystack string in /usr/src/php/examples/strrpos.offset.greater.than.heystrack.php on line 3 */
strrpos("foo", "f", 4);
?>

<?php
class foo {
    public function __toString() {
        throw new Exception;
    }
}
try {
    /* PHP Fatal error:  Method foo::__toString() must not throw an exception in /usr/src/php/examples/tostring.exception.php on line 9 */
    print new foo;
} catch(Exception $e) {

}
?>

============
NEW FEATURES
============

New Classess:
=============
  RegexIterator extends FilterIterator implements Iterator, Traversable, OuterIterator
    Constants:
      RecursiveRegexIterator::USE_KEY
      RecursiveRegexIterator::MATCH
      RecursiveRegexIterator::GET_MATCH
      RecursiveRegexIterator::ALL_MATCHES
      RecursiveRegexIterator::SPLIT
      RecursiveRegexIterator::REPLACE
    Properties:
      public $replacement
    Methods:
      RegexIterator::__construct(Iterator it, string regex [, int mode [, int flags [, int preg_flags]]])
        - Create an RegexIterator from another iterator and a regular expression
      bool RegexIterator::accept()
        - Match (string)current() against regular expression
      bool RegexIterator::getMode()
        - Returns current operation mode
      bool RegexIterator::setMode(int new_mode)
        - Set new operation mode
      bool RegexIterator::getFlags()
        - Returns current operation flags
      bool RegexIterator::setFlags(int new_flags)
        - Set operation flags
      bool RegexIterator::getPregFlags()
        - Returns current PREG flags (if in use or NULL)
      bool RegexIterator::setFlags(int new_flags)
        - Set PREG flags

  RecursiveRegexIterator extends RegexIterator implements OuterIterator, Traversable, Iterator, RecursiveIterator
    Methods:
      RecursiveRegexIterator::__construct(RecursiveIterator it, string regex [, int mode [, int flags [, int preg_flags]]])
        Create an RecursiveRegexIterator from another recursive iterator and a regular expression
      RecursiveRegexIterator RecursiveRegexIterator::getChildren()
        Return the inner iterator's children contained in a RecursiveRegexIterator
      bool RecursiveRegexIterator::hasChildren()
        Check whether the inner iterator's current element has children


New methods:
============
  ext/dom
    DOMDocument:
      DOMDocument::registerNodeClass(string baseclass, string extendedclass)
        - Register extended class used to create base node type

    DOMElement:
      DOMElement::setIDAttribute(string name, boolean isId)
        - Declares the attribute specified by name to be of type ID
      DOMElement::setIDAttributeNS(string namespaceURI, string localName, boolean isId)
        - Declares the attribute specified by local name and namespace URI to be of type ID
      DOMElement::setIDAttributeNode(DOMAttr idAttr, boolean isId)
        - Declares the attribute specified by node to be of type ID

    DOMNode:
      DOMNode::getNodePath()
        - Gets an xpath for a node
      DOMNode::C14N([bool exclusive [, bool with_comments [, array xpath [, array ns_prefixes]]]])
        - Canonicalize nodes to a string
      DOMNode::C14NFile(string uri [, bool exclusive [, bool with_comments [, array xpath [, array ns_prefixes]]]])
        - Canonicalize nodes to a file

  ext/soap
    SoapServer:
      SoapServer::setObject(object obj)
        - Sets object which will handle SOAP requests

  ext/spl
    ArrayObject:
      int ArrayObject::asort(void)
        - Sort the entries by values
      int ArrayObject::ksort(void)
        - Sort the entries by key
      int ArrayObject::uasort(callback cmp_function)
        - Sort the entries by values user defined function
      int ArrayObject::uksort(callback cmp_function)
        - Sort the entries by key using user defined function.
      int ArrayObject::natsort(void)
        - Sort the entries by values using "natural order" algorithm.
      int ArrayObject::natcasesort(void)
        - Sort the entries by key using case insensitive "natural order" algorithm.

    SplFileObject
      void SplFileObject::setCsvControl([string delimiter = ',' [, string enclosure = '"']])
        - Set the delimiter and enclosure character used in fgetcsv
      array("delimiter" =>, "enclosure" =>) SplFileObject::getCsvControl(void)
        - Get the delimiter and enclosure character used in fgetcsv

    CachingIterator
      void CachingIterator::offsetSet(mixed index, mixed newval)
        - Set given index in cache
      string CachingIterator::offsetGet(mixed index)
        - Return the internal cache if used
      void CachingIterator::offsetUnset(mixed index)
        - Unset given index in cache
      bool CachingIterator::offsetExists(mixed index)
        Return whether the requested index exists
      bool CachingIterator::getCache()
        Return the cache
      int CachingIterator::getFlags()
        Return the internal flags
      void CachingIterator::setFlags()
        Set the internal flags
      int AppendIterator::getIteratorIndex()
        Get index of iterator
      ArrayIterator AppendIterator::getArrayIterator()
        Get access to inner ArrayIterator
      boolean XMLReader::setSchema(string filename)
        Use W3C XSD schema to validate the document as it is processed. Activation is only possible before the first Read()


New class constants:
====================
  SplFileObject::READ_AHEAD
  SplFileObject::SKIP_EMPTY
  SplFileObject::READ_CSV

  CachingIterator::TOSTRING_USE_INNER
  CachingIterator::FULL_CACHE


New functions:
==============
  ext/mbstring
    int mb_stripos(string haystack, string needle [, int offset [, string encoding]])
      - Finds position of first occurrence of a string within another, case insensitive
    int mb_strripos(string haystack, string needle [, int offset [, string encoding]])
      - Finds position of last occurrence of a string within another, case insensitive
    string mb_strstr(string haystack, string needle[, bool part[, string encoding]])
      - Finds first occurrence of a string within another
    string mb_strrchr(string haystack, string needle[, bool part[, string encoding]])
      - Finds the last occurrence of a character in a string within another
    string mb_stristr(string haystack, string needle[, bool part[, string encoding]])
      - Finds first occurrence of a string within another, case insensitive
    string mb_strrichr(string haystack, string needle[, bool part[, string encoding]])
      - Finds the last occurrence of a character in a string within another, case insensitive
    array mb_list_encodings_alias_names([string encoding])
      - Returns an array of all supported entity encodings
    mixed mb_list_mime_names([string encoding])
      - Returns an array or string of all supported mime names

  ext/openssl
    array openssl_csr_get_subject(mixed csr [, bool use_short_names])
      - Returns the subject of a CERT
    resource openssl_csr_get_public_key(mixed csr)
      - Returns the subject of a CERT
    array openssl_pkey_get_details(resource key)
      - returns an array with the key details (bits, pkey, type)

  ext/spl
    string spl_object_hash(object obj)
      - Return hash id for given object
    int iterator_apply(Traversable it, mixed function [, mixed params])
      - Calls a function for every element in an iterator

  ext/pcre
    int preg_last_error(void)
      - Returns the error code of the last regexp execution.

  ext/pgsql
    mixed pg_field_table(resource result, int field_number[, bool oid_only])
      - Returns the name of the table field belongs to, or table's oid if oid_only is true

  ext/posix
    bool posix_initgroups(string name, int base_group_id)
      - Calculate the group access list for the user specified in name

  ext/standard
    array array_fill_keys(array keys, mixed val)
      - Create an array using the elements of the first parameter as keys each initialized to val
    int memory_get_peak_usage([real_usage])
      - Returns the peak allocated by PHP memory
    array error_get_last()
      - Get the last occurred error as associative array. Returns NULL if there hasn't been an error yet


New optional parameters:
========================
  - array curl_multi_info_read(resource mh [, long msgs_in_queue]) (msgs_in_queue)
  - int mb_strrpos(string haystack, string needle [, int offset [, string encoding]]) (offset)
  - int openssl_verify(string data, string signature, mixed key [, int signature_algo]) (signature_algo)
  - string pg_escape_string([resource connection,] string data) (connection)
  - string pg_escape_bytea([resource connection,] string data) (connection)
  - object SimpleXMLElement::children([string ns [, bool is_prefix]]) (is_prefix)
  - array SimpleXMLElement::attributes([string ns [, bool is_prefix]]) (is_prefix)
  - SimpleXMLElement simplexml_load_file(string filename [, string class_name [, int options [, string ns [, bool is_prefix]]]]) (ns && is_prefix)
  - SimpleXMLElement simplexml_load_string(string data [, string class_name [, int options [, string ns [, bool is_prefix]]]]) (ns && is_prefix)
  - SimpleXMLElement::__construct(string data [, int options [, bool data_is_url [, string ns [, bool is_prefix]]]]) (ns && is_prefix)
  - string base64_decode(string str[, bool strict=false]) (strict)
  - bool setcookie(string name [, string value [, int expires [, string path [, string domain [, bool secure[, bool httponly=false]]]]]] (httponly)
  - bool setrawcookie(string name [, string value [, int expires [, string path [, string domain [, bool secure[, bool httponly=false]]]]]] (httponly)
  - void session_set_cookie_params(int lifetime [, string path [, string domain [, bool secure[, bool httponly]]]]) (httponly)
  - int memory_get_usage([bool real_usage=false]) (real_usage)
  - boolean XMLReader::open(string URI [, string encoding [, int options]]) (encoding, options)
  - boolean XMLReader::XML(string source [, string encoding [, int options]]) (encoding, options)