Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002876 [Quercus] major always 08-28-08 10:18 08-28-08 19:38
Reporter koreth View Status public  
Assigned To nam
Priority high Resolution fixed  
Status closed   Product Version 3.2.1
Summary 0002876: APC-cached objects' classes are assigned at store, not at fetch
Description Here's test1.php, which unserializes an instance of an undefined class and stashes it in APC:

<?php
$foo = unserialize('O:3:"Foo":1:{s:3:"bar";i:1;}');
apc_store('test', $foo);

And here's test2.php, which defines the class and pulls the object from APC:

<?php
class Foo {
  public $bar;
}

$foo = apc_fetch('test');
if ($foo instanceof Foo) {
  print "it's a Foo\n";
} else {
  print_r($foo);
}

In plain PHP, fetching test1.php then test2.php gets you "it's a Foo". In Quercus, you get the print_r of the incomplete-class-name object.

We have an "initialize APC" script that reads a couple megabytes worth of data and stashes it into APC; that script doesn't need to have all the class declarations loaded in regular PHP. In Quercus it breaks in a bunch of places because the objects aren't of the expected types when they're pulled from APC.

For our purposes it's sufficient to just fix this for the case of an object whose class was undefined at the time it was stored in APC (but is defined at fetch time) and I think that's probably the most common case in general. But I suppose there could also be more obscure cases where you have two classes of the same name but with different methods that you want to be able to instantiate from the same APC entries. Not good programming practice, of course, but it would work fine in vanilla PHP.
Additional Information
Attached Files

- Relationships

- Notes
(0003366)
nam
08-28-08 19:38

php/4209
php/420a
php/420b

On apc_fetch() call, PHP will attempt to inject the currently available classes into all fetched objects. Quercus now follows this pattern.
 

- Issue History
Date Modified Username Field Change
08-28-08 10:18 koreth New Issue
08-28-08 11:04 emil Priority normal => high
08-28-08 13:43 nam Status new => assigned
08-28-08 13:43 nam Assigned To  => nam
08-28-08 19:38 nam Status assigned => closed
08-28-08 19:38 nam Note Added: 0003366
08-28-08 19:38 nam Resolution open => fixed
08-28-08 19:38 nam Fixed in Version  => 3.2.1


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker