How to use cleanup class

Best Phoronix-test-suite code snippet using cleanup

Result.php

Source:Result.php Github

copy

Full Screen

...67 protected $syncsFailed = 0;68 /**69 * @var integer70 */71 protected $cleanupsSkipped = 0;72 /**73 * @var integer74 */75 protected $cleanupsFailed = 0;76 /**77 * Constructor78 */79 public function __construct()80 {81 $this->eventDispatcher = new EventDispatcher();82 }83 /**84 * Registers a Listener/Subscriber.85 *86 * @param \phpbu\App\Listener87 */88 public function addListener(Listener $subscriber)89 {90 $this->eventDispatcher->addSubscriber($subscriber);91 }92 /**93 * No errors at all?94 *95 * @return boolean96 */97 public function allOk()98 {99 return $this->wasSuccessful() && $this->noneSkipped() && $this->noneFailed();100 }101 /**102 * Backup without errors, but some tasks where skipped or failed.103 *104 * @return boolean105 */106 public function backupOkButSkipsOrFails()107 {108 return $this->wasSuccessful() && (!$this->noneSkipped() || !$this->noneFailed());109 }110 /**111 * Backup without errors?112 *113 * @return boolean114 */115 public function wasSuccessful()116 {117 return $this->backupsFailed === 0;118 }119 /**120 * Nothing skipped?121 *122 * @return boolean123 */124 public function noneSkipped()125 {126 return $this->cryptsSkipped + $this->syncsSkipped + $this->cleanupsSkipped === 0;127 }128 /**129 * Nothing failed?130 *131 * @return boolean132 */133 public function noneFailed()134 {135 return $this->checksFailed + $this->cryptsFailed + $this->syncsFailed + $this->cleanupsFailed === 0;136 }137 /**138 * Add Exception to error list139 *140 * @param \Exception $e141 */142 public function addError(\Exception $e)143 {144 $this->errors[] = $e;145 }146 /**147 * Return current error count.148 *149 * @return integer150 */151 public function errorCount()152 {153 return count($this->errors);154 }155 /**156 * Return list of errors.157 *158 * @return array<Exception>159 */160 public function getErrors()161 {162 return $this->errors;163 }164 /**165 * Return list of executed backups.166 *167 * @return array<\phpbu\App\Configuration\Backup>168 */169 public function getBackups()170 {171 return $this->backups;172 }173 /**174 * phpbu start event.175 *176 * @param \phpbu\App\Configuration $configuration177 */178 public function phpbuStart(Configuration $configuration)179 {180 $event = new Event\App\Start($configuration);181 $this->eventDispatcher->dispatch(Event\App\Start::NAME, $event);182 }183 /**184 * phpbu end event.185 */186 public function phpbuEnd()187 {188 $event = new Event\App\End($this);189 $this->eventDispatcher->dispatch(Event\App\End::NAME, $event);190 }191 /**192 * Backup start event.193 *194 * @param \phpbu\App\Configuration\Backup $backup195 */196 public function backupStart(Configuration\Backup $backup)197 {198 $this->backupActive = new Result\Backup($backup->getName());199 $this->backups[] = $this->backupActive;200 $event = new Event\Backup\Start($backup);201 $this->eventDispatcher->dispatch(Event\Backup\Start::NAME, $event);202 }203 /**204 * Backup failed event.205 *206 * @param \phpbu\App\Configuration\Backup $backup207 */208 public function backupFailed(Configuration\Backup $backup)209 {210 $this->backupsFailed++;211 $this->backupActive->fail();212 $event = new Event\Backup\Failed($backup);213 $this->eventDispatcher->dispatch(Event\Backup\Failed::NAME, $event);214 }215 /**216 * Return amount of failed backups217 *218 * @return integer219 */220 public function backupsFailedCount()221 {222 return $this->backupsFailed;223 }224 /**225 * Backup end event.226 *227 * @param \phpbu\App\Configuration\Backup $backup228 */229 public function backupEnd(Configuration\Backup $backup)230 {231 $event = new Event\Backup\End($backup);232 $this->eventDispatcher->dispatch(Event\Backup\End::NAME, $event);233 }234 /**235 * Check start event.236 *237 * @param \phpbu\App\Configuration\Backup\Check $check238 */239 public function checkStart(Configuration\Backup\Check $check)240 {241 $this->backupActive->checkAdd($check);242 $event = new Event\Check\Start($check);243 $this->eventDispatcher->dispatch(Event\Check\Start::NAME, $event);244 }245 /**246 * Check failed event.247 *248 * @param \phpbu\App\Configuration\Backup\Check $check249 */250 public function checkFailed(Configuration\Backup\Check $check)251 {252 // if this is the first check that fails253 if ($this->backupActive->wasSuccessful()) {254 $this->backupsFailed++;255 }256 $this->checksFailed++;257 $this->backupActive->fail();258 $this->backupActive->checkFailed($check);259 $event = new Event\Check\Failed($check);260 $this->eventDispatcher->dispatch(Event\Check\Failed::NAME, $event);261 }262 /**263 * Return amount of failed checks.264 *265 * @return integer266 */267 public function checksFailedCount()268 {269 return $this->checksFailed;270 }271 /**272 * Check end event.273 *274 * @param \phpbu\App\Configuration\Backup\Check $check275 */276 public function checkEnd(Configuration\Backup\Check $check)277 {278 $event = new Event\Check\End($check);279 $this->eventDispatcher->dispatch(Event\Check\End::NAME, $event);280 }281 /**282 * Crypt start event.283 *284 * @param \phpbu\App\Configuration\Backup\Crypt $crypt285 */286 public function cryptStart(Configuration\Backup\Crypt $crypt)287 {288 $this->backupActive->cryptAdd($crypt);289 $event = new Event\Crypt\Start($crypt);290 $this->eventDispatcher->dispatch(Event\Crypt\Start::NAME, $event);291 }292 /**293 * Crypt skipped event.294 *295 * @param \phpbu\App\Configuration\Backup\Crypt $crypt296 */297 public function cryptSkipped(Configuration\Backup\Crypt $crypt)298 {299 $this->cryptsSkipped++;300 $this->backupActive->cryptSkipped($crypt);301 $event = new Event\Crypt\Skipped($crypt);302 $this->eventDispatcher->dispatch(Event\Crypt\Skipped::NAME, $event);303 }304 /**305 * Return amount of skipped crypts.306 *307 * @return integer308 */309 public function cryptsSkippedCount()310 {311 return $this->cryptsSkipped;312 }313 /**314 * Crypt failed event.315 *316 * @param \phpbu\App\Configuration\Backup\Crypt $crypt317 */318 public function cryptFailed(Configuration\Backup\Crypt $crypt)319 {320 $this->cryptsFailed++;321 $this->backupActive->fail();322 $this->backupActive->cryptFailed($crypt);323 $event = new Event\Crypt\Failed($crypt);324 $this->eventDispatcher->dispatch(Event\Crypt\Failed::NAME, $event);325 }326 /**327 * Return amount of failed crypts.328 *329 * @return integer330 */331 public function cryptsFailedCount()332 {333 return $this->cryptsFailed;334 }335 /**336 * Crypt end event.337 *338 * @param \phpbu\App\Configuration\Backup\Crypt $crypt339 */340 public function cryptEnd(Configuration\Backup\Crypt $crypt)341 {342 $event = new Event\Crypt\End($crypt);343 $this->eventDispatcher->dispatch(Event\Crypt\End::NAME, $event);344 }345 /**346 * Sync start event.347 *348 * @param \phpbu\App\Configuration\Backup\Sync $sync349 */350 public function syncStart(Configuration\Backup\Sync $sync)351 {352 $this->backupActive->syncAdd($sync);353 $event = new Event\Sync\Start($sync);354 $this->eventDispatcher->dispatch(Event\Sync\Start::NAME, $event);355 }356 /**357 * Sync skipped event.358 *359 * @param \phpbu\App\Configuration\Backup\Sync $sync360 */361 public function syncSkipped(Configuration\Backup\Sync $sync)362 {363 $this->syncsSkipped++;364 $this->backupActive->syncSkipped($sync);365 $event = new Event\Sync\Skipped($sync);366 $this->eventDispatcher->dispatch(Event\Sync\Skipped::NAME, $event);367 }368 /**369 * Return amount of skipped syncs.370 *371 * @return integer372 */373 public function syncsSkippedCount()374 {375 return $this->syncsSkipped;376 }377 /**378 * Sync failed event.379 *380 * @param \phpbu\App\Configuration\Backup\Sync $sync381 */382 public function syncFailed(Configuration\Backup\Sync $sync)383 {384 $this->syncsFailed++;385 $this->backupActive->syncFailed($sync);386 $event = new Event\Sync\Failed($sync);387 $this->eventDispatcher->dispatch(Event\Sync\Failed::NAME, $event);388 }389 /**390 * Return amount of failed syncs.391 *392 * @return integer393 */394 public function syncsFailedCount()395 {396 return $this->syncsFailed;397 }398 /**399 * Sync end event.400 *401 * @param \phpbu\App\Configuration\Backup\Sync $sync402 */403 public function syncEnd(Configuration\Backup\Sync $sync)404 {405 $event = new Event\Sync\End($sync);406 $this->eventDispatcher->dispatch(Event\Sync\End::NAME, $event);407 }408 /**409 * Cleanup start event.410 *411 * @param \phpbu\App\Configuration\Backup\Cleanup $cleanup412 */413 public function cleanupStart(Configuration\Backup\Cleanup $cleanup)414 {415 $this->backupActive->cleanupAdd($cleanup);416 $event = new Event\Cleanup\Start($cleanup);417 $this->eventDispatcher->dispatch(Event\Cleanup\Start::NAME, $event);418 }419 /**420 * Cleanup skipped event.421 *422 * @param \phpbu\App\Configuration\Backup\Cleanup $cleanup423 */424 public function cleanupSkipped(Configuration\Backup\Cleanup $cleanup)425 {426 $this->cleanupsSkipped++;427 $this->backupActive->cleanupSkipped($cleanup);428 $event = new Event\Cleanup\Skipped($cleanup);429 $this->eventDispatcher->dispatch(Event\Cleanup\Skipped::NAME, $event);430 }431 /**432 * Return amount of skipped cleanups.433 *434 * @return integer435 */436 public function cleanupsSkippedCount()437 {438 return $this->cleanupsSkipped;439 }440 /**441 * Cleanup failed event.442 *443 * @param \phpbu\App\Configuration\Backup\Cleanup $cleanup444 */445 public function cleanupFailed(Configuration\Backup\Cleanup $cleanup)446 {447 $this->cleanupsFailed++;448 $this->backupActive->cleanupFailed($cleanup);449 $event = new Event\Cleanup\Failed($cleanup);450 $this->eventDispatcher->dispatch(Event\Cleanup\Failed::NAME, $event);451 }452 /**453 * Return amount of failed cleanups.454 *455 * @return integer456 */457 public function cleanupsFailedCount()458 {459 return $this->cleanupsFailed;460 }461 /**462 * Cleanup end event.463 *464 * @param \phpbu\App\Configuration\Backup\Cleanup $cleanup465 */466 public function cleanupEnd(Configuration\Backup\Cleanup $cleanup)467 {468 $event = new Event\Cleanup\End($cleanup);469 $this->eventDispatcher->dispatch(Event\Cleanup\End::NAME, $event);470 }471 /**472 * Debug.473 *474 * @param string $msg475 */476 public function debug($msg)477 {478 $event = new Event\Debug($msg);479 $this->eventDispatcher->dispatch(Event\Debug::NAME, $event);480 }481}...

Full Screen

Full Screen

optimize.class.php

Source:optimize.class.php Github

copy

Full Screen

...9 {10 parent::__construct();11 }12 13 function cleanup_system($cleanupType){14 15 $cleanup_values = array();16 $cleanup_values['value_array'] = array();17 $text = '';1819 if (isset($cleanupType["clean-revisions"])) {20 $values = self::cleanup_type_process('revisions');21 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";22 $cleanup_values['value_array']['revisions'] = $values['value'];23 }24 25 if (isset($cleanupType["clean-autodraft"])) {26 $values = self::cleanup_type_process('autodraft');27 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";28 $cleanup_values['value_array']['autodraft'] = $values['value'];29 } 30 31 if (isset($cleanupType["clean-comments"])) {32 $values = self::cleanup_type_process('spam');33 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";34 $cleanup_values['value_array']['spam'] = $values['value'];35 }36 37 if (isset($cleanupType["unapproved-comments"])) {38 $values = self::cleanup_type_process('unapproved');39 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";40 $cleanup_values['value_array']['unapproved'] = $values['value'];41 }42 if (isset($cleanupType["trash-post"])) {43 $values = self::cleanup_type_process('trash-post');44 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";45 $cleanup_values['value_array']['trash-post'] = $values['value'];46 }47 if (isset($cleanupType["trash-comments"])) {48 $values = self::cleanup_type_process('trash-comments');49 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";50 $cleanup_values['value_array']['trash-comments'] = $values['value'];51 }52 if (isset($cleanupType["meta-comments"])) {53 $values = self::cleanup_type_process('meta-comments');54 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";55 $cleanup_values['value_array']['meta-comments'] = $values['value'];56 }57 if (isset($cleanupType["meta-posts"])) {58 $values = self::cleanup_type_process('meta-posts');59 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";60 $cleanup_values['value_array']['meta-posts'] = $values['value'];61 }62 if (isset($cleanupType["pingbacks"])) {63 $values = self::cleanup_type_process('pingbacks');64 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";65 $cleanup_values['value_array']['pingbacks'] = $values['value'];66 }67 if (isset($cleanupType["trackbacks"])) {68 $values = self::cleanup_type_process('trackbacks');69 $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";70 $cleanup_values['value_array']['trackbacks'] = $values['value'];71 }72 73 74 $text .= '<br>';75 76 if (isset($cleanupType["optimize-db"])) {77 $values = self::cleanup_type_process('optimize-db');78 $text .= "<span class='wpm_results_db'>" . $values['message'] . "</span>";79 $cleanup_values['value_array']['optimize-db'] = $values['value'];80 //$text .= DB_NAME.__(" Database Optimized!<br>", 'wp-optimize');81 }82 83 if ($text !==''){84 $cleanup_values['message'] = $text;85 return $cleanup_values;86 }87 }88 89 function cleanup_type_process($cleanupType){90 global $wpdb;91 $clean = ""; $message = "";92 $message_array = array();93 //$message_array['value'] = array();94 $optimized = array();95 96 switch ($cleanupType) {97 98 case "revisions":99 $clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";100 $revisions = $wpdb->query( $clean );101 $message .= __('Post revisions deleted - ', 'wp-optimize') . $revisions;102 $message_array['value'] = $revisions;103 //$message_array['del_post_rev']['message'] = $revisions.__(' post revisions deleted<br>', 'wp-optimize');104 105 break;106 107 108 case "autodraft":109 $clean = "DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'";110 $autodraft = $wpdb->query( $clean ); ...

Full Screen

Full Screen

intermediary_post_cleanup.php

Source:intermediary_post_cleanup.php Github

copy

Full Screen

...10 * @since 2.5.1011 */12class Toolset_Ajax_Handler_Intermediary_Post_Cleanup extends Toolset_Ajax_Handler_Abstract {13 /** @var Toolset_Association_Cleanup_Factory */14 private $cleanup_factory;15 /** @var Toolset_Cron */16 private $cron;17 /**18 * Toolset_Ajax_Handler_Intermediary_Post_Cleanup constructor.19 *20 * @param Toolset_Ajax $ajax_manager21 * @param Toolset_Association_Cleanup_Factory|null $cleanup_factory_di22 * @param Toolset_Cron|null $cron_di23 */24 public function __construct(25 Toolset_Ajax $ajax_manager,26 Toolset_Association_Cleanup_Factory $cleanup_factory_di = null,27 Toolset_Cron $cron_di = null28 ) {29 parent::__construct( $ajax_manager );30 $this->cleanup_factory = $cleanup_factory_di ?: new Toolset_Association_Cleanup_Factory();31 $this->cron = $cron_di ?: Toolset_Cron::get_instance();32 }33 /**34 * Processes the Ajax call35 *36 * @param array $arguments Original action arguments.37 *38 * @return void39 */40 function process_call( $arguments ) {41 $this->ajax_begin( array( 'nonce' => Toolset_Ajax::CALLBACK_INTERMEDIARY_POST_CLEANUP ) );42 $current_step = (int) toolset_getpost( 'current_step' );43 $cleanup = $this->cleanup_factory->dangling_intermediary_posts();44 $cleanup->do_batch();45 $number_of_deleted_posts = $cleanup->get_deleted_posts();46 // This will consequently hide the admin notice about dangling intermediary posts needing to be deleted.47 if( ! $cleanup->has_remaining_posts() ) {48 $event = $this->cleanup_factory->cron_event();49 $this->cron->unschedule_event( $event );50 }51 $message = sprintf(52 (53 $cleanup->has_remaining_posts()54 ? __( 'Deleted %d dangling intermediary posts...', 'wpcf' )55 : __( 'Deleted %d dangling intermediary posts. Operation completed.', 'wpcf' )56 ),57 $number_of_deleted_posts58 );59 $this->ajax_finish(60 array(61 'continue' => $cleanup->has_remaining_posts(),62 'message' => $message,63 'ajax_arguments' => array(64 'current_step' => $current_step + 165 )66 )67 );68 }69}...

Full Screen

Full Screen

cleanup

Using AI Code Generation

copy

Full Screen

1$test = new pts_test_profile('test');2$test->test_profile->cleanup();3$test = new pts_test_profile('test');4$test->test_profile->cleanup();5$test = new pts_test_profile('test');6$test->test_profile->cleanup();7$test = new pts_test_profile('test');8$test->test_profile->cleanup();9$test = new pts_test_profile('test');10$test->test_profile->cleanup();11$test = new pts_test_profile('test');12$test->test_profile->cleanup();13$test = new pts_test_profile('test');14$test->test_profile->cleanup();15$test = new pts_test_profile('test');16$test->test_profile->cleanup();17$test = new pts_test_profile('test');18$test->test_profile->cleanup();19$test = new pts_test_profile('test');20$test->test_profile->cleanup();21$test = new pts_test_profile('test');22$test->test_profile->cleanup();23$test = new pts_test_profile('test');24$test->test_profile->cleanup();25$test = new pts_test_profile('test');26$test->test_profile->cleanup();

Full Screen

Full Screen

cleanup

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/phoronix-test-suite.php');2$cleanup = new pts_cleanup();3$cleanup->cleanup_system();4require_once('pts-core/phoronix-test-suite.php');5$test_profile = new pts_test_profile();6$test_profile->get_test_profile();7require_once('pts-core/phoronix-test-suite.php');8$test_profile = new pts_test_profile();9$test_profile->get_test_profile();10require_once('pts-core/phoronix-test-suite.php');11$test_profile = new pts_test_profile();12$test_profile->get_test_profile();13require_once('pts-core/phoronix-test-suite.php');14$test_profile = new pts_test_profile();15$test_profile->get_test_profile();16require_once('pts-core/phoronix-test-suite.php');17$test_profile = new pts_test_profile();18$test_profile->get_test_profile();19require_once('pts-core/phoronix-test-suite.php');20$test_profile = new pts_test_profile();21$test_profile->get_test_profile();22require_once('pts-core/phoronix-test-suite.php');23$test_profile = new pts_test_profile();24$test_profile->get_test_profile();25require_once('pts-core/phoronix-test-suite.php');26$test_profile = new pts_test_profile();27$test_profile->get_test_profile();28require_once('pts-core/phoronix-test-suite.php');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful