Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: $this Not in Object Context #581

Closed
jaswrks opened this issue Oct 3, 2015 · 5 comments
Closed

Bug: $this Not in Object Context #581

jaswrks opened this issue Oct 3, 2015 · 5 comments
Labels
bug
Milestone

Comments

@jaswrks
Copy link

@jaswrks jaswrks commented Oct 3, 2015

Overview

These lines, see: https://github.com/websharks/zencache-pro/blob/151002/src/includes/closures/Plugin/WcpUtils.php#L89-L91

And these lines, see: https://github.com/websharks/zencache-pro/blob/151002/src/includes/closures/Plugin/WcpUtils.php#L44-L46

$this should be $self due to the PHP 5.3 compat. framework and closures. We use $self as a workaround in this context, and therefore, $this is not valid as expected.

First reported here in a private ticket: https://websharks.zendesk.com/agent/tickets/8697

@jaswrks jaswrks added the bug label Oct 3, 2015
@jaswrks
Copy link
Author

@jaswrks jaswrks commented Oct 3, 2015

I should note also that instead of $this->plugin-> it should just be $self->. So we need to change $this to $self and remove the ->plugin reference also.

@raamdev
Copy link
Contributor

@raamdev raamdev commented Oct 3, 2015

Example of error related to this issue:

Fatal error: Using $this when not in object context in /home/example/www/wp-content/plugins/zencache-pro/src/includes/closures/Plugin/WcpUtils.php on line 89

@jaswrks
Copy link
Author

@jaswrks jaswrks commented Oct 3, 2015

Fatal error: Using $this when not in object context

I am able to reproduce this, but only on PHP 5.3. It seems the most recent versions of PHP are magically allowing $this to work outside of object context; i.e., via an include. That's definitely an unexpected behavior, and yet I am happy that it works to reduce the impact this bug is having.

So this issue is currently PHP 5.3-specific.

@raamdev raamdev added this to the Next Release (Pro) milestone Oct 3, 2015
@raamdev raamdev mentioned this issue Oct 3, 2015
raamdev added a commit to wpsharks/comet-cache-pro that referenced this issue Oct 3, 2015
@raamdev
Copy link
Contributor

@raamdev raamdev commented Oct 4, 2015

@raamdev raamdev closed this Oct 4, 2015
@raamdev
Copy link
Contributor

@raamdev raamdev commented Oct 4, 2015

Next Pro Release Changelog:

  • Bug Fix: Fixed a bug introduced in the previous release that was resulting in a "Fatal error: Using $this when not in object context" for sites running PHP 5.3. (PHP 5.4+ sites were unaffected.) Props @jaswsinc. See Issue #581.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants