Apidocjs throws warnings when i attempt to update - api-doc

Ok, so I'm playing around with apidocjs to figure it out before implementing it in a production environment and am incountering the following:
~/apidoc_playground$ apidoc
warn: parser plugin 'param' not found in block: 0
info: Done.
the following are the block comments it is looking at (each in a separate file):
/**
*this is a test of apidocjs
*#api {get} /user/:id Request User information
* #apiName GetUser
* #apiGroup User
*
* #apiParam {Number} id Users unique ID.
*
* #apiSuccess {String} firstname Firstname of the User.
* #apiSuccess {String} lastname Lastname of the User.
*
*/
/**
*#api {GET} /getPicture/:UID Retreive user profile picture
*#apiGroup User
*#apiName getPicture
*#apiVersion 0.0.1
*
*#apiDescription userID goes in, picture comes out, you can't explain that!
*#apiParam {int} UID User's identification number.
*#apiExample {curl} Example usage:
* curl -i http://api.example.com/getPicture/45123
*#apiSuccess (200) {json} picture The user's profile picture
*#apiError (4xx) {userNotFound} UID There was no user affiliated with the given id.
*#apiErrorExample {json} Error-Response:
* HTTP/1.1 404 Not Found
* {
* "error":"UserNotFound"
* }
*/
What i know already :
This does not cause the update to fail, apidoc updates the output directory as intended.
If i delete the output directory before calling apidoc, there is no warning.
the warning still occurs if it has no files to parse.
after scouring for an answer the most i can find is one question that is similar to mine except that the asker also has format errors in his apidoc.json. That being said, the answers in that thread don't really meet what i'm looking for (one being delete the output folder before calling apidoc, and the other being don't delete the output folder if you want to keep history and maybe you have format errors).
Any insights from more experienced users of apidocjs would be appriciated.
sorry for the wall-of-text

If it happens even when both the input and output directories are empty, that indicates there's probably something wrong with the install.
Try to wipe and re-add it.
npm remove -g apidoc
npm install -g apidoc

Related

WordPress admin-ajax.php 400 error generated by Event Tickets plugin ... database related?

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.

How do I create a presigned link to a particular version of an object using the Ruby AWS SDK v2?

I am using the Ruby AWS SDK (v2) to upload log files to a versioned S3 bucket. The log files are not public, but I would like to generate a presigned link to the log to make it available for a limited time via a chat integration. I want to link to a particular version, which this answer says is possible via the S3 console.
Documentation on Aws::S3::Presigner shows how to do this for an unversioned object (or the head version of a versioned object) but not for a particular version. The possible parameters to #presigned_url are not well documented, and reading the source it looks like the parameters are just passed to Seahorse::Client::Base#build_request which is not S3-specific.
I think I've finally worked this out, though I'm still not sure I could trace the entire code path. In short: You can pass :version_id in the options parameter to presigned_url.
#
# Uploads a log to S3 at the given key, returning a URL
# to the file that's good for one hour.
#
# #param [String] bucket
# #param [String] key
# #param [String] body of the log to be uploaded
# #param [Hash] options
# #return [String] public URL of uploaded log, valid for one hour
# #raise [Exception] if the S3 upload fails
#
def upload_log(bucket, key, body, options={})
# Upload log
result = AWS::S3.create_client.put_object(
options.merge(
bucket: bucket,
key: key,
body: body
)
)
# Get presigned URL that expires in one hour
options = {bucket: bucket, key: key, expires_in: 3600}
options[:version_id] = result[:version_id] unless result[:version_id].nil?
Aws::S3::Presigner.new.presigned_url(:get_object, options)
end
And here, everything I could trace about why this works:
presigned_url passes its params argument through to #client.build_request (presigner.rb#L48).
build_request eventually pushes those parameters onto request.context.params of the request it returns (documented in client/base_spec.rb#L91).
From here my understanding is fuzzy; I expect that something like Aws::Rest::Request::Builder passes all the params along to create the Endpoint and the particular rules for this operation (which I'm unable to find) allow version_id to be added to the querystring.
In any case, it's working. Thanks for the pointer Michael!

#param description showing up in code font

I'm generating javadoc for the following simple example:
public class test {
/**
* foo does something.
*
* #param x the parameter
*/
public void foo(int x) {}
}
I run javadoc test.java.
I expected x to have the name shown in a non-proportional font, and the description shown in a proportional font, like it happens for the official JDK javadocs for example. Instead I get what shown in this capture:
This is ok for a short description, but it's ugly for longer ones. What am I doing wrong?
When you compare the Java API documentation of Object.equals(obj) for Java 7 and Java 8 you will see the difference in the font for the
Parameters:
obj - the reference object with which to compare.
part. You will see it for all other method’s parameters as well, I just picked the well-known method as an example.
In other words, this is a general change in the behavior of JavaDoc between Java 7 and the current version of Java 8 and you are not doing anything wrong.
If you look into the stylesheet you will find the definition responsible for the description part starting at line 287 containing the attribute font-family:'DejaVu Sans Mono',monospace;.

Laravel App::make causes infinite loop

I'm creating some project management functionality.
I'm using Model Observers in Laravel to create an audit trail whenever models are created/updated/deleted. So for example when a project is created, the observer will automatically create a new instance of the project audit model creating a new database entry storing the fields that have changed. This observer also clears the relevant caches, ensuring the user can access the most recent information.
The problem is calling the cache repository causes this error message (with no stack trace):
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Maximum function nesting level of '100' reached, aborting!
I'm using App::make to call the cache repository:
$this->projectAuditCache = App::make('cache\ProjectManagement\Interfaces\ProjectAuditCacheInterface');
The Audit Cache Repository then constructs with only one other repository which isn't reliant on anything else.
The only possible clue on the stack trace is this:
Open: /home/vagrant/Sites/fixing/new_fixing/vendor/laravel/framework/src/Illuminate/Container/Container.php
* Determine if the given abstract has a leading slash.
*
* #param string $abstract
* #return bool
*/
protected function missingLeadingSlash($abstract)
{
return is_string($abstract) && strpos($abstract, '\\') !== 0;
}
Is there a way to get this to work? Is using App::make the wrong way to go about this?
Thanks, Ed
The problem which causes the error is xdebug the debug extension of PHP.
The array that this extension wants to echo is to big.
You can just simply adjust the setting of maximum nesting level of xdebug simply in your php.ini.
Or with the command
ini_set('xdebug.max_nesting_level', $limit)
which should be included when your app starts. For Laravel 4.x that would be app/start/global.php.
Source: StackOverflow

Doxygen Ignoring Some .h Files

UPDATE 2: The issue seems to be stemming from the files themselves, and not the contents. I've tried, across multiple repos, duplicating the broken files from the ground up (new file, copy-paste contents, rename, etc) and they work as expected with Doxygen.
UPDATE: It seems that all of the "broken" .h files are being saved as class_.html while working .h files are interface_.html. Strikes me as related.
Trying to set up Doxygen for my Xcode project and for some reason it is ignoring the .h file in one of my repos.
The basic structure of the project is 1 central repo with a handful of private CocoaPods being pulled in either from the local copy or the external repo, depending on which is more recent. Other pods projects, when run against Doxygen, generate documentation just fine. This one does not. I've tried it with a variety of configurations (EXTRACT_ALL, EXTRACT_STATIC, etc. etc.) to no avail.
When run on the following .h file, no documentation is generated and the only thing I see is "The documentation for this class was generated from the following file:", with the .m file following; clicking on that just shows some static string constants and the imports, still no method headers.
One thing I noticed is that if I set EXTRACT_LOCAL_METHODS to YES then it works...but that would imply that I am NOT defining methods in my .h, which is definitely untrue.
Am I missing something?
#import <Foundation/Foundation.h>
#import <FinderAuthApiProtocol.h>
#import <AuthCredentials.h>
//Keys to name persisted objects
extern NSString *const kCarrierAuthCredentialsPersistName;
extern NSString *const kFinderAuthCredentialsPersistName;
extern NSString *const kLastLoggedInUserName;
#interface CommonAuthManager : NSObject
/**
* Returns the singleton object for CommonAuthManager, or creates one if necessary
*
* #return pointer to the singleton instance
*/
+ (CommonAuthManager *)sharedInstance;
/**
* #brief Performs carrier-agnostic authenticaton
*
* This method is called by the UI to perform authentication with a user's
* username and password combination. The carrier-specific implementation of
* Network's FinderAuthApiProtocol determines the precise behavior but as far
* as the manager is concerned it doesn't matter; it just calls auth and waits
* for results
*
* #param userID - the user's ID (i.e. phone number, username, email, etc)
* #param password - the user's password
* #param stayLoggedIn - toggled value for refreshig auth tokens or not
* #param block - block for completion
**/
+ (void)authWithUserID:(NSString *)userID
andPassword:(NSString *)password
andStayLoggedIn:(bool)stayLoggedIn
withCompletionBlock:(void(^)(NSError *error))block;
/**
* Determines if current user is allowed to say logged in (bypass explicit login screen)
*
* YES if all the following criteria are met:
* Current user must exist in persistence store
* Current user last login attempt must have succeeded
* Current user must be allowed to stay logged in
*
* #param error return error
*
* #return Returns YES if user is allowed to stay logged in
*/
+ (BOOL)isUserAllowedToStayLoggedIn:(NSError *__autoreleasing *)error;
/**
* Abstracted-away selector for the LLCommonAuthManager's finder API credentials
**/
+ (AuthCredentials *)finderCredentials;
/**
* Abstracted-away selector for the LLCommonAuthManager's carrier API credentials
*
* NOTE: Functionality across carriers varies. For <XXX> this object will have
* the auth token, while for <YYY> it will be the username and password
* they originally authed with.
**/
+ (AuthCredentials *)credentials;
#end
Turns out Doxygen expects a newline at the bottom of the file.
Who knew.

Resources