PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.4
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.4
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | freemius/includes/class-fs-logger.php +17 -53 trunk3.1.4 View file →
@@ -31,11 +31,8 @@
31 31 * @var int ABSPATH length.
32 32 */
33 33 private static $_abspathLength;
34 34
35 - /**
36 - * @var FS_Logger[] $LOGGERS
37 - */
38 35 private static $LOGGERS = array();
39 36 private static $LOG = array();
40 37 private static $CNT = 0;
41 38 private static $_HOOKED_FOOTER = false;
@@ -126,8 +123,9 @@
126 123 }
127 124
128 125 self::hook_footer();
129 126 }
127 +
130 128 function echo_on() {
131 129 $this->on();
132 130
133 131 $this->_echo = true;
@@ -321,13 +319,8 @@
321 319 global $wpdb;
322 320
323 321 $table = "{$wpdb->prefix}fs_logger";
324 322
325 - /**
326 - * Drop logging table in any case.
327 - */
328 - $result = $wpdb->query( "DROP TABLE IF EXISTS $table;" );
329 -
330 323 if ( $is_on ) {
331 324 /**
332 325 * Create logging table.
333 326 *
@@ -335,9 +328,9 @@
335 328 * dbDelta must use KEY and not INDEX for indexes.
336 329 *
337 330 * @link https://core.trac.wordpress.org/ticket/2695
338 331 */
339 - $result = $wpdb->query( "CREATE TABLE IF NOT EXISTS {$table} (
332 + $result = $wpdb->query( "CREATE TABLE {$table} (
340 333 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
341 334 `process_id` INT UNSIGNED NOT NULL,
342 335 `user_name` VARCHAR(64) NOT NULL,
343 336 `logger` VARCHAR(128) NOT NULL,
@@ -354,13 +347,17 @@
354 347 KEY `process_id` (`process_id` ASC),
355 348 KEY `process_logger` (`process_id` ASC, `logger` ASC),
356 349 KEY `function` (`function` ASC),
357 350 KEY `type` (`type` ASC))" );
351 + } else {
352 + /**
353 + * Drop logging table.
354 + */
355 + $result = $wpdb->query( "DROP TABLE IF EXISTS $table;" );
358 356 }
359 357
360 358 if ( false !== $result ) {
361 359 update_option( 'fs_storage_logger', ( $is_on ? 1 : 0 ) );
362 - self::$_isStorageLoggingOn = $is_on;
363 360 }
364 361
365 362 return ( false !== $result );
366 363 }
@@ -635,20 +632,10 @@
635 632 $limit = 10000,
636 633 $offset = 0,
637 634 $order = false
638 635 ) {
639 - if ( empty( $filename ) ) {
640 - $filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
641 - }
636 + global $wpdb;
642 637
643 - $upload_dir = wp_upload_dir();
644 - $filepath = rtrim( $upload_dir['path'], '/' ) . "/{$filename}";
645 -
646 - WP_Filesystem();
647 - if ( ! $GLOBALS['wp_filesystem']->is_writable( dirname( $filepath ) ) ) {
648 - return false;
649 - }
650 -
651 638 $query = self::build_db_logs_query(
652 639 $filters,
653 640 $limit,
654 641 $offset,
@@ -655,8 +642,16 @@
655 642 $order,
656 643 true
657 644 );
658 645
646 + $upload_dir = wp_upload_dir();
647 + if ( empty( $filename ) ) {
648 + $filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
649 + }
650 + $filepath = rtrim( $upload_dir['path'], '/' ) . "/{$filename}";
651 +
652 + $query .= " INTO OUTFILE '{$filepath}' FIELDS TERMINATED BY '\t' ESCAPED BY '\\\\' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n'";
653 +
659 654 $columns = '';
660 655 for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
661 656 if ( $i > 0 ) {
662 657 $columns .= ', ';
@@ -666,18 +661,14 @@
666 661 }
667 662
668 663 $query = "SELECT {$columns} UNION ALL " . $query;
669 664
670 - $result = $GLOBALS['wpdb']->get_results( $query );
665 + $result = $wpdb->query( $query );
671 666
672 667 if ( false === $result ) {
673 668 return false;
674 669 }
675 670
676 - if ( ! self::write_csv_to_filesystem( $filepath, $result ) ) {
677 - return false;
678 - }
679 -
680 671 return rtrim( $upload_dir['url'], '/' ) . '/' . $filename;
681 672 }
682 673
683 674 /**
@@ -694,35 +685,8 @@
694 685 $filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
695 686 }
696 687
697 688 return rtrim( $upload_dir['url'], '/' ) . $filename;
698 - }
699 -
700 - /**
701 - * @param string $file_path
702 - * @param array $query_results
703 - *
704 - * @return bool
705 - */
706 - private static function write_csv_to_filesystem( $file_path, $query_results ) {
707 - if ( empty( $query_results ) ) {
708 - return false;
709 - }
710 -
711 - $content = '';
712 -
713 - foreach ( $query_results as $row ) {
714 - $row_data = array_map( function ( $value ) {
715 - return str_replace( "\n", ' ', $value );
716 - }, (array) $row );
717 - $content .= implode( "\t", $row_data ) . "\n";
718 - }
719 -
720 - if ( ! $GLOBALS['wp_filesystem']->put_contents( $file_path, $content, FS_CHMOD_FILE ) ) {
721 - return false;
722 - }
723 -
724 - return true;
725 689 }
726 690
727 691 #endregion
728 692 }