Opened 5 years ago

Closed 5 years ago

#632 closed Bug (fixed)

Local mods to Zend Framework should be subclassed

Reported by: tom67 Owned by: matt
Priority: normal Milestone: Piwik 0.4.4
Component: Core Keywords:
Cc: Sensitive: no

Description (last modified by vipsoft)

i have tried to use piwik in a zend framework project so i have copy the example on the Calling the API From within PHP page and paste it in a zf controller
after hacking the include_path to avoid 'cannot redeclare class exception' (see #631)

then i got the following error :

Fatal error: Call to undefined method Zend_Db_Adapter_Pdo_Mysql::resetConfigArray() in D:\WORK\SITES WEB\JC2\SRC\lib\piwik\core\Piwik.php on line 1184

--> Piwik::createDatabaseObject( )    ..\FrontController.php:234

Matthieu said on the forum that's because resetConfigArray() is a custom method from piwik, but now the classes are added from the standart library used for the whole project.
i suggest any custom method like this one to be moove in new classes extending the original classes (eg Zenwik_Db_Adpater)

while looking at this i also noticed that piwik is using Zend_Registry to store data throw the process.
Any user using already zf will surely use Zend_Registry too so every entry in it should be prefixed to avoid scope issue

Zend_Registry::set('piwik_config',$config)

maybe something similar should be done for zend_session and zend_auth

PS : maybe same pb can happen with other third party librarys (smarty is used a lot too ...)

Change History (12)

comment:1 Changed 5 years ago by matt (mattab)

(In [1030]) - renaming all constants that were not prefixed by PIWIK_ refs #632

comment:2 Changed 5 years ago by vipsoft (robocoder)

  • Milestone set to RobotRock

comment:3 Changed 5 years ago by vipsoft (robocoder)

  • Milestone changed from RobotRock to Stable release

co-depends in #497

comment:4 Changed 5 years ago by vipsoft (robocoder)

  • Summary changed from Problems when using piwik inside ZF project to Local mods to Zend Framework should be subclassed

comment:5 Changed 5 years ago by vipsoft (robocoder)

  • Milestone changed from 4- Stable release to 2- DigitalVibes
  • Sensitive unset

comment:6 Changed 5 years ago by vipsoft (robocoder)

  • Description modified (diff)

Adding resetConfigArray() to Zend_Db_Adapter_Abstract is much cleaner/simpler than subclassing all the adapters and changing the factory to use our subclassed adapters. I'll add a method_exists() check.

comment:7 Changed 5 years ago by vipsoft (robocoder)

  • Owner set to vipsoft

comment:8 Changed 5 years ago by vipsoft (robocoder)

  • Milestone changed from 2- DigitalVibes to 1 - Piwik 0.4.4

comment:9 Changed 5 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from new to closed

In [1453], check that resetConfigArray() method exists

comment:10 Changed 5 years ago by matt (mattab)

  • Resolution fixed deleted
  • Status changed from closed to reopened

I think we might be able to call _construct() with empty parameter, rather than having to keep the hack ->resetConfig()

I will investigate

comment:11 Changed 5 years ago by matt (mattab)

  • Owner changed from vipsoft to matt
  • Status changed from reopened to new

comment:12 Changed 5 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from new to closed

In [1465], fixes #632 - move local mods to subclassed ZF classes; the duplication in Db/Mysqli.php and Db/Pdo/Mysql.php is unavoidable because PHP doesn't support multiple inheritance

Note: See TracTickets for help on using tickets.