I can confirm this bug. It's been bugging me for months - now I can
finally stop pulling my hair out. It seems to affect Model-
>find('first') with multiple conditions. The bug seems to occur
somewhere between 125,000 and 140,000 loops. (When I noticed it in
production code, it was occurring at just over 135,000) The same code
with the same data seems to produce the exact same results. I'll
truncate the table and rerun this test one more time to confirm.
As an aside, I assumed _queriesLog was circular. I'll fix that before
I run it again and get the actual query PHP produced.

There is no model file, so there are no associations. At this point,
my best guess would be a memory leak or overflow somewhere within PHP
itself.

Debian Linux 2.6.32-5-amd64 #1 SMP Fri Sep 17 21:50:19 UTC 2010 x86_64
GNU/Linux
PHP 5.3.2-2 with Suhosin-Patch (cli) (built: Jul 19 2010 01:22:58)
Server version: Apache/2.2.16 (Debian)
cakephp/squeeze uptodate 1.3.2-1

<?php
class ReproduceErrorShell extends Shell
{
        var $uses = array('Foo');

        function main()
        {
                assert_options(ASSERT_ACTIVE,   true);
                assert_options(ASSERT_BAIL,     false);
                assert_options(ASSERT_WARNING,  true);
                assert_options(ASSERT_QUIET_EVAL,  true);

                var_dump($this->Foo->_schema);

                for ($x = 0; $x <= 150000; $x += 1)
                {
                        if ($x % 1000 == 0)
                        {
                                echo "[$x]\n";
                        }
                        $dbo = $this->Foo->getDataSource();
                        $dbo->fullDebug = true;
                        $foo = $this->Foo->create();
                        $bar = $foo['Foo']['bar'] = $x+2;
                        $baz = $foo['Foo']['baz'] = $x+3;
                        $this->Foo->recursive = -1;
                        $savedFoo = $this->Foo->save($foo);
                        $this->Foo->recursive = -1;
                        $foundFoo = $this->Foo->find('first', 
array('conditions' =>
array('bar' => $bar, 'baz' => $baz)));

                        $rv = assert('$foundFoo[\'Foo\'][\'bar\'] == $bar and
$foundFoo[\'Foo\'][\'baz\'] == $baz');
                        if ($rv == false)
                        {
                                echo "Assertion Failed\n";
                                echo "x = $x\n";
                                var_dump(array(
                                                        'Expected' => $savedFoo,
                                                        'Found' => $foundFoo,
                                                        'QueryLog' => 
array_slice($dbo->_queriesLog, -20)
                                ));
                                die();
                        }
                }
        }
}
?>

** RESULTS **

Welcome to CakePHP v1.3.2 Console
---------------------------------------------------------------
App : baked
Path: /var/www/baked
---------------------------------------------------------------
array(3) {
  ["id"]=>
  array(5) {
    ["type"]=>
    string(7) "integer"
    ["null"]=>
    bool(false)
    ["default"]=>
    NULL
    ["length"]=>
    int(11)
    ["key"]=>
    string(7) "primary"
  }
  ["bar"]=>
  array(4) {
    ["type"]=>
    string(7) "integer"
    ["null"]=>
    bool(false)
    ["default"]=>
    NULL
    ["length"]=>
    int(11)
  }
  ["baz"]=>
  array(4) {
    ["type"]=>
    string(7) "integer"
    ["null"]=>
    bool(false)
    ["default"]=>
    NULL
    ["length"]=>
    int(11)
  }
}
[0]
[1000]
[2000]
...

[128000]
PHP Warning:  assert(): Assertion "$foundFoo['Foo']['bar'] == $bar and
$foundFoo['Foo']['baz'] == $baz" failed in /var/www/bakedyankee-
testing/vendors/shells/reproduce_error.php on line 31

Warning: assert(): Assertion "$foundFoo['Foo']['bar'] == $bar and
$foundFoo['Foo']['baz'] == $baz" failed in /var/www/bakedyankee-
testing/vendors/shells/reproduce_error.php on line 31
Assertion Failed
x = 128919
array(3) {
  ["Expected"]=>
  array(1) {
    ["Foo"]=>
    array(2) {
      ["bar"]=>
      int(128921)
      ["baz"]=>
      int(128922)
    }
  }
  ["Found"]=>
  array(1) {
    ["Foo"]=>
    array(3) {
      ["id"]=>
      string(5) "86110"
      ["bar"]=>
      string(5) "86111"
      ["baz"]=>
      string(5) "86112"
    }
  }
  ["QueryLog"]=>
  array(20) {
    [0]=>
    array(5) {
      ["query"]=>
      string(49) "INSERT INTO `foos` (`bar`, `baz`) VALUES (62, 63)"
      ["error"]=>
      NULL
      ["affected"]=>
      int(1)
      ["numRows"]=>
      NULL
      ["took"]=>
      float(1)
    }
    [1]=>
    array(5) {
      ["query"]=>
      string(35) "SELECT LAST_INSERT_ID() AS insertID"
      ["error"]=>
      NULL
      ["affected"]=>
      int(1)
      ["numRows"]=>
      int(1)
      ["took"]=>
      float(0)
    }
    [2]=>
    array(5) {
      ["query"]=>
      string(109) "SELECT `Foo`.`id`, `Foo`.`bar`, `Foo`.`baz` FROM
`foos` AS `Foo`   WHERE `bar` = 62 AND `baz` = 63    LIMIT 1"
      ["error"]=>
      NULL
      ["affected"]=>
      int(1)
      ["numRows"]=>
      int(1)
      ["took"]=>
      float(3)
    }
    [3]=>
    array(5) {
      ["query"]=>
      string(49) "INSERT INTO `foos` (`bar`, `baz`) VALUES (63, 64)"
      ["error"]=>
      NULL
      ["affected"]=>
      int(1)
      ["numRows"]=>
      NULL
      ["took"]=>
      float(7)
    }
...
    [19]=>
    array(5) {
      ["query"]=>
      string(35) "SELECT LAST_INSERT_ID() AS insertID"
      ["error"]=>
      NULL
      ["affected"]=>
      int(1)
      ["numRows"]=>
      int(1)
      ["took"]=>
      float(0)
    }
  }
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to