Changeset 2010196
- Timestamp:
- 01/10/2019 07:50:59 PM (7 years ago)
- Location:
- laiser-tag
- Files:
-
- 10 edited
-
tags/1.2/assets/images/calais-logo.png (modified) (previous)
-
tags/1.2/include/OpenCalais/OpenCalais.php (modified) (1 diff)
-
tags/1.2/include/Tagging.php (modified) (4 diffs)
-
tags/1.2/laisertag.php (modified) (2 diffs)
-
tags/1.2/readme.txt (modified) (2 diffs)
-
trunk/assets/images/calais-logo.png (modified) (previous)
-
trunk/include/OpenCalais/OpenCalais.php (modified) (1 diff)
-
trunk/include/Tagging.php (modified) (4 diffs)
-
trunk/laisertag.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
laiser-tag/tags/1.2/include/OpenCalais/OpenCalais.php
r2009527 r2010196 79 79 80 80 if(is_a($response, 'WP_Error')) { 81 throw new \Exception('WordPress API error, could not complete tagging.'); 81 error_log($response); 82 throw new OpenCalaisException('WordPress API error, could not complete tagging: '.$response->get_error_message()); 82 83 } 83 84 84 85 $object = json_decode($response['body']); 85 86 if (empty($object)) { 86 error_log( $response);87 error_log(print_r($response, true)); 87 88 throw new OpenCalaisException('No response was received from the API.'); 88 89 } elseif (isset($object->fault)) { -
laiser-tag/tags/1.2/include/Tagging.php
r2009527 r2010196 307 307 308 308 // file check to stop this cron from running simultaneously 309 if( file_exists(LTOC_PROCESS_FILE)) {309 if($this->isProcessRunning()) { 310 310 echo "in progress"; 311 311 die; 312 312 } 313 313 314 touch(LTOC_PROCESS_FILE);315 314 unlink(LTOC_BATCH_LOG); 316 315 touch(LTOC_BATCH_LOG); … … 355 354 sleep(2); 356 355 } 356 // unlink the process file, saves us having to check for the process later 357 357 unlink(LTOC_PROCESS_FILE); 358 358 $finalresult = "$tagged posts tagged successfully."; … … 366 366 $finalresult .= " $tags_not_stored posts returned tags but were not stored."; 367 367 } 368 369 file_put_contents(LTOC_BATCH_LOG, date('Y-m-d H:i:s', time())." :: Batch process completed. $finalresult\n", FILE_APPEND); 368 $this->batchLog("Batch process completed. $finalresult"); 370 369 } 371 370 … … 524 523 return $cat_parent_id; 525 524 } 525 526 private function isProcessRunning() { 527 touch(LTOC_PROCESS_FILE); 528 $last_pid = file_get_contents(LTOC_PROCESS_FILE); 529 if(!empty($last_pid)) { 530 exec('ps aux | grep "'.$last_pid.'"', $output, $result); 531 foreach ($output as $line) { 532 // compress spaces, then get the PID from the start of the line 533 $line = preg_replace('/\s+/', ' ', $line); 534 $splits = explode(' ', $line); 535 $pid = $splits[1]; 536 if($pid == $last_pid) { 537 // then there is a process still running with the last recorded PID for this process 538 return true; 539 } 540 } 541 } 542 // at this point we're sure there is no other process running 543 file_put_contents(LTOC_PROCESS_FILE, getmypid()); 544 return false; 545 } 526 546 } -
laiser-tag/tags/1.2/laisertag.php
r2009527 r2010196 9 9 * Plugin URI: https://developer.wordpress.org/plugins/laiser-tag/ 10 10 * Description: Uses the OpenCalais API to automatically generate tags for existing posts. 11 * Version: 1.2. 011 * Version: 1.2.1 12 12 * Author: PCIS 13 13 * Author URI: http://www.pcis.com/laiser-tag … … 21 21 } 22 22 23 define('LTOC_PLUGIN_VERSION', '1.2. 0');23 define('LTOC_PLUGIN_VERSION', '1.2.1'); 24 24 define('LTOC_PLUGIN_PATH', dirname(__FILE__)); 25 25 define('LTOC_TEMPLATES', dirname(__FILE__) . '/templates/'); -
laiser-tag/tags/1.2/readme.txt
r2010168 r2010196 4 4 Requires at least: 4.6 5 5 Tested up to: 5.0 6 Stable tag: 1.2. 06 Stable tag: 1.2.1 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 88 88 == Changelog == 89 89 90 = 1.2.1 = 91 * Improved error handling 92 * Improved functionality for checking if the tagging cron is already running 93 90 94 = 1.2.0 = 91 95 * Major UI changes; enhanced display and ease of use -
laiser-tag/trunk/include/OpenCalais/OpenCalais.php
r2009527 r2010196 79 79 80 80 if(is_a($response, 'WP_Error')) { 81 throw new \Exception('WordPress API error, could not complete tagging.'); 81 error_log($response); 82 throw new OpenCalaisException('WordPress API error, could not complete tagging: '.$response->get_error_message()); 82 83 } 83 84 84 85 $object = json_decode($response['body']); 85 86 if (empty($object)) { 86 error_log( $response);87 error_log(print_r($response, true)); 87 88 throw new OpenCalaisException('No response was received from the API.'); 88 89 } elseif (isset($object->fault)) { -
laiser-tag/trunk/include/Tagging.php
r2009521 r2010196 307 307 308 308 // file check to stop this cron from running simultaneously 309 if( file_exists(LTOC_PROCESS_FILE)) {309 if($this->isProcessRunning()) { 310 310 echo "in progress"; 311 311 die; 312 312 } 313 313 314 touch(LTOC_PROCESS_FILE);315 314 unlink(LTOC_BATCH_LOG); 316 315 touch(LTOC_BATCH_LOG); … … 355 354 sleep(2); 356 355 } 356 // unlink the process file, saves us having to check for the process later 357 357 unlink(LTOC_PROCESS_FILE); 358 358 $finalresult = "$tagged posts tagged successfully."; … … 366 366 $finalresult .= " $tags_not_stored posts returned tags but were not stored."; 367 367 } 368 369 file_put_contents(LTOC_BATCH_LOG, date('Y-m-d H:i:s', time())." :: Batch process completed. $finalresult\n", FILE_APPEND); 368 $this->batchLog("Batch process completed. $finalresult"); 370 369 } 371 370 … … 524 523 return $cat_parent_id; 525 524 } 525 526 private function isProcessRunning() { 527 touch(LTOC_PROCESS_FILE); 528 $last_pid = file_get_contents(LTOC_PROCESS_FILE); 529 if(!empty($last_pid)) { 530 exec('ps aux | grep "'.$last_pid.'"', $output, $result); 531 foreach ($output as $line) { 532 // compress spaces, then get the PID from the start of the line 533 $line = preg_replace('/\s+/', ' ', $line); 534 $splits = explode(' ', $line); 535 $pid = $splits[1]; 536 if($pid == $last_pid) { 537 // then there is a process still running with the last recorded PID for this process 538 return true; 539 } 540 } 541 } 542 // at this point we're sure there is no other process running 543 file_put_contents(LTOC_PROCESS_FILE, getmypid()); 544 return false; 545 } 526 546 } -
laiser-tag/trunk/laisertag.php
r2009521 r2010196 9 9 * Plugin URI: https://developer.wordpress.org/plugins/laiser-tag/ 10 10 * Description: Uses the OpenCalais API to automatically generate tags for existing posts. 11 * Version: 1.2. 011 * Version: 1.2.1 12 12 * Author: PCIS 13 13 * Author URI: http://www.pcis.com/laiser-tag … … 21 21 } 22 22 23 define('LTOC_PLUGIN_VERSION', '1.2. 0');23 define('LTOC_PLUGIN_VERSION', '1.2.1'); 24 24 define('LTOC_PLUGIN_PATH', dirname(__FILE__)); 25 25 define('LTOC_TEMPLATES', dirname(__FILE__) . '/templates/'); -
laiser-tag/trunk/readme.txt
r2010168 r2010196 4 4 Requires at least: 4.6 5 5 Tested up to: 5.0 6 Stable tag: 1.2. 06 Stable tag: 1.2.1 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 88 88 == Changelog == 89 89 90 = 1.2.1 = 91 * Improved error handling 92 * Improved functionality for checking if the tagging cron is already running 93 90 94 = 1.2.0 = 91 95 * Major UI changes; enhanced display and ease of use
Note: See TracChangeset
for help on using the changeset viewer.