Zend framework 1.11.11 with PHP 5.4 error - zend-framework

I am getting below error while accessing by website having PHP 5.4 version running on REHL-7 with Zend framework as 1.11.11.
Can anyone help in resolving the below issue.
Error::
"Argument 1 passed to Zend_View_Helper_Navigation_HelperAbstract::setAcl() must be an instance of Zend_Acl, boolean given, called in /var/www/html/amov/library/Buza/Controller/Plugin/Navigation.php on line 48 and defined', '/var/www/html/amov/library/Zend/View/Helper/Navigation/HelperAbstract.php', 333"
Code in Navigation.php file:
$view = $layout->getView();
$view->navigation($navigation)
->pikeMenu()
->setACL(Zend_Registry::get('acl'))
->setRoles(Zend_Auth::getInstance()->getIdentity()->getRoles());
Code in HelperAbstract.php file:
public function setAcl(Zend_Acl $acl = null)
{
$this->_acl = $acl;
return $this;
}

Related

SuiteCRM v7.10.29 Custom API v4.1

I am creating a custom API for SuiteCRM. When I attempt to run the new API from {CRM Home}/custom/service/v4_1_custom I receive an 'HTTP ERROR 500'. There are not errors in the error_log file or the SuiteCRM.log file.
I have followed the method in the following two url's
https://fayebsg.com/2013/05/extending-the-sugarcrm-api-updating-dropdowns/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.0/Integration/Web_Services/Legacy_API/Extending_Web_Services/
registry.php
<?php
require_once('service/v4_1/registry.php');
class registry_v4_1_custom extends registry_v4_1
{
protected function registerFunction()
{
parent::registerFunction();
$this->serviceClass->registerFunction('test', array(), array());
}
}
SugarWebServicesImplv4_1_custom.php
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('service/v4_1/SugarWebServiceImplv4_1.php');
class SugarWebServiceImplv4_1_custom extends SugarWebServiceImplv4_1
{
/**
* #return string
*/
public function test()
{
LoggerManager::getLogger()->warn('SugerWebServiceImplv4_1_custom test()');
return ("Test Worked");
} // test
} // SugarWebServiceImplv4_1_custom
I found the answer to this issue.
In the file {SuiteCRM}/include/entryPoint.php there are many files that are included thru require_once. In this list of require_once files, there were 4 files that were set as require not require_once. These were classes and therefore could not be included a second time. I changed these to require_once and the HTTP Error 500 went away and the custom APIs started working.

Problem deploying Zend Framework website: doesn't find the classes

I'm trying to deploy a website made with the Zend Framework. The website is running fine on my local environment, I'm trying to deploy it on my VPS. But I'm running into some difficulties.
Now it says the following:
*Fatal error: Class 'Doctrine_Manager' not found in /is/htdocs/wpxxxxx/www/mensenenjij/application/Bootstrap.php on line 12*
It properly includes the Doctrine classes but it can't instantiate a new Doctrine_Manager. Anybody knows why?
Bootstrap.php:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctrine()
{
require_once 'Doctrine/Doctrine.php';
$this->getApplication()
->getAutoloader()
->pushAutoloader(array('Doctrine', 'autoload'), 'Doctrine');
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(
Doctrine::ATTR_MODEL_LOADING,
Doctrine::MODEL_LOADING_CONSERVATIVE
);
$config = $this->getOption('doctrine');
$conn = Doctrine_Manager::connection($config['dsn'], 'doctrine');
return $conn;
}
}

Test protected methods of ZF controllers with PHPUnit

I want to test a protected method which is inside a controller:
class AuthenticateController extends Zend_Controller_Action
{
protected function getAuthAdapter(){}
}
My test (following this post) look like this:
public function testGetAuthAdapterShouldReturnZendAuthAdapterDbTable()
{
require_once(APPLICATION_PATH.'/controllers/AuthenticateController.php');
$method = new Zend_Reflection_Method('AuthenticateController',
'getAuthAdapter');
$class = new AuthenticateController();
$result = $method->invoke($class);
// assert result value
$this->assertInstanceOf('Zend_Auth_Adapter_DbTable', $result);
}
When I execute the test, I got this runtime exception
RuntimeException: Fatal error: Call to a member function getModuleName() on a non-object in /Users/padawan_rodrigo/Documents/workspace/ZendFramework-1.11.5/library/Zend/Controller/Action/Helper/ViewRenderer.php on line 226
Call Stack:
0.0030 396924 1. {main}() -:0
0.0755 4593044 2. __phpunit_run_isolated_test() -:207
0.0771 4718524 3. PHPUnit_Framework_TestCase->run() -:22
0.0785 4798460 4. PHPUnit_Framework_TestResult->run() /usr/local/pear/share/pear/PHPUnit/Framework/TestCase.php:576
0.3565 4827948 5. PHPUnit_Framework_TestCase->runBare() /usr/local/pear/share/pear/PHPUnit/Framework/TestResult.php:666
0.6696 10508956 6. PHPUnit_Framework_TestCase->runTest() /usr/local/pear/share/pear/PHPUnit/Framework/TestCase.php:628
0.6697 10509780 7. ReflectionMethod->invokeArgs() /usr/local/pear/share/pear/PHPUnit/Framework/TestCase.php:738
0.6697 10509796 8. AuthenticateControllerTest->testGetAuthAdapterShouldReturnZendAuthAdapterDbTable() /project/code/tests/application/controllers/AuthenticateControllerTest.php:0
0.6794 10753940 9. Zend_Controller_Action->__construct() /project/code/tests/application/controllers/AuthenticateControllerTest.php:172
I also tried to mock the class with same results. Any ideas?
Thanks
You need to pass in a request and response to the controller's constructor.
$class = new AuthenticateController(
new Zend_Controller_Request_HttpTestCase(),
new Zend_Controller_Response_HttpTestCase()
);

Zend framework ignores custom helper path in application.ini

I have my view helper in Library/My/View/Helper/LoadSkin.php, I added this line in application.ini : resources.view.helperPath.My_View_Helper = "My/View/Helper" but I'm still getting
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message
'Plugin by name 'LoadSkin' was not found in the registry; used paths: Zend_View_Helper_: Zend/View
/Helper/;C:/Program Files (x86)/Zend/Apache2/htdocs/TinOuzel/application/views\helpers/'
This looks like ZF stills looks for helper in default path ;/
My namespacje is registered in bootstrap:
protected function _initAutoloader ()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
$autoloader->suppressNotFoundWarnings(true);
return $autoloader;
}
in this case , you must had overridden the default view object
in much clear example , you are using something like :
$view = new Zend_View();
mostly somewhere in your bootstrap file , just remove it and you would be okay

Unit Testing with PHPUnit & Doctrine2: Autoloading Failed

I am getting this error
D:\Projects\Tickle\tests>phpunit
PHPUnit 3.5.5 by Sebastian Bergmann.
..........ok1
Fatal error: Doctrine\Common\ClassLoader::loadClass(): Failed opening required 'D:\Projects\Tickle\Application\Models\Ap
plication\Models\User.php' (include_path='D:\Projects\Tickle\application/../library;D:\Projects\Tickle\application;D:\Pr
ojects\Tickle\library;D:\ResourceLibrary\Frameworks\PHPFrameworks;C:\Program Files (x86)\PHP\pear;.;c:\php\includes') in
D:\ResourceLibrary\Frameworks\PHPFrameworks\Doctrine\Common\ClassLoader.php on line 148
Notice its repetition "D:\Projects\Tickle\Application\Models\Application\Models\User.php" of Application\Models. I narrowed it down to 1 function of my unit tests with the help of some echo statements
protected function isAllowed($userId, $taskId, $privilege) {
$user = $this->em->find('Application\Models\User', $userId);
echo 'ok1'; // this gets printed
$task = $this->em->find('Application\Models\Task', $taskId); // this seem to be the cause of the problem
echo 'ok2'; // this doesn't get printed
return $this->acl->isAllowed($user, $task, $privilege);
}
The full class http://pastebin.com/rJungFvP
So I tried looking of something in the Tasks class that uses User ... the only thing that might use the User class are
/**
* #ManyToOne(targetEntity="User", inversedBy="ownedTasks")
*/
protected $owner;
/**
* #ManyToOne(targetEntity="User", inversedBy="assignedTasks")
*/
protected $assigned;
apart from that, I don't see use of any Users. full class http://pastebin.com/wDPXUPSV.
What did I do wrong?
The problem was actually found in the TodoList class ... I had something like
public function setProject(Application\Models\Project $project) {
...
}
when I should be using something like
public function setProject(Project $project) {
$this->project = $project;
}
instead