Changeset 16096
- Timestamp:
- 04/15/08 16:29:18 (4 months ago)
- Files:
-
- branches/MidCOM_2_8/midcom.helper.replicator/config/config.inc (modified) (1 diff)
- branches/MidCOM_2_8/midcom.helper.replicator/exporter/mirror.php (modified) (2 diffs)
- branches/MidCOM_2_8/midcom.helper.replicator/exporter/staging2live.php (modified) (10 diffs)
- branches/MidCOM_2_8/midcom.helper.replicator/logger.php (modified) (2 diffs)
- branches/MidCOM_2_8/midcom.helper.replicator/manager.php (modified) (2 diffs)
- branches/MidCOM_2_8/midcom.helper.replicator/queuemanager.php (modified) (3 diffs)
- branches/MidCOM_2_8/midcom.helper.replicator/style/midcom-helper-replicator-object.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/MidCOM_2_8/midcom.helper.replicator/config/config.inc
r16086 r16096 1 'queue_root_dir' => '/var/spool/midgard/replicator_queue/ ',1 'queue_root_dir' => '/var/spool/midgard/replicator_queue//', 2 2 'log_filename' => "{$GLOBALS['midcom_config']['log_filename']}.replicator", 3 3 'exporter_staging2live_check_approvals_for' => array branches/MidCOM_2_8/midcom.helper.replicator/exporter/mirror.php
r15913 r16096 31 31 function is_exportable_by_metadata(&$object) 32 32 { 33 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable_by_metadata called"); 33 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable_by_metadata called"); 34 //TODO: Is there a more graceful way to do this ? (see also manager.php) 35 $check_exported = true; 36 if ( isset($GLOBALS['midcom_helper_replicator_exporter_retry_mode']) 37 && !empty($GLOBALS['midcom_helper_replicator_exporter_retry_mode'])) 38 { 39 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "Retry mode, not checking metadata->exported"); 40 return true; 41 } 34 42 if ( $object->metadata->deleted 35 43 || ( isset($this->_serialize_rewrite_to_delete[$object->guid]) … … 74 82 { 75 83 // This has been exported already 76 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has alrady been exported ({$exported_unixtime} >= {$revised_unixtime}), returning false", MIDCOM_LOG_INFO);84 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "has alrady been exported", MIDCOM_LOG_INFO); 77 85 return false; 78 86 } branches/MidCOM_2_8/midcom.helper.replicator/exporter/staging2live.php
r16092 r16096 43 43 44 44 /** 45 * This is the main entry point of the exporter. Since we're mirroring 46 * all content this will always return true. 45 * This is the main entry point of the exporter, we'll do some approval and scheduling checks 47 46 * 48 47 * @param midgard_object $object The Object to export parameters of 48 * @param boolean $check_exported check if the object has already been exported or not 49 49 * @return boolean Whether the object may be exported with this exporter 50 * @todo log the debug messages to generic debug log and log only more informative reasons to object replication log 50 51 */ 51 52 function is_exportable(&$object, $check_exported = true) … … 85 86 { 86 87 // CAVEAT: may cause issues with multiple subscriptions 87 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]);88 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]); 88 89 $this->exportability[$object->guid] = parent::is_exportable_by_metadata(&$object); 89 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]);90 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER is_exportable_by_metadata check: exportability = " . (int)$this->exportability[$object->guid]); 90 91 } 91 92 92 93 // Approvals checks 93 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE approval check: exportability = " . (int)$this->exportability[$object->guid]);94 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE approval check: exportability = " . (int)$this->exportability[$object->guid]); 94 95 $this->_check_approval($object); 95 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER approval check: exportability = " . (int)$this->exportability[$object->guid]);96 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER approval check: exportability = " . (int)$this->exportability[$object->guid]); 96 97 97 98 /** … … 135 136 } 136 137 } 137 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE schedule check: \$schedule_action = {$schedule_action}, exportability = " . (int)$this->exportability[$object->guid]);138 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "BEFORE schedule check: \$schedule_action = {$schedule_action}, exportability = " . (int)$this->exportability[$object->guid]); 138 139 switch ($schedule_action) 139 140 { … … 175 176 break; 176 177 } 177 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER schedule check: exportability = " . (int)$this->exportability[$object->guid]);178 179 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable checks done, returning " . (int)$this->exportability[$object->guid]);178 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "AFTER schedule check: exportability = " . (int)$this->exportability[$object->guid]); 179 180 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "is_exportable checks done, returning " . (int)$this->exportability[$object->guid]); 180 181 $GLOBALS['midcom_helper_replicator_logger']->pop_prefix(); 181 182 return $this->exportability[$object->guid]; … … 187 188 debug_push_class(__CLASS__, __FUNCTION__); 188 189 debug_add("Called for {$object->guid}"); 189 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "_check_approval called");190 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, "_check_approval called"); 190 191 191 192 // Do not check approvals for deletes … … 196 197 $msg = 'Object is deleted, do not check approvals, setting exportability explicitly to true'; 197 198 $this->exportability[$object->guid] = true; 198 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, $msg );199 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, $msg, MIDCOM_LOG_INFO); 199 200 debug_add($msg); 200 201 debug_pop(); … … 226 227 { 227 228 // Child articles don't currently have any approval UI, skip approval for them (but do check parent below) 228 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, ' Child article, not checking approval status');229 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Reply article, not checking approval status', MIDCOM_LOG_INFO); 229 230 $this->exportability[$object->guid] = true; 230 231 } … … 233 234 // FIXME: use metadata service (?) 234 235 // Not approved since last update 235 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, ' Not approved, skipping');236 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because it\'s not approved', MIDCOM_LOG_WARN); 236 237 $this->exportability[$object->guid] = false; 237 238 } … … 250 251 if (!$this->exportability[$object->guid]) 251 252 { 252 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Parent not approved, skipping');253 //$GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Parent not approved, skipping'); 253 254 if (empty($parent_check_stack)) 254 255 { 255 256 // Empty stack means we're not inside parent recursion, thus we can raise an UIMessage 256 $_MIDCOM->load_library('midcom.helper.reflector');257 257 $ref = new midcom_helper_reflector($object); 258 258 $_MIDCOM->uimessages->add … … 267 267 'warning' 268 268 ); 269 unset($ref); 270 $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because one of its parents is not approved', MIDCOM_LOG_WARN); 269 271 } 270 272 } branches/MidCOM_2_8/midcom.helper.replicator/logger.php
r14775 r16096 7 7 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License 8 8 */ 9 10 $_MIDCOM->load_library('midcom.helper.reflector'); 9 11 10 12 /** … … 18 20 } 19 21 20 function _resolve_object_title($object)22 function log_object(&$object, $action, $loglevel = MIDCOM_LOG_DEBUG) 21 23 { 22 $vars = get_object_vars($object); 23 24 if (is_a($object, 'midgard_parameter')) 25 { 26 return "{$object->domain}/{$object->name}"; 27 } 28 elseif (is_a($object, 'midgard_topic')) 29 { 30 return $object->extra; 31 } 32 elseif ( array_key_exists('title', $vars) 33 && !empty($object->title)) 34 { 35 return $object->title; 36 } 37 elseif ( array_key_exists('name', $vars) 38 && !empty($object->name)) 39 { 40 return $object->name; 41 } 42 else 43 { 44 return "#{$object->id}"; 45 } 46 } 47 48 function log_object($object, $action, $loglevel = MIDCOM_LOG_DEBUG) 49 { 24 $ref = new midcom_helper_reflector($object); 50 25 $message = $action; 51 26 $message .= " {$object->guid}"; 52 $message .= ', ' . get_class($object); 53 $message .= ' "' . $this->_resolve_object_title($object) . '"'; 27 $message .= ', ' . $ref->get_class_label(); 28 $message .= ' "' . $ref->get_object_label($object) . '"'; 29 unset($ref); 54 30 55 31 $this->log($message, $loglevel); branches/MidCOM_2_8/midcom.helper.replicator/manager.php
r16080 r16096 439 439 } 440 440 441 if (isset($_POST['midcom_helper_replicator_requeue'])) 442 { 443 $qmanager =& midcom_helper_replicator_queuemanager::get(); 444 //TODO: Is there a more graceful way to do this ? (see also mirror.php) 445 $GLOBALS['midcom_helper_replicator_exporter_retry_mode'] = true; 446 if (!$qmanager->add_to_queue($data['object'])) 447 { 448 $_MIDCOM->uimessages->add 449 ( 450 $this->_l10n->get('midcom.helper.replicator'), 451 $this->_l10n->get('re-queuing failed'), 452 'warning' 453 ); 454 } 455 unset($GLOBALS['midcom_helper_replicator_exporter_retry_mode']); 456 } 441 457 442 458 if ($bind_toolbar) … … 460 476 ); 461 477 478 $data['queue_root_dir'] = preg_replace('%/{2,}|/$%', '', $this->_local_config->get('queue_root_dir')); 479 462 480 return true; 463 481 } branches/MidCOM_2_8/midcom.helper.replicator/queuemanager.php
r16086 r16096 133 133 } 134 134 if ( !isset($this->file_counts[$subscription->guid]) 135 || !is_ array($this->file_counts[$subscription->guid]))136 { 137 $this->file_counts[$subscription->guid] = array();135 || !is_numeric($this->file_counts[$subscription->guid])) 136 { 137 $this->file_counts[$subscription->guid] = 1; 138 138 } 139 139 $i =& $this->file_counts[$subscription->guid]; … … 198 198 199 199 unset($key, $data); 200 $i++;200 ++$i; 201 201 } 202 202 unset($exporter_serializations); … … 243 243 function _get_subscription_basedir(&$subscription) 244 244 { 245 $global_base = $this->_config->get('queue_root_dir'); 245 // Normalize basedir, no trailing slash and no consecutive slashes 246 $global_base = preg_replace('%/{2,}|/$%', '', $this->_config->get('queue_root_dir')); 246 247 if (!is_dir($global_base)) 247 248 { branches/MidCOM_2_8/midcom.helper.replicator/style/midcom-helper-replicator-object.php
r5757 r16096 29 29 <td>&(exported);</td> 30 30 </tr> 31 <tr> 32 <td colspan=2> 33 <form method="post" class="midcom_helper_replicator_requeue_form"> 34 <input type="submit" class="button" name="midcom_helper_replicator_requeue" value="<?php echo $_MIDCOM->i18n->get_string('re-queue object', 'midcom.helper.replicator'); ?>" /> 35 </form> 36 </td> 37 </tr> 31 38 </table> 32 39 … … 37 44 exec("grep '{$data['object']->guid}' '{$GLOBALS['midcom_helper_replicator_logger']->_filename}'", $output); 38 45 46 $path_regex = "%{$data['queue_root_dir']}.*?/[0-9a-f]{32,80}(-quarantine)?/[0-9]+/%"; 39 47 echo "<ul class=\"midcom_helper_replicator_object\">\n"; 40 48 foreach ($output as $line) … … 55 63 $component = str_replace('midcom_helper_replicator_importer', 'importer', str_replace('Queue Manager', 'queuemanager', $item_component)); 56 64 $message = str_replace($data['object']->guid, "<abbr title=\"{$data['object']->guid}\"><GUID></abbr>", $item_content); 65 $message = preg_replace($path_regex, '<abbr title="\\0"><PATH></abbr>/', $message); 57 66 58 67 echo "<li class=\"{$item_class} {$component}\">";
