Posted: November 8, 2018 at 1:27 am
We have an application that generates massive one-use codes applied to an event. We have to generate 15,000 promo codes with a 100% discount. We have put the ticket limit at 20,000.
We are generating 2000 codes in 2000, but when we pass the 8,000 discount codes associated with an event, we are prevented from editing the event.
If you delete the codes inserted in wp_esp_promotion, wp_esp_promotion_object, wp_esp_price, the editing and creation of events works perfectly.
Is there a maximum limit of association of promotional codes to events or can they be limitations of our hosting server?
We have another open incident with this problem, but we have redirected it here once we have seen the causes of the error.
In WP-Debug we get the following error:
[07-Nov-2018 19:11:54 UTC] PHP Warning: mysqli_query(): MySQL server has gone away in /home/salonesgqb/www/wp-includes/wp-db.php on line 1924
[07-Nov-2018 19:11:54 UTC] PHP Warning: mysqli_query(): Error reading result set’s header in /home/salonesgqb/www/wp-includes/wp-db.php on line 1924
In the logs of the server:
I attach the information of Health Check:
### WordPress ###
### Installation size ###
Uploads Directory: 6.52 GB
### Active Theme ###
Name: Januas | Shared By showthemes.com
### Active Plugins (36) ###
Akismet Anti-Spam: Version 4.0.8 by Automattic
### Inactive Plugins (8) ###
Duplicator: Version 1.2.52 by Snap Creek
### Media handling ###
Active editor: WP_Image_Editor_Imagick
### Server ###
Server architecture: Linux 4.14.19-ovh-vps-grsec-zfs-classid x86_64
### Database ###
### WordPress Constants ###
### Filesystem Permissions ###
The main WordPress directory: Writable
We don’t have limits on the number of promotions, with a ‘MySQL server has gone away’ error your likely hitting a limitation of your hosting, but that may also mean we need to alter something with our queries.
We’ll need to so do some digging into this, may I ask, how are you creating the promotion codes currently?
While creating or editing an Event, seems like the program is reading all promotions and prices. This makes the program more slow in time, while promotions are growing in number.
We have PHP script that make this inserts:
We read from another tables and insert the data as needed in those fields.
All help is appreciated.
It’s not reading promotions, but promotions create prices, and it does pull in all default prices, are you setting the
Can you send me the script so I can try and reproduce this locally?
Yep, that field is set to 1 automatically by default. Shall we set the field to 0?
Thats a module, and it adds to WordPress tools (to access when installed: Menu -> tools -> Codigos Masivos)
I paste the code here:
Yes, set that field to 0.
Promotion price objects are not ‘default prices’ and thats likely what is causing your problem as default prices are all pulled into the the event editor. It was never expected that a user would have 8,000+ default prices on an event (a default price would usually be asigned to a default ticket, meaning an event with 8,000 default tickets).
Side note, is there any reason your not using our models to create these objects?
Had you have used those to add the prices the default field would have automatically been set to 0. I’m going to create a ticket to investigate why that field defaults to 1 but I would still recommend switching the above to use the model system as it handles a lot of what you are doing automatically.
Thanks for all, it was really helpfull.
We have already made the change and it finally works fine. Thanks so much!
We didn’t really noticed that it exists. We will consider update our code for using your model system as u mentioned above to create codes. Thanks for suggestion!!
You’re most welcome, I’m glad that worked for you.
With regards to the models, I’d highly recommend looking into using them, the handle a lot of the background work for you so once you know how to use them its much easier to work with EE than rolling your own.