Making WordPress.org

Changeset 11232


Ignore:
Timestamp:
09/14/2021 07:19:00 AM (5 years ago)
Author:
dd32
Message:

Theme Directory: Add a cron task to monitor themes.svn.wordpress.org for new commits.

See #5899.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/jobs/class-manager.php

    r6289 r11232  
    2828        // A cronjob to check cronjobs.
    2929        add_action( 'theme_directory_check_cronjobs', [ $this, 'register_cron_tasks' ] );
     30
     31        // Import from SVN tasks.
     32        add_action( 'theme_directory_svn_import_watcher', [ __NAMESPACE__ . '\SVN_Import', 'watcher_trigger' ] );
     33        add_action( 'theme_directory_svn_import', [ __NAMESPACE__ . '\SVN_Import', 'import_trigger' ] );
    3034    }
    3135
     
    4246            'interval' => 15 * MINUTE_IN_SECONDS,
    4347            'display'  => 'Every 15 minutes',
     48        ];
     49
     50        $schedules['every_5m']  = [
     51            'interval' => 5 * MINUTE_IN_SECONDS,
     52            'display'  => 'Every 5 minutes',
    4453        ];
    4554
     
    6069            wp_schedule_event( time() + 60, 'every_15m', 'theme_directory_check_cronjobs' );
    6170        }
     71
     72        if ( ! wp_next_scheduled( 'theme_directory_svn_import_watcher' ) ) {
     73            wp_schedule_event( time() + 60, 'every_5m', 'theme_directory_svn_import_watcher' );
     74        }
    6275    }
    6376}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/lib/class-exec-with-logging.php

    r11230 r11232  
    33
    44/**
    5  * Simple `exec()` wrapper which adds error reporting to WordPress.org.
     5 * Simple `exec()` wrappers which add error reporting to WordPress.org.
    66 *
    7  * @package WordPressdotorg\Theme_Directory
     7 * @package WordPressdotorg\Theme_Directory\Lib
    88 */
    99trait Exec_With_Logging {
     
    1818     * @return false|string False on failure, last line of output on success, as per exec().
    1919     */
    20     public function exec( $command, &$output = null, &$return_var = null ) {
     20    public static function exec( $command, &$output = null, &$return_var = null ) {
    2121        $proc = proc_open(
    2222            $command,
     
    2727            $pipes
    2828        );
     29
     30        if ( ! $proc ) {
     31            return false;
     32        }
    2933
    3034        $stdout = stream_get_contents( $pipes[1] );
     
    7781    }
    7882
     83    /**
     84     * Execute a shell process, same behaviour as `shell_exec()` but with PHP Warnings/Notices generated on errors.
     85     *
     86     * @param string $command Command to execute. Escape it.
     87     *
     88     * @return false|string False on failure, output on success, mostly per shell_exec().
     89     */
     90    public static function shell_exec( $command ) {
     91        $output     = [];
     92        $return_var = 0;
     93        $return = self::exec( $command, $output, $return_var );
     94
     95        // Diverge from shell_exec(): return false for any error.
     96        if ( $return_var > 0 || false === $return || ! $output ) {
     97            return false;
     98        }
     99
     100        return implode( "\n", $output );
     101    }
    79102}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r11231 r11232  
    2727include __DIR__ . '/query-modifications.php';
    2828
     29// Load the GitHub API client.
     30include __DIR__ . '/lib/class-github.php';
     31include __DIR__ . '/lib/class-exec-with-logging.php';
     32
    2933// Load repo jobs.
    3034include __DIR__ . '/jobs/class-manager.php';
    3135include __DIR__ . '/jobs/class-trac-sync.php';
     36include __DIR__ . '/jobs/class-svn-import.php';
    3237new WordPressdotorg\Theme_Directory\Jobs\Manager();
    33 
    34 // Load the GitHub API client.
    35 include __DIR__ . '/lib/class-github.php';
    36 include __DIR__ . '/lib/class-exec-with-logging.php';
    3738
    3839// Load the Rest API Endpoints.
Note: See TracChangeset for help on using the changeset viewer.