Issues

ZF-7042: metadata cache identifier collisions

Issue Type: Bug Created: 2009-06-18T07:58:19.000+0000 Last Updated: 2009-08-25T16:47:54.000+0000 Status: Resolved Fix version(s): - 1.9.3 (22/Sep/09)

Reporter: Grégory Eve (igreg) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db_Table

Related issues: Attachments:

Description

The cache identifier where the metadata are saved is not unique:

  • schema is not mandatory, so if you have two databases with a same table name in both and you haven't set the schema it will generate the same id.
  • you can connect to databases on different host or port and it's also not include in the id so there are collisions.
<pre class="highlight">
$cacheId = md5("$this->_schema.$this->_name");

should be replace to :

<pre class="highlight">
//get db configuration
$dbConfig = $this->_db->getConfig();

//get the port if available 
$port = isset($dbConfig['options']['port']) ? ':'.$dbConfig['options']['port'] : null;

//get the custom schema or the default schema if not specified
$schema = !empty($this->_schema) ? $this->_schema : $dbConfig['dbname'];

// Define the cache identifier where the metadata are saved
$cacheId = md5($dbConfig['host'].$port.'/'.$schema.'.'.$this->_name);

Comments

Posted by Mickael Perraud (mikaelkael) on 2009-08-25T06:46:46.000+0000

Exactly the same for me today ;)

But with your correction, we can't have same schema in different database on same server.

I choose:

<pre class="highlight">
// If $this has a metadata cache
if (null !== $this->_metadataCache) {
    //get db configuration
    $dbConfig = $this->_db->getConfig();

    //get the port if available
    $port = isset($dbConfig['options']['port']) ? ':'.$dbConfig['options']['port'] : null;

    //get the host if available
    $host = isset($dbConfig['options']['host']) ? ':'.$dbConfig['options']['host'] : null;

    // Define the cache identifier where the metadata are saved
    $cacheId = md5($host.$port.'/'.$dbConfig['dbname'].':'.$this->_schema.'.'.$this->_name);
}

Posted by Ralph Schindler (ralph) on 2009-08-25T16:47:54.000+0000

Used patch supplied.

Fixed in trunk in 17819, and merged to release branch 1.9 in 17820

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts