I'm trying to schedule a simple event that should clear a transient daily at 23:59 UTC.
While investigating, I installed WP Crontrol as a debugging means. And noticed that my events were successfully added to the CRON custom events job task but were not firing, additionally I noticed the following error statement from WP Crontrol:
There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron events on your site may not work. The problem was:
cURL error 7: Failed to connect to localhost port 8080: Connection refused.
More information
I'm currently assuming that this is due to the fact that I'm developing on localhost.
Did anyone already encountered that type of issue, and what were the steps you took to fix it?
Just in case, following are my current scheduled event related functions.
/**
* Daily users_online transient clear
*/
if (! wp_next_scheduled ( 'wp_schedule_event_delete_transient_users_online' ) ) {
wp_schedule_event( strtotime( '23:59:00' ), 'daily', 'wp_schedule_event_delete_transient_users_online' );
};
add_action( 'wp_schedule_event_delete_transient_users_online', 'delete_transient_users_online' );
if ( ! function_exists( 'delete_transient_users_online' ) ) {
function delete_transient_users_online() {
delete_transient( 'users_online' );
};
};
Related
I'm using the following code. Assume $url is something like https://example.com/cron/cron.php. I'm getting the failure message, but it's actually working because in the linked script I send out an e-mail and I am receiving the e-mails.
So if it's working, then why is is_wp_error triggering?
if (is_wp_error($wp_remote_get = wp_remote_get($url))) {
echo "Failed to get script. Error: " . $wp_remote_get->get_error_message() . " Exiting...";
exit;
}
Got error: Failed to get script. Error: cURL error 28: Operation timed out after 5004 milliseconds with 0 out of -1 bytes received
So it was a bit of a silly issue. wp_remote_get retrieves the http response, but I thought it would just be visiting the url to run the script. The script takes a while to complete, so it must be running into time limits, which is what the error message seems to be suggesting.
I resolved this by just using wp_redirect instead. Would be nice if I can find a way to run the other script without redirecting though.
I'm trying to send logs into datadog using rsyslog. Ideally, I'm trying to do this without having the logs stored on the server hosting rsyslog. I've run into an error in my config that I haven't been able to find out much about. The error occurs on startup of rsyslog.
omfwd: could not get addrinfo for hostname '(null)':'(null)': Name or service not known [v8.2001.0 try https://www.rsyslog.com/e/2007 ]
Here's the portion I've added into the default rsyslog.config
module(load="imudp")
input(type="imudp" port="514" ruleset="datadog")
ruleset(name="datadog"){
action(
type="omfwd"
action.resumeRetryCount="-1"
queue.type="linkedList"
queue.saveOnShutdown="on"
queue.maxDiskSpace="1g"
queue.fileName="fwdRule1"
)
$template DatadogFormat,"00000000000000000 <%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% - - - %msg%\n "
$DefaultNetstreamDriverCAFile /etc/ssl/certs/ca-certificates.crt
$ActionSendStreamDriver gtls
$ActionSendStreamDriverMode 1
$ActionSendStreamDriverAuthMode x509/name
$ActionSendStreamDriverPermittedPeer *.logs.datadoghq.com
*.* ##intake.logs.datadoghq.com:10516;DatadogFormat
}
First things first.
The module imudp enables log reception over udp.
The module omfwd enables log forwarding over (tcp, udp, ...)
So most probably - or atleast as far as i can tell - with rsyslog you just want to log messages locally and then send them to datadog.
I don't know anything about the $ActionSendStreamDriver tags, so I can't help you there. But what is jumping out is, that in your action you haven't defined where the logs should be sent to.
ruleset(name="datadog"){
action(
type="omfwd"
target="10.100.1.1"
port="514"
protocol="udp"
...
)
...
}
I have the following fatal error when trying to use Curl GET Method using woocommerce rest api V3 in WordPress. I have try to set_time_limit(0) and also, try with wp_remote_get method of WordPress but not solve issue. this because I get errors and I'm not able to fix them. I've set the timeout to 30 seconds. Also with this settings I get a timeout error and getting null response from REST API.
Fatal error: cURL Error: Operation timed out after 30009 milliseconds with 0 bytes received
Anyone have suggestion to fix this?
I think the answer here is likely what you're looking for https://wordpress.stackexchange.com/a/346236/31838
Increase the request timeout with a http_request_timeout filter
function custom_http_request_timeout( ) {
return 90;
}
add_filter( 'http_request_timeout', 'custom_http_request_timeout' );
I am using Symfony and creating a soft with 3 tiers (client, apache, mysql). So I don't know how to get the statut when the symfony application persists and flushs something?
When I add something in database I display an alert like "Add done!" but if my database is down I will display "Add done" despite the fail...
So how can I get the statut of these functions (flush/persist)? How can I change my alert switch the statut?
Best regards,
Use a try & catch block:
try {
$article = new Article(); //Example entity
$em = $this->getDoctrine()->getEntityManager();
$em->persist($article);
$em->flush();
$this->get('session')->setFlash('flash_key',"Add done!");
} catch (Exception $e) {
$this->get('session')->setFlash('flash_key',"Add not done: " . $e->getMessage());
}
In case you get errors try using "\Doctrine\ORM\ORMException $e", \Doctrine\DBAL\DBALException $e" or "\Exception $e" inside catch()
My issue was that I was passing a complex object into a field that expected a string even though I had set that column up to be a ManyToOne. Apparently #ORM\Column overrode that.
However! It's not what the error was that's interesting, it's how I fixed it.
I was having a PDOException. I had to deep dive into the code with xdebug and PHPStorm. xdebug is supported by many PHP IDEs. xdebug is tough to set up the first several times that you set it up. There's always some firewall hassle or hassle getting it to show up in your phpinfo() or xdebug.enable_remote or xdebug.remote_host.
Get used to it. JUST DO IT! No seriously. Don't write another line of code in PHP until you have got xdebug working; even if you run into 8 million issues. You will save years of your life in coding.
I don't know about Symfony, but ZF3 now comes with a Vagrantfile. You install vagrant and Oracle VirtualBox, type vangrant up in your Zf3 project directory, and you have a fully-functional local web server running your ZF3 application at http://localhost:8080. From there all I had to do was:
... Well first, before I called vagrant up for the first time, I added the following line to the Vagrantfile
config.vm.network "private_network", ip: "192.168.33.10" ... then I called vagrant up
vangrant ssh
sudo -s
apt-get install php-xdebug
echo "xdebug.remote_enable = 1" >> /etc/php/7.0/apache2/php.ini
echo "xdebug.remote_host = 192.168.33.1" >> /etc/php/7.0/apache2/php.ini
apachectl restart
In your phpinfo(), you should see xdebug somwhere. Just ctrl + f for it. If it's there, you're mostly in business.
Then I added a rule for port 9000 on my firewall. Then I started an xdebug session. If it doesn't work You can temporarily shut down Windows Firewall just to check if it works, but remember to enable it right away and make sure it's not just the firewall. Setup a firewall rule for incoming on port 9000 and allow ip 192.168.33.10. If you don't know how to do this ... why are you trying to develop web software?
Learn to use xdebug!!!
I am using wordpress application with multisite concept. Also my web hosting working with mod_fcgid as a server API. At some instances the my site getting 500 internal server error. When I looked into the error log, it shows the repeated warning errors like "[warning] mod_fcgid: stderr: PHP Warning: Creating default object from empty value in /var/www/vhosts/mywjb.com/httpdocs/wp-includes/ms-load.php on line 113". How do I resolve this problem. Can any one help?
Thanks in advance,
My Web server was working with FCGI mode. So the FCGI processing with multiple PHP requests (wordpress), and the apache logging the FCGI related errors, when the requests gets failed with FCGI.
Below is my wordpress code,
111 global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
112 if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
113 $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
.........
I have fixed this issue by shifting the server mode from FCGI to CGI.
But compared to CGI, working with FCGI only most efficient and performance boosting technology.
Thanks