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

Error when running PHP via the command line: Call to a member function url() on a non-object #34

Closed
henare opened this issue Jan 5, 2015 · 9 comments

Comments

@henare
Copy link

henare commented Jan 5, 2015

PHP Fatal error: Call to a member function url() on a non-object in /var/www/wp-content/plugins/redirection/modules/wordpress.php on line 49

I'm guessing this is something to do with other plugins on my install. CiviCRM leaps to mind :(

@johngodley
Copy link
Owner

What version are you running? That error refers to a line of code that doesn't exist!

@henare
Copy link
Author

henare commented Jan 7, 2015

Thanks for the plugin and reply John!

What version are you running?

The latest from the WordPress directory: Version 2.3.11

That error refers to a line of code that doesn't exist!

Here's the line at that version:

if ( $part[0] == str_replace( get_bloginfo( 'url' ), '', $redirection->url() ).'/ajax.php' || strpos($url, 'wp-cron.php' ) !== false )

Manually upgrading to 2.3.12 makes this exception get thrown instead when running via the command line:

PHP Fatal error: Call to a member function hasMatched() on a non-object in /var/www/wp-content/plugins/redirection/modules/wordpress.php on line 27

Which is this line: https://github.com/johngodley/redirection/blob/2.3.12/modules/wordpress.php#L27

@johngodley
Copy link
Owner

How are you running WordPress via the command line? The error isn't thrown when the plugin runs normally so something must be happening differently from the CLI

@henare
Copy link
Author

henare commented Jan 8, 2015

It's CiviCRM scheduled jobs. When trying to run the scheduled job it throws the exception above.

@soulseekah
Copy link

Same error here when running with wp-cli, trying to figure it out. And, no, I don't have Civi installed.

@soulseekah
Copy link

Directly related to: wp-cli/wp-cli#2289

@soulseekah
Copy link

Adding global to $redirection = in the last line of redirection.php fixes this error. WP-CLI is able to import the variable into the scope only when explicitly set as global.

@pj-dave
Copy link

pj-dave commented Jul 25, 2016

@johngodley is this something you can fix? It's a shame to have to add --skip-plugins to every single WP-CLI command. I'm happy to create a pull request if you prefer, though @soulseekah's solution in the comment above is simple enough. Thanks!

@johngodley
Copy link
Owner

Sorry for the length of time between replying. The code has changed significantly since this bug was raised and I don't think it applies any more. I'm closing it for now, but please reopen if its still a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants