CakePHP ACL/ACO errors - php

I get the following error when viewing my home page for my CakePHP website:
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 1
[username] => admin#test.com
[group_id] => 1
[created] => 2008-07-05 17:16:58
[modified] => 2008-07-05 17:16:58
)
)
Aco: controllers/Pages/display [CORE/cake/libs/controller/components/acl.php, line 273]
Warning (2): Cannot modify header information - headers already sent by (output started at /Users/cameron/Sites/cakeapp/cake/libs/debugger.php:673) [CORE/cake/libs/controller/controller.php, line 742]
What is the problem(s)? Thanks

First, did you create the ACO/ACL tables in the database. (usually in /config/sql). Next, your user probably needs the ACO/ACL foreign keys, so you'll probably have to modify your user table.
see this tutorial for more information:
http://lemoncake.wordpress.com/category/authorization/

I recall getting errors like this, but unfortunately can't remember specific solutions. It came down to perseverance and tweaking. Try debug() on everything you can think of and you'll begin to get the picture.
If you followed the tutorial I posted earlier, start it again, double checking everything. It isn't a straightforward component/behaviour but Mark documents it well.
Stick with it!

Related

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.

Drupal 7.23 warning and error messages when open page

Drupal 7.23 When I open page (as anonymous user), I periodically get warning and error messages. The duplicate of header logo appears in the end of page, right above error messages.
I can't understand conditions when appears this warning & error, but it seems it appears when I open page as anonymous user. Then after logging in, logging out, no any errors shown anymore.
warning:
Warning: Cannot modify header information - headers already sent by
(output started at
/home/ztiw7851207/public_html/includes/common.inc:2700) in
drupal_send_headers() (line 1220 of
/home/ztiw7851207/public_html/includes/bootstrap.inc).
Warning: Cannot modify header information - headers already sent by
(output started at
/home/ztiw7851207/public_html/includes/common.inc:2700) in
drupal_send_headers() (line 1216 of
/home/ztiw7851207/public_html/includes/bootstrap.inc).
error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062
Duplicate entry '' for key 'title': INSERT INTO {aggregator_feed}
(fid, url, link, description, image, hash, etag, modified) VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4, :db_insert_placeholder_5,
:db_insert_placeholder_6, :db_insert_placeholder_7); Array (
[:db_insert_placeholder_0] => 9 [:db_insert_placeholder_1] =>
http://hitech.com/rss/reviews/ [:db_insert_placeholder_2] =>
http://hitech.com/reviews/ [:db_insert_placeholder_3] => News, reviews
and opinion outlet with obsessive coverage of cutting edge gadgets,
consumer electronics and the science and technology they're built
upon. [:db_insert_placeholder_4] =>
http://hitech.com/img/rss_cover.png [:db_insert_placeholder_5] =>
1d37c01e3b1346cc3ac3dbf1280c3fd236c3f3433e1d44a4902066a9f3d87cbe
[:db_insert_placeholder_6] => [:db_insert_placeholder_7] => 0 ) in
aggregator_refresh() (line 640 of
/home/ztiw7851207/public_html/modules/aggregator/aggregator.module).
How to solve this issues?
Issue may be due to the aggregator_feed module try to uninstall and re install it, if you are using Drush
drush dis aggregator_feed && drush en aggregator_feed

CakePHP excel download troubleshooting

I'm trying to follow this solution to export data to excel but when I click the download link it just says "Server Error. May be down for maintenance....etc"
The only thing I had to change from the tutorial is the name of the Csv helper. The tutorial specifies "Csv.php" but I had to name it "CsvHelper.php". When I print the variable that goes to this view, it displays the array. However, when I remove this and just have the code listed exactly as it appears in that linked post from above I get a server error
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
These are the files that I had to add to my server as directed by the "tutorial"
//Helper
/App/View/Helper/CsvHelper.php
//Vendor
/App/Vendor/excel/PHPExcel.PHP
/App/Vendor/excel/PHPExcel/ //contains the rest of PHPExcel
//view
/App/View/Orders/download.ctp //Tutorial specifies /App/View/Homes/download.ctp so I made sure to change the link accordingly in the view which actually "links" to this
As I mentioned previously when I print the array on download.ctp see this
Array ( [0] => Array ( [Order] => Array ( [id] => 1 [userid] => 2 [order_status] => completed [email] => test#gmail.com [total] => 8.00 ) )
My array's structure matches that of the tutorial which is
$orders[0]['Order'];
Is there something I have to configure with CakePHP for downloading files? I have no idea where to go from here.
Outputting different types of content in cake 2.x is now easy and a "piece of cake" :)
View classes can easily be switched to whatever output you need (json, xml, csv, ..).
In your case I would use https://github.com/josegonzalez/CsvView .
$this->viewClass = 'CsvView.Csv';
and export the data as documented in the plugin readme.

How to manage single session on two different php scripts?

I have installed two different PHP scripts on my server. One on root and another on different sub-directory. However, I want the root phpscript's users session to be continued on another sub-directory script. I need this session to enable chat even on another directory script.
The sub directory is os-class.
I made a different PHP file on sub-directory to track session variables.
Array ( [user_email] => xxxx#example.com
[users_id] => 275
[first_name] => Sammy
[last_name] => Durha
[username] => 275
[mobile] => XXXXXXXXX
[chat_sms_sent] => message sent to off line friends. )
However on one of the script page the half session gets lost.
Array ( [messages] => Array ( )
[keepForm] => Array ( )
[form] => Array ( )
[chat_sms_sent] => message sent to off line friends. )
Can anyone please sort out the problem.
Thanks
Sessions are not tied to a directory. If you call session_start() at the top of both scripts, the $_SESSION variable should have the same content in both.
Session is independent of directories and files. It can be used universally. But remember that sessions are less secure.
You may follow a simple tutorial here.

Spoon-library acts different on localhost then on webhosting

I have a problem regarding the spoon-library (www.spoon-library.com). I have a folder with subfolders, each subfolder is a 'reference' from my dad his company. (although its translated to my native language). Each of the 'reference' subfolder contains images.
I am reading the names of al subfolders and the images that are in that specific folder and save it to an array. With the use of spoon-library i am nesting these in template variable in my tpl files. So basically I print the <h2></h2> with the project's title (the subfolder name), and all his images (so that they can be viewed through lightbox).
On my localhost and my website (provider A) it works, but when i upload it to my dad his hosting (provider B) it doens't work.
ex.
http://davyloose.be/electroloose/projecten.php -> it works.
http://electro-loose.be/projecten.php -> it doens't work.
The code is identical.
Example of the array with the data that i get through the folders (note, i get the same data on both webspace):
Array (
[0] => Array (
[title] => Apotheek Beerlandt
[images] => Array (
[0] => Array ( [url] => beerlandt 2.JPG )
[1] => Array ( [url] => beerlandt 3.JPG )
[2] => Array ( [url] => beerlandt 1.JPG )
)
)
)
This is entered in the following 'html' code (template file):
{iteration:referenties}
<h2>{$referenties.title}</h2>
<div id="imageslide">
{iteration:referenties.images}
<img src="/images/referenties/{$referenties.title}/thumbs/{$referenties.images.url}" />
{/iteration:referenties.images}
</div>
{/iteration:referenties}
Note: references in my native language is 'referenties'.
It seems that on my dad his webhosting a '.' changed to '->', although i'm not really sure (as in 'I can't believe that).
The php version on my localhost and my webhosting are PHP5.3.5, the version on my dad his hosting is 5.1.2.
I hope you guys can help me out on this one :).
PS: I know i can fix this with the use of an sql database. And i'm going to do that in the near future, but for now i just want to know why this error is occurring.
Thanks in advance!
Edit: I just enabled the display_errors in my php.ini and now i see the following error 'Notice: Undefined variable: count in /var/www/html/test/spoon/template/compiler.php on line 913' (and also on some other lines). Still, it's a mystery why it works on my localhost and not on my dad his host.
I'm the author of Spoon Library. I believe the issue lies with the differences in the PHP versions. The $count parameter that the notices are talking about were added in PHP5.1, but for some reason they don't seem to work exactly as expected in the PHP version on your dad's host.
I'd recommend to try and get the hosting to use at least PHP5.2, because there are another few issues that might occur within other spoon packages because of this.
If you need any more help you can always find me on twitter(#spoonlibrary) or e-mail me (davy#spoon-library.com)

Categories