I have a WordPress website for a client that uses a custom theme and a number of plugins in combination to create an events calendar where logged in users can purchase tickets for paid events and register for free RSVP-required events. To accomplish this, I am using the following six plugins in combination:
The Events Calendar
Events Calendar Pro
Event Tickets
Event Tickets Plus
WooCommerce
WooCommerce Stripe Gateway
The website was established in 2015. In the last 4 years, those plugins have seen extensive updates, and as a result, at a certain point the custom site I built around those plugins started experiencing deprecation issues, and attempts to upgrade caused performance failure. After consulting with support, it became necessary to pull a duplicate copy of the site onto a development server so that I could do the work to upgrade the install so all the latest versions of all of these plugins can be running and working properly.
Everything was going well with the upgrade work until I noticed that one of the plugins seems to be generating the following error in the console in Chrome:
POST https://pcapolar.codewordserver.com/wp-admin/admin-ajax.php 400 (Bad Request)
send # jquery.js?ver=1.12.4-wp:4
ajax # jquery.js?ver=1.12.4-wp:4
n.<computed> # jquery.js?ver=1.12.4-wp:4
r.length.e.checkAvailability # frontend-ticket-form.min.js?ver=4.11.1:1
r.length.e.init # frontend-ticket-form.min.js?ver=4.11.1:1
(anonymous) # frontend-ticket-form.min.js?ver=4.11.1:1
(anonymous) # frontend-ticket-form.min.js?ver=4.11.1:1
Loading the same page in Edge generated the following console error:
HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax
(XHR)POST - https://pcapolar.codewordserver.com/wp-admin/admin-ajax.php
The error occurs only under very specific circumstances -- when a single event page displays the frontend form for a paid ticket. The error doesn't occur when the front end paid ticket form is not output, for example when there is a registered RSVP form with no payment component, when there is no ticket component to the event, or when a user who is not an active member views an affected page such that all information about details of the event and buying tickets is excluded from the output via theme template files. Despite the console error generated, it appears that ajax works fine and all of the functionality works exactly as expected. If you weren't looking at the console, you'd never know there was a problem.
In order to rule out an issue with my custom theme or a conflict with another plugin, I activated the default Twenty Twenty theme and deactivated all other plugins except the 6 I listed that are required to use ticketed event process. The error remained present under these circumstances
After going back and forth with Modern Tribe (the plugin developers) support desk, they report the error cannot be replicated. So I tried myself to install a clean copy of WordPress with a new database, then install only those 6 plugins while running the default Twenty Twenty theme. I did this on the same server under the same cPanel account as the dev site with the error, just at different subdomains. On the clean install, the error was NOT present. But when I then pointed the clean WordPress install to a duplicate copy of the database I'm using for the dev site I'm working on, the error shows up again. From that, I can only conclude there is something going on in my database that is making this error happen, but Modern Tribe support are telling me that since the error can't be reproduced by them, there isn't anything they can do to help.
Starting over with a clean install for this site isn't really an option, there is so much data collected over the last 4 years from ticket purchase and membership transactions that we really can't lose. I need to find the faulty data and clean it, but I feel out of my depth here. Any help or suggestions on how to resolve this are welcome.
Edited to add:
I found this code in the javascript file references by the error message in the console. Am I looking in the right place?
/**
* Check tickets availability.
*
* #since 4.9
*
* #return void
*/
obj.checkAvailability = function() {
// We're checking availability for all the tickets at once.
var params = {
action : 'ticket_availability_check',
tickets : obj.getTickets(),
};
$.post(
TribeTicketOptions.ajaxurl,
params,
function( response ) {
var success = response.success;
// Bail if we don't get a successful response.
if ( ! success ) {
return;
}
// Get the tickets response with availability.
var tickets = response.data.tickets;
// Make DOM updates.
obj.updateAvailability( tickets );
}
);
// Repeat every 60 (filterable via tribe_tickets_availability_check_interval ) seconds
if ( 0 < TribeTicketOptions.availability_check_interval ) {
setTimeout( obj.checkAvailability, TribeTicketOptions.availability_check_interval );
}
}
Edited to add:
Then I ran a string search for ticket_availability and found the following. It looks like it might be related, but I'm a bit over my head in interpreting. Am I on the right track yet?
public function ticket_availability( $tickets = array() ) {
$response = array( 'html' => '' );
$tickets = tribe_get_request_var( 'tickets', array() );
// Bail if we receive no tickets
if ( empty( $tickets ) ) {
wp_send_json_error( $response );
}
/** #var Tribe__Tickets__Tickets_Handler $tickets_handler */
$tickets_handler = tribe( 'tickets.handler' );
/** #var Tribe__Tickets__Editor__Template $tickets_editor */
$tickets_editor = tribe( 'tickets.editor.template' );
// Parse the tickets and create the array for the response
foreach ( $tickets as $ticket_id ) {
$ticket = Tribe__Tickets__Tickets::load_ticket_object( $ticket_id );
if (
! $ticket instanceof Tribe__Tickets__Ticket_Object
|| empty( $ticket->ID )
) {
continue;
}
$available = $tickets_handler->get_ticket_max_purchase( $ticket->ID );
$response['tickets'][ $ticket_id ]['available'] = $available;
// If there are no more available we will send the template part HTML to update the DOM
if ( 0 === $available ) {
$response['tickets'][ $ticket_id ]['unavailable_html'] = $tickets_editor->template( 'blocks/tickets/quantity-unavailable', $ticket, false );
}
}
wp_send_json_success( $response );
}
The weird thing is that this function is filed to a folder called Blocks, which implied it works with Gutenberg, which I have disabled via the Classic Editor plugin.
StackOverflow powers that be, forgive me but this was too much to fit in a comment.
I apologize, but this is more of a debug process than a strict answer.
The admin-ajax.php file only has 3 scenarios to return a 400 error.
If the user is logged in, and the ajax function hasn't been added to the wp_ajax_{function_name} action. (line #164)
The user is NOT logged in, and the ajax function hasn't been added to the wp_ajax_nopriv_{function_name} action. (line #179)
No action was sent in the request. (line #32)
You'll need to figure out which of these is causing your error. If you're not sure how to do this, an easy way is to temporarily edit your admin-ajax.php file. Before you see this:
// Require an action parameter
if ( empty( $_REQUEST['action'] ) ) {
wp_die( '0', 400 );
}
Add in the following (again, before the above lines)
ob_start();
print( '<pre>'. print_r($_REQUEST, true) .'</pre>' );
wp_mail( 'your-email#address.com', 'Debug Results', ob_get_clean() );
This will email you (semi-nicely) formatted dump of the $_REQUEST. If there's no action, you'll know that for some reason the "front end form for a paid ticket" function isn't being added, and Modern Tribe could probably help you out with that.
If the action is set, you can add a similar line down below at line 164 or 179 and repeat the above, but with print( '<pre>'. print_r($action, true) .'</pre>' ); instead. If either of these get emailed to you when you submit the form, you'll know which ajax hook isn't being added, and again Modern Tribe could probably help you from there.
Also note, that modifying core WP files is generally bad practice and you should revert these changes when you're done debugging. (There's ways to hook into file instead, but for ease/speed of diagnostics, go ahead and temporarily edit it, as these aren't permanent changes, and it's on a development site, so you shouldn't have to worry)
Beyond the above, you'll probably need to hire a developer look at it, there's not much more that someone on Stack Overflow can do without having direct access to your database and files.
I am having the same problem and I think the problem is Tribe__Editor::should_load_blocks when the classic editor plugin is active.
To bypass this error I add this code to my theme functions.php file
add_action( 'xxx', tribe_callback( 'tickets.editor.blocks.tickets', 'register' ) );
do_action( 'xxx' );
I hope this works for you.
The advice I received from the plugin developers after a great deal of back and forth was to add the following to my theme's functions.php file:
add_filter( 'tribe_tickets_availability_check_interval', function( $interval) {
return 0;
} );
This resolves the console issue, does not generate additional errors, and does not interfere with any expected functionality in all tests performed thus far.
Wanted to update everyone that with the release of Event Tickets 4.11.4 and Event Tickets Plus 4.11.3, this issue has been completely resolved on the plugin side. So apparently this was not just an issue with my site only. Thank you to everyone who contributed.
i have a form where user could upload files. There are 3 files they could upload and each of them need to have an unique name. So even the person upload the same file everytime i neet different names for it in the email, i get from the form.
So i try to use randomizeFileName.
https://github.com/einpraegsam/powermail/blob/develop/Configuration/TypoScript/Main/setup.txt#L538
Cause i dont have the randomizeFilename in my constants.txt it try to enter it in my setup.txt with a real value.
# File upload settings
file {
folder = {$plugin.tx_powermail.settings.misc.uploadFolder}
size = {$plugin.tx_powermail.settings.misc.uploadSize}
extension = {$plugin.tx_powermail.settings.misc.uploadFileExtensions}
randomizeFileName = 1
}
But sadly that dont work. The file issues-1.pdf still has the same name (+ a suffix cause i tried it a lot time )
I hope someone can help me. Thank you very much!
Based on the setup file included in the extension, the correct syntax for Powermail 7.x would be:
plugin.tx_powermail.settings.misc.randomizeFileName = 1
randomizeFileName = 1 is the default value in Powermail 7.x!
You have to set this over Typoscript Constant, not in Typoscript Setup:
In Typoscript Setup this may work. (Not Tested)
plugin.tx_powermail.settings.Pi2.misc.file.randomizeFileName = 1
Read the source code to see more:
https://github.com/einpraegsam/powermail/blob/develop/Configuration/TypoScript/Powermail_Frontend/setup.txt
Or the documentation: https://docs.typo3.org/typo3cms/extensions/powermail/stable/ForAdministrators/BestPractice/MainTypoScript/Index.html
i'm using fineuploader s3 and i've just discovered a unexpected ( from my pov ) behaviour.
I give to our customers the possibility to upload files for their works.
Every work has a code for example 12345_1298681 and 12345_84792782.
let's assume that customer started to upload files for both orders ( starting the upload sets the work as interrupted so at next uploader init them are set as _isResumable = true)
User uploads file a.mov to work 12345_1298681 ( s3key is 12345_1298681/a.mov ) and b.mov to 12345_84792782 ( s3Key is 12345_84792782/b.mov)
If for some reason user tries to upload a.mov to work 12345_84792782 fineuploader recognizes the file as resumables and in the console i can see
Identified file with ID 0 and name of a.mov as resumable.
Server requested UUID change from '60aecf65-67ca-4811-aa3c-6425620cc3f1' to 'a2bfc111-0c82-4e48-8512-a08c3e24cbd8'
But a.mov is resumable if added to work 12345_1298681 not if added to work 12345_84792782.
i've seen in the doc that if i return false to the onResume callback the file is restarted from the beginning, but the problem whit this approach is that resume data is deleted for the file and not for the s3Key and in this way i'll lose the ability to resume upload in 12345_1298681?
To be clearer ( hopefully )
i have
order 12345_123456 => s3 key => 12345_123456/a.mov
order 12345_987654 => s3 key => 12345_987654/a.mov
if i start to upload file for order 12345_123456 than i stop it, if i want start the upload for order 12345_987654 using the same file in my filesystem, fineuploader recognizes that the file is the same ( that's correct but it differs in the final key ) and uploads it to 12345_123456/a.mov instead of 12345_987654/a.mov
and this can lead to a problem:
i think i'm uploading file for one order instead i'm not.
Digging in the source of fineuploader i can see that the cookie id is generated by function
_getLocalStorageId from qq.XhrUploadHandler
instead of
_getLocalStorageId from qq.s3.XhrUploadHandler but in none of those methods there's something that consider key to differentiate file from another
I can not figure out how to get the flow field working in admin,
I would like example shown at shown https://raw.githubusercontent.com/lektor/lektor-assets/master/screenshots/admin.png When I then click through to localhost:5000/admin/root/edit and get the http://i.imgur.com/EPCrBRC.png
Got I feel I am doing something simple wrong. But cutting it down to basic here is what I tried:-
$ cd /tmp/
$ lektor quickstart
Lektor Quickstart
=================
This wizard will generate a new basic project with some sensible defaults for
getting started quickly. We jsut need to go through a few questions so that
the project is set up correctly for you.
Step 1:
| A project needs a name. The name is primarily used for the admin UI and
| some other places to refer to your project to not get confused if multiple
| projects exist. You can change this at any later point.
> Project Name: flow-example
Step 2:
| This is the path where the project will be located. You can move a
| project around later if you do not like the path. If you provide a
| relative path it will be relative to the working directory.
> Project Path [/tmp/flow-example]:
Step 3:
| Do you want to generate a basic blog module? If you enable this the
| models for a very basic blog will be generated.
> Add Basic Blog [Y/n]: n
Step 4:
| Your name. This is used in a few places in the default template to refer
| to in the default copyright messages.
> Author Name [Brendan M. Sleight,,,]:
That's all. Create project? [Y/n] Y
$ cd flow-example/
$ echo "[fields.extra]
> label = Extra
> type = flow
> flow_blocks = text" >>./models/page.ini
$ cat ./models/page.ini
[model]
name = Page
label = {{ this.title }}
[fields.title]
label = Title
type = string
[fields.body]
label = Body
type = markdown
[fields.extra]
label = Extra
type = flow
flow_blocks = text
$ lektor server
* Project path: /tmp/flow-example/flow-example.lektorproject
* Output path: /home/bms/.cache/lektor/builds/76682e6a8f99116f0da91bcf96203e94
Started source info update
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Finished source info update in 0.05 sec
Started build
U index.html
U about/index.html
U projects/index.html
Finished build in 0.12 sec
Started prune
Finished prune in 0.00 sec
```
It takes a bit of careful documentation reading to find out what needs to go where to make flow blocks work.
You need to create a folder flowblocks at the same level where your content and models folders are.
Put your flowblock model files in this folder (example: image-paragraph.ini)
Create a blocks folder inside your templates folder.
Put your HTML templates for your flowblock in the blocks folder (example: image-paragraph.html)
Directory structure should look like this:
my-lektor-project
assets
content
flowblocks
image-paragraph.ini (your model)
models
templates
blocks
image-paragraph.html (your template for the block)
Currently the admin responds really badly to misconfiguration. Usually it just dies with an error you can see in the console window. Most likely the flow block itself does not exist or has a bug in it. Just open the console window and look at the error message printed. That might give an indication.
See https://www.getlektor.com/docs/models/flow/
To use Flow you need to define flow block models. If you are not familiar with Flow yet, you should read the Introduction Documentation to Flow first
Defining Models
Flow block models work pretty much exactly the same as Regular Models. The differences are mostly minor and of cosmetic nature. They are stored in the flowblocks/ folder and are ini files just like models.
Best explained with an example.
First, create a model containing a field with type set to flow and put it into models/flow_page.ini.
[model]
name = FlowPage
label = {{ this.title }}
[fields.title]
label = Title
type = string
[fields.body]
label = Body
type = flow
Create a new template in templates/flow_page.html. You can just copy page.html if you want.
Then write the following flow block config to flowblocks/colored_text.ini:
[block]
name = Text Block
button_label = Text
[fields.text]
label = Text
type = markdown
[fields.color]
label = Class
type = select
choices = red, blue, green
choice_labels = Red, Blue, Green
default = red
Now you need a template for the flow block. Add it to templates/blocks/colored_text.html.
<span style="color: {{ this.color }}">{{ this.text }}</span>
Finally, create a new subpage, choose FlowPage under model.
Now you can add the block we defined earlier to the body.
I'm trying to figure out what the purpose of the file /var/resource_config.json is in Magento. It appears to perhaps be a caching of a configuration, but can't see where in the source code it is being created and/or updated.
I'm in the process of setting up local/dev/staging/prod environments for an EE1.12 build and want to figure out if I can safely exclude it from my repo or whether I need to script some updates to it for deploys.
Maybe the flash image uploader in admin creates it?
Any ideas or directions to look?
This is a configuration cache file for the "alternative media store" system. This is a system where requests for media files are routed through get.php, and allows you to store media in the database instead of the file system. (That may be a gross over simplification, as I've never used the feature myself)
You can safely, (and should) exclude this file from deployments/source control, as it's a cache file and will be auto generated as needed. See the following codeblock in the root level get.php for more information.
if (!$mediaDirectory) {
$config = Mage_Core_Model_File_Storage::getScriptConfig();
$mediaDirectory = str_replace($bp . $ds, '', $config['media_directory']);
$allowedResources = array_merge($allowedResources, $config['allowed_resources']);
$relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo);
$fp = fopen($configCacheFile, 'w');
if (flock($fp, LOCK_EX | LOCK_NB)) {
ftruncate($fp, 0);
fwrite($fp, json_encode($config));
}
flock($fp, LOCK_UN);
fclose($fp);
checkResource($relativeFilename, $allowedResources);
}
Speaking in general terms, Magento's var folder serves the same purpose as the *nix var folder
Variable files—files whose content is expected to continually change during normal operation of the system—such as logs, spool files, and temporary e-mail files. Sometimes a separate partition
and should be isolated to particular systems (i.e. not a part of deployments)