<commit_before>RFC 0023: 
========================================================================
$Id$

@authors: kiesel
@created: Thu Apr 21 14:11:52 CEST 2005
@status: draft
@category: rdbms

Scope of Change
---------------
The constructor of rdbms.Criteria will be removed, and a new static
method createFor() will be added which basically mimics the constructor's
behaviour and retrieves an arbitrary list of conditions.

Note: this is a BC-break!

Rationale
---------
The constructor calls func_get_args() to get the list of arguments it has
been invoked with. func_get_args() is known to cause memory corruption which
usually does not lead to problems with short running applications (such
as web frontends) but can cause heavy damage to long running applications.

By removing the constructor, there won't be any calls to func_get_args left
- Object::Object() does not call the function either, because __construct()
does not exist any more.

Functionality
-------------
As a replacement for the old functionality of the constructor, a new method
createFor() will be added which must be invoked statically.

The old way of creating criteria objects changes from:
<pre>
  $criteria= &new Criteria(array('bz_id', $bz_id, EQUAL));
</pre>

to

<pre>
  $criteria= &Criteria::createFor(array('bz_id', $bz_id, EQUAL));
</pre>

The "safe" way that prevents memory corruption then is
<pre>
  $criteria= &new Criteria();
  $criteria->add('bz_id', $bz_id, EQUAL);
</pre>

Security considerations
-----------------------
The new implementation is supposed to prevent severe memory corruption
in long running applications and thus is considered more secure.

Speed impact
------------
n/a

Dependencies
------------
* ports/dist/database/util/classgen/data/xp.php.xsl must be updated to
  generate database classes following the new Criteria implementation.

Related documents
-----------------
n/a

Comments
--------

<EOF><commit_msg>- set status from draft to discussion - add implementation patch<commit_after>RFC 0023: Fix memory corruption in rdbms.Criteria
========================================================================
$Id$

@authors: kiesel
@created: Thu Apr 21 14:11:52 CEST 2005
@status: discussion
@category: rdbms

Scope of Change
---------------
The constructor of rdbms.Criteria will be removed, and a new static
method createFor() will be added which basically mimics the constructor's
behaviour and retrieves an arbitrary list of conditions.

Note: this is a BC-break!

Rationale
---------
The constructor calls func_get_args() to get the list of arguments it has
been invoked with. func_get_args() is known to cause memory corruption which
usually does not lead to problems with short running applications (such
as web frontends) but can cause heavy damage to long running applications.

By removing the constructor, there won't be any calls to func_get_args left
- Object::Object() does not call the function either, because __construct()
does not exist any more.

Functionality
-------------
As a replacement for the old functionality of the constructor, a new method
createFor() will be added which must be invoked statically.

The old way of creating criteria objects changes from:
<?php
  $criteria= &new Criteria(array('bz_id', $bz_id, EQUAL));
?>

to

<?php
  $criteria= &Criteria::createFor(array('bz_id', $bz_id, EQUAL));
?>

The "safe" way that prevents memory corruption then is
<?php
  $criteria= &new Criteria();
  $criteria->add('bz_id', $bz_id, EQUAL);
?>

Security considerations
-----------------------
The new implementation is supposed to prevent severe memory corruption
in long running applications and thus is considered more secure.

Speed impact
------------
n/a

Dependencies
------------
- ports/dist/database/util/classgen/data/xp.php.xsl must be updated to
  generate database classes following the new Criteria implementation.

Related documents
-----------------
- http://xp-framework.net/downloads/rfc0023.diff
  Patch against / implementing this change

Comments
--------

<EOF>
{'fraction_non_alphanumeric': 0.15447557649392513, 'fraction_numerical': 0.008926357550210762, 'mean_word_length': 3.8081048867699643, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '758443', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1029, 'n_words': 481}