An unexpected error occurred. Using $this when not in object context error in Concrete 5 on PHP 5.6
Permalink 1 user found helpful
I am running a legacy version of Concrete 5 from 2012 and I am experiencing an issue out of the blue on every page load where I get the following error:
An unexpected error occurred.
Using $this when not in object context
This is the code creating the error, or at least the calling code:
When I dump $v out with var_dump I get this:
Unfortunately my cheapo host have a bug in their cPanel meaning I can't access the error logs to see what this error actually is, line number, class etc.
Is this a common issue? I am assuming my host have upgraded PHP (currently 5.6.23) and this has broken my install as I haven't touched Concrete 5 since fixing a bug in May last year.
Thanks.
An unexpected error occurred.
Using $this when not in object context
This is the code creating the error, or at least the calling code:
## now we display (provided we've gotten this far) $v = View::getInstance(); $v->render($c);
When I dump $v out with var_dump I get this:
object(View)#4 (8) { ["viewPath":"View":private]=> NULL ["controller"]=> NULL ["headerItems":"View":private]=> array(0) { } ["footerItems":"View":private]=> array(0) { } ["themePaths":"View":private]=> array(8) { ["/dashboard"]=> string(9) "dashboard" ["/dashboard/*"]=> string(9) "dashboard" ["/page_forbidden"]=> string(8) "concrete" ["/page_not_found"]=> string(8) "concrete" ["/install"]=> string(8) "concrete" ["/login"]=> string(8) "concrete" ["/register"]=> string(8) "concrete" ["/maintenance_mode"]=> string(8) "concrete" } ["areLinksDisabled":"View":private]=> bool(false) ["isEditingEnabled":"View":private]=> bool(true) ["error"]=> string(0) "" }
Unfortunately my cheapo host have a bug in their cPanel meaning I can't access the error logs to see what this error actually is, line number, class etc.
Is this a common issue? I am assuming my host have upgraded PHP (currently 5.6.23) and this has broken my install as I haven't touched Concrete 5 since fixing a bug in May last year.
Thanks.
What version of 5.6 exactly are you using?
$v looks like it is an object, so maybe $c is not an object.
$c is usually set to the current collection/page, but not in all contexts.
Try dumping $c. If it is not an object, you can try
This will only work once the page is established, so won't work (for instance) in an on_start() handler.
$c is usually set to the current collection/page, but not in all contexts.
Try dumping $c. If it is not an object, you can try
$c = Page::getCurrentPage();
This will only work once the page is established, so won't work (for instance) in an on_start() handler.
The upgrade of Concrete 5.5 was proving to be a nightmare so I asked my host to rollback my PHP version to 5.6. Luckily the cPanel allowed me to do it.