When navigating between CakePHP plugins I get an error - php

I am consistently getting an error when navigating between CakePHP plugins (that I coded).
I bootstrap them like this:
CakePlugin::loadAll(array(
'OneTime' => array('bootstrap' => true),
'Mango' => array('bootstrap' => true),
'Intercape' => array('bootstrap' => true)
));
I link to them like this:
echo $this->Html->link($image,array('plugin'=>'intercape','controller'=>'tickets','action'=>'StepOne','agent'=>FALSE),array('escape'=>FALSE));
echo $this->Html->link($image,array('plugin'=>'mango','controller'=>'tickets','action'=>'StepOne','agent'=>FALSE),array('escape'=>FALSE));
I can clear my cache and navigate to a plugin, but if I use a link like the following one to go to the home page then the next time I try to click the other link I get a bug.
Clicking this link
echo $this->Html->link($image,array('plugin'=>'','controller'=>'agentusers','action'=>'dashboard','agent'=>TRUE), array('escape'=>FALSE));
gives this bug the next time I click the Intercape link (not the Mango link)
Fatal error: Class 'MangoAppController' not found in /var/www/mtn/app/Plugin/Mango/Controller/TicketsController.php on line 12
I have checked that Intercape does not reference Mango anywhere. Clearing my cache lets me click Intercape and use the plugin, but then Mango won't work.

It turns out that the problem was in using the same controller name in different plugins.
Cake was caching where to look for controller source across plugin requests and so was looking for the wrong code.
Renaming the controller solved the problem, but made the URL's a bit messy :(

Related

How to add comments to each forum post in yii, using bbii forum module and comments-module

I am using Yii bbii forum module and it works fine. But now I want to add comments-module so every forum post could be seperately commented.
At the begining it might look:
I followed instruction what is here, but I can't make it work :(
And why I even need to include this file, if I want to add just comment?
When I added the same widget to user page (just for testing) - I got "This item cann't be commentable" and it's fine because probably I don't have correct configuration in main.php.
Difference between widget in user model view and forum view is data passed in it.
Here:
public function actionPostComment()
{
if(isset($_POST['Comment']) && Yii::app()->request->isAjaxRequest)
{
$comment = new Comment();
$comment->attributes = $_POST['Comment'];
var_dump($comment);
var_dump returned this when tried to submit comment in forum, and here in user view page.
And probably it is not even possible to combine these to modules? I'm really new in Yii.
Updated:
Basically what I have done is:
exstracted comment module (under protected->modules)
in main.php (under protected->config) added all cofiguration in modules array:
'comments'=>array(
//you may override default config for all connecting models
'defaultModelConfig' => array(
//only registered users can post comments
'registeredOnly' => false,
'useCaptcha' => false,
.......
and in view file _post.php added following:
<?php $this->widget('comments.widgets.ECommentsListWidget', array(
'model' => $data,
));
and var_dump($data) gives this (when this is called in controller where post is reseaved).
An error message was given here:
include(BbiiPost.php): failed to open stream: No such file or directory
You said that the Bbii was working with Yii and it broke when you tried to add comments.
The links to your var_dump files are broken, but I did try to read them ;)
It looks like the comments module is interfering with the POST path so that when the form submission comes in it is in a different path from the root which is confusing the YiiBase's autoloader.
You could try explicitly adding the path to BbiiPost.php to the autoloader's search path, or finding where the include("BbiiPost.php") line is and changing it to an absolute path.
Another possibility is that the forum page you are on has links to add comments but the page routing has not been taken from the route. So it might be that the POST link to the comments is actually at /forum/123/comment/add instead of just /comment/add. So when the form is submitted it is trying to the comments/add controller/action but finding that it is in /forum/view and getting confused about the paths to the include files.
I have generally found that the instructions on the Yii (v1) [v2 docs are much better] site for these modules is flaky at best. Quite often the source download link on the page points to an old buggy version of the code as the project has usually moved somewhere else. You generally need to have a pretty good PHP/Yii knowledge to debug these user-submitted modules and get them working.

Why can't an anonymous user see the xhprof link at the bottom if permission is set?

I set the permissions so that anonymous users can see xhprof but I can't seem to see the link at the bottom of the page when the page loads. I am able to view the page /admin/reports/xhprof/ as anonymous but just can't get the link to appear. I am sure it isn't hidden because I can't find it in Firebug.
I tried flushing the cache and running cron but still no luck.
I added a print_r to the following part of the xhprof code and I get some weird character response. So it leads me to believe that it is a problem somewhere with drupal_register_shutdown_function.
function xhprof_boot() {
// Initialize XHProf.
if (xhprof_xhprof_enable()) {
print_r(drupal_register_shutdown_function('xhprof_shutdown'));
}
}
I get a response of weird characters:
Array ( [0] => Array ( [callback] => xhprof_shutdown [arguments] => Array ( ) ) )
����r�H�0xmE�;T��mI� <��d�=�N�[��d�n�F(��##It��{���#���ͣ̓lfU�D$(QRwR�%�CfVVVfVV֫����?�쐞
�7�ɻ��[$� ��Ba�|�|xs~x����]JJ�b��s�#��������u�����n�:��l�Q���G�P���<-�
.....
.....
Fatal error: Call to undefined function drupal_get_path_alias() in
.../includes/common.inc on line 2250
Weird thing is I do have an older database of my site and the problem doesn't happen. Only happens on my production database copy of my site.
I tried commenting out every function that calls drupal_register_shutdown_function or register_shutdown_function but I can't seem to find what is causing the problem on my site.
I was able to fix my issue by going to Configuration -> Development and unchecking "Compress cached pages". This way I able to clear the cache and view the page as anonymous and see the link.
If I try to view the page the second time (since it is cached). I get this error below: Fatal error: Call to undefined function url() in .../sites/all/modules/xhprof/xhprof.module on line 190. I think that the xhprof was just meant to be viewed on on uncached pages.

Call to member function getResourceId() on non object - Magento CE

Firstly I'd like to apologise in advance if this is a stupid question - Although I have been writing PHP for the last 12 years, I work on bespoke applications and have only been using Magento for the last hour, so I'm clueless on its structure. If possible I'd like to avoid having to dig too much into Magento as the entire reason why I'm using Magento is to save time.
Anyway, the error:
Call to a member function getResourceId() on a non-object in /var/www/[site]/lib/Zend/Acl.php on line 1174
This error occurred after attempting to log in to the administration area immediately after install. The error is in the &_getRules method in lib/Zend/Acl.php.
So, I did a little digging and $resource (the variable it is attempting to call the &_getRules method on) is actually an array - which I found odd as the this is the method definition:
protected function &_getRules(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null, $create = false){
So, to verify that I wasn't actually losing my mind I wrote the following as the first line of the &_getRules method
if($resource!==null&&!$resource instanceof Zend_Acl_Resource_Interface){
die('<pre>'.print_r($resource,1).' </pre>');
}
Which printed:
Array
(
[G1] => Array
(
[instance] => Mage_Admin_Model_Acl_Role_Group Object
(
[_roleId:protected] => G1
)
[parents] => Array
(
)
[children] => Array
(
[U1] => Mage_Admin_Model_Acl_Role_User Object
(
[_roleId:protected] => U1
)
)
)
[U1] => Array
(
[instance] => bea423c23f6343e2b509fb192a00826f:3EOt7Vo0agtENPH8Wm73EOelgSDoDxYO
[parents] => Array
(
[G1] => Ryan
)
[children] => Array
(
)
)
)
So yeah, i guess my question comes in four parts:
Why doesn't this work out of the box?
Am I just being an idiot?
Why isn't PHP preventing this method from running considering the $resource variable is neither a Zend_Acl_Resource_Interface or null?
How do i fix it?
I should mention that this is a local test site, running on Ubuntu 12.04, Apache 2.4.9 (likely to be nginx in production though), PHP 5.5.12, Magento CE 1.9.0.2.
Thanks in advance,
Ryan
/*************************UPDATE*********************************/
Hi again everyone,
So I've noticed there is a pattern to how this problem/bug/whatever comes around. So, this is my admin url:
http://magento.example.local/admin_system/
If I go to this url, I am able to login and then this issue happens. At this point the url is now
http://magento.example.local/index.php/admin_system/[some_irrelevant_stuff]
So this is where it gets odd. If I then navigate to the original url I am once again redirected to the second url but the beginning of [some_irrelevant_stuff] is /index/denied/ (which I assume is relevant now haha).At this point I am provided the header of the Magento admin panel and I am able to logout.
OK so thats one part of the issue. If I then logout, or if I start my login process at /index.php/admin_system/ then I am able to log in and use the admin area as usual. So, the long and short of it is, I don't know what's going on but I'm hoping this extra info might get me more details.
Thanks for your time,
Ryan
Wow, I am genuinely surprised that nobody had an answer for this. Anyway, the following details are not so much an explanation as to what caused this issue, but a solution to stop it happening.
So, as you'll see from the edit of my question, I noticed that this seemed to have a bizarre connection to the URL and using different URLs to access the admin area (eg. /index.php/admin instead of /admin) caused different errrors. So for this reason, and because having index.php in all my admin area URLs, I took a look into rewriting the admin URLs. This is made available using this plugin: http://www.magentocommerce.com/magento-connect/admin-rewrites.html
If I'm not mistaken, I did not need to make any changes to the RewriteRule(s) that are set by default by magento so following the instructions on the plugin page above should work.
Either way, this appears to resolve the issue so I hope it helps someone having similar issues.

CakePHP cache i18n translate

When I forget to translate something, somewhere Project VIEW, I change the file /app/Locale/por/LC_MESSAGES/default.po and sending it back to the server.
But mostly, this 'new translation', takes HOURS to be viewed, in short: I just send the file, cleaned the cache and browser CakePHP, press F5, and ... NOTHING HAPPENS.
For what reason?
[EDIT]
<?php echo $this->Form->input('Item.0.description', array('label' => false,
'class' => 'span12', 'div' => array('class' => 'span7'), 'rows' => 3,
'placeholder' => __('Type the description'))); ?>
To force the language to update you can clear the persistent and models directories in the /tmp/cache directory. If view caching is enabled you'll have to clean out views as well.
Caching is disabled when debug is set to 2 (which is the value for using the framework during development) and the persistent directory is populated with new cache files, overwriting the old ones each time a view is loaded. So the debug switch and subsequent browser refresh might clean the old language files for you.
I found a strange solution:
I set (app/Config/core.php)...
Configure::write('debug', 2); // It was 0
Press, F5... wait... and works.
Later, I back...
Configure::write('debug', 0);
Press F5 again, and works.
Why? I no have idea.
Even if Configure::write('debug', 2); I recommend to delete the remote folder containing the translations, refresh with browser (to state that nothing is translated anymore) then reupload the translations folder.
Works perfectly that way for me.

facing cache issue in activecollab routers

I am developing activecollab custom module; facing an issue related to Routers.
I by mistake type wrong action name in Router's action where we need to define in router, but after getting error I updated that action name but activecollabs still reading a previous action i removed files from cache and complie folders but reading previous action.
please share if you ever face this problem in development of activecollab module..
By mistake I did this: (action=>'views')
Router::map('mymodule_view', 'mymodule/view/:request_id', array('controller' => 'mymodule', 'action' => 'views' ), array('req_id' => Router::MATCH_ID) );
but after getting error i update above code by this: (action=>'views')
Router::map('mymodule_view', 'mymodule/view/:request_id', array('controller' => 'mymodule', 'action' => 'view' ), array('req_id' => Router::MATCH_ID) );
First, make sure that your system is in development mode. Open config/config.php and confirm that APPLICATION_MODE is set to in_development:
define('APPLICATION_MODE', 'in_development');
Now that you have that covered, go to activeCollab and you'll have Developer toolbar available in the lower right corner of the application interface, next to activeCollab powered button (it has a red bug icon). Use this tool to clear cache, rebuild images etc.
PS: You can also clear all files from /cache folder, just in case.

Categories