#300 closed defect (wontfix)

Error on PHP files containing multiple namespaces when XCache is enabled

Reported by: adrienlabelle Owned by: moo
Priority: major Milestone: 3.0.2
Component: cacher Version: 3.0.1
Keywords: Cc:
Application: PHP Version:
Other Exts: SAPI: Irrelevant
Probability: Always Blocked By:
Blocking:

Description

This was first reported over there: https://github.com/nrk/predis/issues/80 but it seems to be a problem with XCache, not this specific library.

If I enable xcache on my apache server, Predis throws the following error:
"Fatal error: Class 'Predis\CommunicationException?' not found in..."

I am using the one-file version of Predis (not really my choice, the application I use Predis with is a bit rigid).
It should be noted this has been reproduced on two different machines.
Disabling XCache as an extension or disabling the caching engine fix the issue.

The issue is present in XCache 3.0.1 too.

PHP version:

PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with XCache v1.3.2, Copyright (c) 2005-2011, by mOo

OS:
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise

Apache:
Server version: Apache/2.2.22 (Ubuntu)
Server built: Feb 13 2012 01:51:50

Predis Client version is 0.7.4-dev

Thank you very much for your time.

Attachments (1)

xcache_300.zip (41.8 KB) - added by adrienlabelle 11 months ago.
Test case for issue reported in bug #300

Download all attachments as: .zip

Change History (10)

comment:1 Changed 11 months ago by moo

  • Milestone changed from undecided to 3.0.2
  • Status changed from new to assigned

comment:2 Changed 11 months ago by moo

i don't think it's easy for me to reproduce. can you attach a simple script (and with the huge single file) to reproduce the problem?

comment:3 Changed 11 months ago by moo

  • Status changed from assigned to infoneeded

comment:4 Changed 11 months ago by moo

  • Blocking 308 added

comment:5 Changed 11 months ago by trac

  • Blocking 308 removed

(In #308) Ticket #308 deleted

comment:6 Changed 11 months ago by adrienlabelle

  • Status changed from infoneeded to assigned

I am putting a test case together right now, I will post it here as soon as it is ready.

Thank you for your time.

Changed 11 months ago by adrienlabelle

Test case for issue reported in bug #300

comment:7 Changed 11 months ago by adrienlabelle

I submitted a ZIP file containing a test file index.php and the lib used to reproduce the case. This assumes:

  • The LAMP environment described in the ticket
  • a redis server running, bound to 127.0.0.1:6379 (ubuntu repository version works fine)

The first page load works fine, the second load gives the following error:

Fatal error: Class 'Predis\CommunicationException' not found in /[...]/xcache_300/lib/predis/Predis.php on line 5518

comment:8 Changed 11 months ago by moo

  • Status changed from assigned to started

reproduced. working on it

comment:9 Changed 11 months ago by moo

  • Resolution set to wontfix
  • Status changed from started to closed

the following reproduced code is reduced from your attachment

<?php

class Child extends Base
{
}

class Base extends Exception
{
}

the order matter XCache, not without XCache in older PHP. it works in new PHP but is deprecated

This is by XCache design and cannot be fixed unless a workaround is figured out.

reason:
Exception is a builtin class. When compile without XCache, for "class Base extends Exception" the Exception is known, so it just do "early binding", while child Class is a late binding class because class Base is known at the point it is needed. so the result is, the class Base is actually defined before class Child

With XCache, XCache made a sandbox with no builtin class. In this way "class Base extends Exception" see no "Exception" making class Base as late binding class, which is after the late binding class Child. when class Child do late binding, no class Base is found, error thrown

The workaround cannot be done in XCache, but can be done in your php code. just you or the author (the one who combine *.php to lib/predis/Predis.php) modify it to correct order which looks like

<?php

class Base extends Exception
{
}

class Child extends Base
{
}

Note: See TracTickets for help on using tickets.