Plugin Directory

Changeset 3074869


Ignore:
Timestamp:
04/22/2024 08:58:21 AM (21 months ago)
Author:
brandonpirk
Message:

Check Logfile data is not empty for logging

Location:
kassa-at-for-woocommerce/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kassa-at-for-woocommerce/trunk/api-connection.php

    r2665761 r3074869  
    3535        $host = 'https://' . kaw_get_subdomain() . '.kassa.at';
    3636    } elseif ( kaw_get_envirement_mode() === 'dev' ) {
    37         $host = 'http://' . kaw_get_subdomain() . '.kassa.at.10.0.0.13.nip.io:3000';
     37        $host = 'http://' . kaw_get_subdomain() . '.kassa.at.192.168.165.45.nip.io:3000';
    3838    }
    3939    return $host;
  • kassa-at-for-woocommerce/trunk/kassa-at-for-woocommerce.php

    r2665761 r3074869  
    55     * Domain Path: /languages
    66     * Description: An API Plugin which corresponds with a KASSA.AT account to synchronize online and offline stock-changes.
    7      * Version:     1.1.0
     7     * Version:     1.1.1
    88     * Author:      Faxonline GmbH
    99     * Author URI:  https://www.kassa.at
     
    4747
    4848/**
     49 * Check if variable is null or empty
     50 */
     51function IsNullOrEmptyString($var){
     52    return ($var === null || trim($var) === '');
     53}
     54
     55
     56/**
    4957 * Asks for the log file and writes whatever is in $data to it.
    5058 *
     
    5866        $filestring = file_get_contents( $logfile ); /* phpcs:ignore */
    5967        $filejson   = json_decode( $filestring );
    60         array_unshift(
    61             $filejson,
    62             array(
    63                 'datetime' => gmdate( 'd-m-Y H:i:s' ),
    64                 'type'     => $type,
    65                 'data'     => kaw_log_data_formating( $type, $data ),
    66             )
    67         );
    68         $filejson   = kaw_cut_log( $filejson );
    69         $fileresult = wp_json_encode( $filejson );
    70         file_put_contents( $logfile, $fileresult ); /* phpcs:ignore */
     68
     69        if( !empty($data) && !empty($filestring) && !empty($logfile) && !empty($filejson) ) {
     70            array_unshift(
     71                $filejson,
     72                array(
     73                    'datetime' => gmdate( 'd-m-Y H:i:s' ),
     74                    'type'     => $type,
     75                    'data'     => kaw_log_data_formating( $type, $data ),
     76                )
     77            );
     78            $filejson   = kaw_cut_log( $filejson );
     79            $fileresult = wp_json_encode( $filejson );
     80            file_put_contents( $logfile, $fileresult ); /* phpcs:ignore */
     81        }
    7182    }
    7283}
     
    149160function kaw_enable_log() {
    150161    if ( get_option( 'kaw-logging' ) ) {
     162
    151163        if ( get_option( 'kaw-logging' ) === 'enabled' ) {
    152164            return true;
     
    355367    $bt     = debug_backtrace(); /* phpcs:ignore */
    356368    $caller = array_shift( $bt );
     369
    357370    if ( count( explode( 'wp-content', $caller['file'] ) ) === 2 ) {
    358371        $path = '/wp-content' . explode( 'wp-content', $caller['file'] )[1];
  • kassa-at-for-woocommerce/trunk/stock-syncro.php

    r2665761 r3074869  
    7373        )
    7474    );
     75
    7576    if ( 1 !== $inventory->length ) {
    7677        kaw_log_data(
Note: See TracChangeset for help on using the changeset viewer.