Zend caching broken (P4A 3.6.1) at ISP

Developers
croaker___
2010-09-07
2013-05-15
  • croaker___

    croaker___ - 2010-09-07

    I'm getting the familiar "Fatal error: Call to a member function build() on a non-object in ./p4a/objects/mask.php on line 159". The line number is different to what I'm used to but with P4A 3.6.1 this seems to be the new line number.

    I get it after uploading P4A to new hosting on my ISP.

    I can trace back the problem to ./Zend/Locale/Data.php (line 300). If I rem out the code blocks dealing with caching in this function, I can get my P4A application to work - to a certain amount, there are still issues. I guess these issues are related to other Zend calls elsewhere that also has caching functions.

    Can you please tell me where in P4A the Zend cache location is set so I can either disanle it throughout P4A or set it to a writeable location on my ISP's server.

    Thanks

     
  • Fabrizio Balliano

    actually it seems to me that we don't use zend_cache, maybe it's used by some other components but not directly from us :-\

     
  • croaker___

    croaker___ - 2010-09-08

    It seems that Zend are implementing a memory cache rather than a disk based cache. I don't know enough about Zend to work it out.

    Perhaps I need to take this up with Zend support.

     
  • croaker___

    croaker___ - 2010-09-08

    Update:
    1. Some of the Zend components do indeed cache themselves.
    2. I've had some success in resolving the problem by manually editing "./p4a/libraries/Zend/Cache/Backend/File.php" at line 90, there's an option to set the cache directory. Using phpinfo() on my hosting, I discovered the full system path to the directory on the server where P4A is installed. I then created a "cache" directory with chmod 777 and pointed line 90 to it:

    'cache_dir' => '/home/fhlinux170/p/preview.mydomain.co.uk/user/cache',

    (Where /home/fhlinux170/p/preview.mydomain.co.uk/user/ is my ftp root and /home/fhlinux170/p/preview.mydomain.co.uk/user/htdocs is the root of my website.

    I'm working on finding out how to set this field programmatically.

     
  • Fabrizio Balliano

    fine so when you'll discover we should add this info to the faq :)

     
  • croaker___

    croaker___ - 2010-09-08

    This posting on the Zend Forum pretty much encapsulates the whole problem.

    http://framework.zend.com/issues/browse/ZF-9897

    In short, you can't set the cache directory programmatically because the required function is not static - you have the set the cache directory manually.

    Alternatively, you can disable the cache but that slows everything down.

     
  • croaker___

    croaker___ - 2010-09-09

    I'm thinking that we need to setup the Zend Cache components in the P4A code somewhere where we can make a call to set the cache path.

    Does anyone know enough about Zend to suggest how to do this?

    Where in P4A should we put the code to make it available when P4A runs and also allow us to set it up when necessary (I'm thinking of some sort call in an application's index.php similar to the P4A_LOCALE and P4A_DSN defines to get it to load and manually set the cache path).

    This is a major issue for me (as my ISP seems to cause the problem regularly) so I _will_ code something up, I'm just short of MIPs for the next few weeks. Any input will be gratefully received.

     
  • Fabrizio Balliano

    if you use 3.6.3 SVN you can now, in your application constructor, use this code:

    require_once "Zend/Cache.php";
    $cache = Zend_Cache::factory("Core", "File", array(), array("cache_dir"=>"/yourcachingdirectory"));
    parent::__construct($cache);

    and your problem will be gone, let me know if it works!
    bye
    fabrizio

     
  • croaker___

    croaker___ - 2010-09-13

    Fabrizio

    Thanks for looking at this

    I've just tested this with a couple of my applications using 3.6.3 SVN and Zend 1.10.8 on my local Test Server and it works just great.

    When I upload the same code to my ISP hosting and set the cache directory, it still fails unfortunately.

    "Fatal error: Call to a member function build() on a non-object in /home/fhlinux171/m/mydomain.co.uk/user/htdocs/admin/p4a/objects/mask.php on line 159"

    If I remove the new code and set the cache_dir manually in ./Zend/Cache/Backend/File.php, it works again.

    Martin

     
  • Fabrizio Balliano

    did you put that in the application's constructor? it can't fail if it's there… i tried it and all the cache files are stored were i configured the way i told you..

     
  • croaker___

    croaker___ - 2010-09-14

    Balliano

    I added the code to my application constructor on my local server, created a cache directory and pointed the constructor to it. It worked as expected and cache files appeared in the cache directory.

    I uploaded the working system to my ISP. Used phpinfo() to discover the full server path and used that as the basis for my cache directory path. The fatal error appeared and no cache files arrived in the cache directory. Access rights were set to 777.

    I agree, it seems a bit odd. I'll poke around a little more…

     

Log in to post a comment.