当前位置: 首页>>代码示例>>PHP>>正文


PHP blc_cleanup_links函数代码示例

本文整理汇总了PHP中blc_cleanup_links函数的典型用法代码示例。如果您正苦于以下问题:PHP blc_cleanup_links函数的具体用法?PHP blc_cleanup_links怎么用?PHP blc_cleanup_links使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了blc_cleanup_links函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: blc_cleanup_database

 /**
  * Delete synch. records, instances and links that refer to missing or invalid items.
  * 
  * @return void
  */
 function blc_cleanup_database()
 {
     global $blclog;
     //Delete synch. records for container types that don't exist
     $blclog->info('... Deleting invalid container records');
     blcContainerHelper::cleanup_containers();
     //Delete invalid instances
     $blclog->info('... Deleting invalid link instances');
     blc_cleanup_instances();
     //Delete orphaned links
     $blclog->info('... Deleting orphaned links');
     blc_cleanup_links();
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:18,代码来源:init.php

示例2: work

 /**
  * The main worker function that does all kinds of things.
  *
  * @return void
  */
 function work()
 {
     global $wpdb;
     if (!$this->acquire_lock()) {
         //FB::warn("Another instance of BLC is already working. Stop.");
         return;
     }
     if ($this->server_too_busy()) {
         //FB::warn("Server is too busy. Stop.");
         return;
     }
     $this->start_timer();
     $max_execution_time = $this->conf->options['max_execution_time'];
     /*****************************************
     						Preparation
     		******************************************/
     // Check for safe mode
     if (blcUtility::is_safe_mode()) {
         // Do it the safe mode way - obey the existing max_execution_time setting
         $t = ini_get('max_execution_time');
         if ($t && $t < $max_execution_time) {
             $max_execution_time = $t - 1;
         }
     } else {
         // Do it the regular way
         @set_time_limit($max_execution_time * 2);
         //x2 should be plenty, running any longer would mean a glitch.
     }
     //Don't stop the script when the connection is closed
     ignore_user_abort(true);
     //Close the connection as per http://www.php.net/manual/en/features.connection-handling.php#71172
     //This reduces resource usage and may solve the mysterious slowdowns certain users have
     //encountered when activating the plugin.
     //(Disable when debugging or you won't get the FirePHP output)
     if (!headers_sent() && (!defined('BLC_DEBUG') || !constant('BLC_DEBUG'))) {
         @ob_end_clean();
         //Discard the existing buffer, if any
         header("Connection: close");
         ob_start();
         echo 'Connection closed';
         //This could be anything
         $size = ob_get_length();
         header("Content-Length: {$size}");
         ob_end_flush();
         // Strange behaviour, will not work
         flush();
         // Unless both are called !
     }
     //Load modules for this context
     $moduleManager = blcModuleManager::getInstance();
     $moduleManager->load_modules('work');
     /*****************************************
     				Parse posts and bookmarks
     		******************************************/
     $orphans_possible = false;
     $still_need_resynch = $this->conf->options['need_resynch'];
     if ($still_need_resynch) {
         //FB::log("Looking for containers that need parsing...");
         while ($containers = blcContainerHelper::get_unsynched_containers(50)) {
             //FB::log($containers, 'Found containers');
             foreach ($containers as $container) {
                 //FB::log($container, "Parsing container");
                 $container->synch();
                 //Check if we still have some execution time left
                 if ($this->execution_time() > $max_execution_time) {
                     //FB::log('The alloted execution time has run out');
                     blc_cleanup_links();
                     $this->release_lock();
                     return;
                 }
                 //Check if the server isn't overloaded
                 if ($this->server_too_busy()) {
                     //FB::log('Server overloaded, bailing out.');
                     blc_cleanup_links();
                     $this->release_lock();
                     return;
                 }
             }
             $orphans_possible = true;
         }
         //FB::log('No unparsed items found.');
         $still_need_resynch = false;
     } else {
         //FB::log('Resynch not required.');
     }
     /******************************************
     				    Resynch done?
     		*******************************************/
     if ($this->conf->options['need_resynch'] && !$still_need_resynch) {
         $this->conf->options['need_resynch'] = $still_need_resynch;
         $this->conf->save_options();
     }
     /******************************************
     				    Remove orphaned links
     		*******************************************/
//.........这里部分代码省略.........
开发者ID:ahsaeldin,项目名称:projects,代码行数:101,代码来源:core.php

示例3: hook_delete_link

 /**
  * When a bookmark is deleted, remove the related DB records.
  *
  * @param int $link_id
  * @return void
  */
 function hook_delete_link($link_id)
 {
     //Get the container object.
     $container = blcContainerHelper::get_container(array($this->container_type, $link_id));
     //Get the link(s) associated with it.
     $links = $container->get_links();
     //Remove synch. record & instance records.
     $container->delete();
     //Clean up links associated with this bookmark (there's probably only one)
     $link_ids = array();
     foreach ($links as $link) {
         $link_ids[] = $link->link_id;
     }
     blc_cleanup_links($link_ids);
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:21,代码来源:blogroll.php

示例4: hook_trashed_post_comments

 function hook_trashed_post_comments($post_id, $statuses)
 {
     foreach ($statuses as $comment_id => $comment_status) {
         if ($comment_status == '1') {
             $container = blcContainerHelper::get_container(array($this->container_type, $comment_id));
             $container->delete();
         }
     }
     blc_cleanup_links();
 }
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:10,代码来源:comment.php

示例5: work

 /**
  * The main worker function that does all kinds of things.
  *
  * @return void
  */
 function work()
 {
     global $blclog;
     //Close the session to prevent lock-ups.
     //PHP sessions are blocking. session_start() will wait until all other scripts that are using the same session
     //are finished. As a result, a long-running script that unintentionally keeps the session open can cause
     //the entire site to "lock up" for the current user/browser. WordPress itself doesn't use sessions, but some
     //plugins do, so we should explicitly close the session (if any) before starting the worker.
     if (session_id() != '') {
         session_write_close();
     }
     if (!$this->acquire_lock()) {
         //FB::warn("Another instance of BLC is already working. Stop.");
         $blclog->info('Another instance of BLC is already working. Stop.');
         return;
     }
     if ($this->server_too_busy()) {
         //FB::warn("Server is too busy. Stop.");
         $blclog->warn('Server load is too high, stopping.');
         return;
     }
     $this->start_timer();
     $blclog->info('work() starts');
     $max_execution_time = $this->conf->options['max_execution_time'];
     /*****************************************
     						Preparation
     		******************************************/
     // Check for safe mode
     if (blcUtility::is_safe_mode()) {
         // Do it the safe mode way - obey the existing max_execution_time setting
         $t = ini_get('max_execution_time');
         if ($t && $t < $max_execution_time) {
             $max_execution_time = $t - 1;
         }
     } else {
         // Do it the regular way
         @set_time_limit($max_execution_time * 2);
         //x2 should be plenty, running any longer would mean a glitch.
     }
     //Don't stop the script when the connection is closed
     ignore_user_abort(true);
     //Close the connection as per http://www.php.net/manual/en/features.connection-handling.php#71172
     //This reduces resource usage.
     //(Disable when debugging or you won't get the FirePHP output)
     if (!headers_sent() && (defined('DOING_AJAX') && constant('DOING_AJAX')) && (!defined('BLC_DEBUG') || !constant('BLC_DEBUG'))) {
         @ob_end_clean();
         //Discard the existing buffer, if any
         header("Connection: close");
         ob_start();
         echo 'Connection closed';
         //This could be anything
         $size = ob_get_length();
         header("Content-Length: {$size}");
         ob_end_flush();
         // Strange behaviour, will not work
         flush();
         // Unless both are called !
     }
     //Load modules for this context
     $moduleManager = blcModuleManager::getInstance();
     $moduleManager->load_modules('work');
     $target_usage_fraction = $this->conf->get('target_resource_usage', 0.25);
     //Target usage must be between 1% and 100%.
     $target_usage_fraction = max(min($target_usage_fraction, 1), 0.01);
     /*****************************************
     				Parse posts and bookmarks
     		******************************************/
     $orphans_possible = false;
     $still_need_resynch = $this->conf->options['need_resynch'];
     if ($still_need_resynch) {
         //FB::log("Looking for containers that need parsing...");
         $max_containers_per_query = 50;
         $start = microtime(true);
         $containers = blcContainerHelper::get_unsynched_containers($max_containers_per_query);
         $get_containers_time = microtime(true) - $start;
         while (!empty($containers)) {
             //FB::log($containers, 'Found containers');
             $this->sleep_to_maintain_ratio($get_containers_time, $target_usage_fraction);
             foreach ($containers as $container) {
                 $synch_start_time = microtime(true);
                 //FB::log($container, "Parsing container");
                 $container->synch();
                 $synch_elapsed_time = microtime(true) - $synch_start_time;
                 $blclog->info(sprintf('Parsed container %s[%s] in %.2f ms', $container->container_type, $container->container_id, $synch_elapsed_time * 1000));
                 //Check if we still have some execution time left
                 if ($this->execution_time() > $max_execution_time) {
                     //FB::log('The allotted execution time has run out');
                     blc_cleanup_links();
                     $this->release_lock();
                     return;
                 }
                 //Check if the server isn't overloaded
                 if ($this->server_too_busy()) {
                     //FB::log('Server overloaded, bailing out.');
                     blc_cleanup_links();
//.........这里部分代码省略.........
开发者ID:ManageWP,项目名称:broken-link-checker,代码行数:101,代码来源:core.php

示例6: post_deleted

 /**
  * Delete custom field synch. records when the post that they belong to is deleted.
  *
  * @param int $post_id
  * @return void
  */
 function post_deleted($post_id)
 {
     //Get the associated container object
     $container =& blcContainerHelper::get_container(array($this->container_type, intval($post_id)));
     //Delete it
     $container->delete();
     //Clean up any dangling links
     blc_cleanup_links();
 }
开发者ID:Weissenberger13,项目名称:web.portugalrentalcottages,代码行数:15,代码来源:custom_field.php

示例7: post_deleted

 /**
  * Remove the synch. record and link instances associated with a post when it's deleted 
  *
  * @param int $post_id
  * @return void
  */
 function post_deleted($post_id)
 {
     //Get the container type matching the type of the deleted post
     $post = get_post($post_id);
     if (!$post) {
         return;
     }
     //Get the associated container object
     $post_container = blcContainerHelper::get_container(array($post->post_type, intval($post_id)));
     if ($post_container) {
         //Delete it
         $post_container->delete();
         //Clean up any dangling links
         blc_cleanup_links();
     }
 }
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:22,代码来源:any-post.php

示例8: hook_post_deleted

 public static function hook_post_deleted($post_id)
 {
     if (get_option('mainwp_linkschecker_ext_enabled') !== "Y") {
         return;
     }
     if (!defined('BLC_ACTIVE') || !function_exists('blc_init')) {
         return;
     }
     blc_init();
     //Get the container type matching the type of the deleted post
     $post = get_post($post_id);
     if (!$post) {
         return;
     }
     //Get the associated container object
     $post_container = blcContainerHelper::get_container(array($post->post_type, intval($post_id)));
     if ($post_container) {
         //Delete it
         $post_container->delete();
         //Clean up any dangling links
         blc_cleanup_links();
     }
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:23,代码来源:MainWPChildLinksChecker.class.php

示例9: hook_comment_status

 function hook_comment_status($new_status, $old_status, $comment)
 {
     $container = blc_get_container(array($this->container_type, $comment->comment_ID));
     if ($new_status == 'approved') {
         $container->mark_as_unsynched();
     } else {
         $container->delete();
         blc_cleanup_links();
     }
 }
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:10,代码来源:comment.php

示例10: blc_resynch

/**
 * (Re)create synchronization records for all containers and mark them all as unparsed.
 *
 * @param bool $forced If true, the plugin will recreate all synch. records from scratch.
 * @return void
 */
function blc_resynch($forced = false)
{
    global $wpdb, $blclog;
    if ($forced) {
        $blclog->info('... Forced resynchronization initiated');
        //Drop all synchronization records
        $wpdb->query("TRUNCATE {$wpdb->prefix}blc_synch");
    } else {
        $blclog->info('... Resynchronization initiated');
    }
    //(Re)create and update synch. records for all container types.
    $blclog->info('... (Re)creating container records');
    blc_resynch_containers($forced);
    //Delete invalid instances
    $blclog->info('... Deleting invalid link instances');
    blc_cleanup_instances();
    //Delete orphaned links
    $blclog->info('... Deleting orphaned links');
    blc_cleanup_links();
    $blclog->info('... Setting resync. flags');
    blc_got_unsynched_items();
    //All done.
    $blclog->info('Database resynchronization complete.');
}
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:30,代码来源:broken-link-checker.php


注:本文中的blc_cleanup_links函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。