本文整理汇总了PHP中midcom_connection::get_error方法的典型用法代码示例。如果您正苦于以下问题:PHP midcom_connection::get_error方法的具体用法?PHP midcom_connection::get_error怎么用?PHP midcom_connection::get_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类midcom_connection
的用法示例。
在下文中一共展示了midcom_connection::get_error方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _load_object
/**
* Helper function to retrieve the object from the db
*
* @param string $guid GUID
*/
private function _load_object($guid)
{
try {
$this->_object = midcom::get('dbfactory')->get_object_by_guid($guid);
} catch (midcom_error $e) {
if (midcom_connection::get_error() == MGD_ERR_OBJECT_DELETED) {
$relocate = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . '__mfa/asgard/object/deleted/' . $guid;
midcom::get()->relocate($relocate);
}
throw $e;
}
}
示例2: testCRUD
public function testCRUD()
{
$time = time();
midcom::get('auth')->request_sudo('org.openpsa.products');
$group = new org_openpsa_products_product_group_dba();
$group->code = 'TEST-100' . $time;
$stat = $group->create();
$this->assertTrue($stat);
$this->assertEquals($group->code, 'TEST-100' . $time);
$group->code = 'TEST-101' . $time;
$stat = $group->update();
$this->assertTrue($stat);
$this->register_object($group);
$this->assertEquals($group->code, 'TEST-101' . $time);
$group2 = new org_openpsa_products_product_group_dba();
$group2->code = 'TEST-101' . $time;
$stat = $group2->create();
$this->assertFalse($stat);
$this->assertEquals(midcom_connection::get_error(), MGD_ERR_OBJECT_NAME_EXISTS);
$stat = $group->delete();
$this->assertTrue($stat);
midcom::get('auth')->drop_sudo();
}
示例3: _process_delete_queue
private static function _process_delete_queue($queue_name, $queue)
{
midcom::get('auth')->request_sudo('midcom.core');
$limit = sizeof($queue) * 5;
$iteration = 0;
while (!empty($queue)) {
$object = array_pop($queue);
if (!$object->delete()) {
if (midcom_connection::get_error() == MGD_ERR_HAS_DEPENDANTS || midcom_connection::get_error() == MGD_ERR_OK) {
array_unshift($queue, $object);
} else {
if (midcom_connection::get_error() == MGD_ERR_NOT_EXISTS) {
continue;
} else {
throw new midcom_error('Cleanup ' . get_class($object) . ' ' . $object->guid . ' failed, reason: ' . midcom_connection::get_error_string());
}
}
} else {
$object->purge();
}
if ($iteration++ > $limit) {
$classnames = array();
foreach ($queue as $obj) {
$obj_class = get_class($obj);
if ($obj->name) {
$obj_class .= " {$obj->name}";
}
if ($obj->component) {
$obj_class .= " [{$obj->component}]";
}
if (!in_array($obj_class, $classnames)) {
$classnames[] = $obj_class;
}
}
$classnames_string = implode(', ', $classnames);
throw new midcom_error('Maximum retry count for ' . $queue_name . ' cleanup reached (' . sizeof($queue) . ' remaining entries with types ' . $classnames_string . '). Last Midgard error was: ' . midcom_connection::get_error_string());
}
}
midcom::get('auth')->drop_sudo();
}
示例4: getUsersBlogs
function getUsersBlogs($message)
{
$args = $this->_params_to_args($message);
if (count($args) != 3) {
return new XML_RPC_Response(0, midcom_connection::get_error(), 'Invalid arguments.');
}
if (!midcom::get('auth')->login($args[1], $args[2])) {
return new XML_RPC_Response(0, midcom_connection::get_error(), 'Authentication failed.');
}
midcom::get('auth')->initialize();
$response = array();
$topic = $this->_topic;
if (!$topic->can_do('midgard:create')) {
// Skip this blog, user cannot edit
continue;
}
$nap = new midcom_helper_nav();
$node = $nap->get_node($topic->id);
if (!$node) {
// This topic isn't on site
continue;
}
$response_array = array('url' => new XML_RPC_Value($node[MIDCOM_NAV_FULLURL], 'string'), 'blogid' => new XML_RPC_Value($topic->guid, 'string'), 'blogName' => new XML_RPC_Value($node[MIDCOM_NAV_NAME], 'string'));
$response[] = new XML_RPC_Value($response_array, 'struct');
return new XML_RPC_Response(new XML_RPC_Value($response, 'array'));
}
示例5: _query_privileges
/**
* This is an internal helper function, which may only be called statically.
*
* It is used by get_all_privileges in case that there is no cache hit. It will query the
* database and construct all necessary objects out of it.
*
* @param string $guid The GUID of the object for which to query ACL data.
* @param string $type SELF or CONTENT
* @return Array A list of midcom_core_privilege instances.
*/
protected static function _query_privileges($guid, $type)
{
$result = array();
$mc = new midgard_collector('midcom_core_privilege_db', 'objectguid', $guid);
$mc->add_constraint('value', '<>', MIDCOM_PRIVILEGE_INHERIT);
if ($type == 'CONTENT') {
$mc->add_constraint('assignee', '<>', 'SELF');
} else {
$mc->add_constraint('assignee', '=', 'SELF');
}
$mc->set_key_property('guid');
$mc->add_value_property('id');
$mc->add_value_property('privilegename');
$mc->add_value_property('assignee');
$mc->add_value_property('classname');
$mc->add_value_property('value');
midcom_connection::set_error(MGD_ERR_OK);
$mc->execute();
$privileges = $mc->list_keys();
if (!$privileges) {
if (midcom_connection::get_error() != MGD_ERR_OK) {
debug_add("Failed to retrieve all {$type} privileges for the Object GUID {$guid}: " . midcom_connection::get_error_string(), MIDCOM_LOG_INFO);
debug_print_r('Result was:', $result);
if (isset($php_errormsg)) {
debug_add("Error message was: {$php_errormsg}", MIDCOM_LOG_ERROR);
}
throw new midcom_error('Privilege collector failed to execute: ' . midcom_connection::get_error_string());
}
return $result;
}
foreach ($privileges as $privilege_guid => $value) {
$privilege = $mc->get($privilege_guid);
$privilege['objectguid'] = $guid;
$privilege['guid'] = $privilege_guid;
$privilege_object = new midcom_core_privilege($privilege);
if (!isset($privilege_object->assignee)) {
// Invalid privilege, skip
continue;
}
$privilege_object->scope = $privilege_object->_get_scope();
$return[] = $privilege_object;
}
return $return;
}
示例6: foreach
$results = $qb->execute();
foreach ($results as $result) {
if (in_array($result->target, $valid_targets)) {
continue;
}
if (in_array($result->target, $invalid_targets)) {
continue;
}
try {
$object = midcom::get('dbfactory')->get_object_by_guid($result->target);
$valid_targets[] = $object->guid;
} catch (midcom_error $e) {
if (midcom_connection::get_error() === MGD_ERR_OBJECT_DELETED) {
$valid_targets[] = $result->target;
} else {
if (midcom_connection::get_error() === MGD_ERR_OBJECT_PURGED || midcom_connection::get_error() === MGD_ERR_NOT_EXISTS) {
$invalid_targets[] = $result->target;
$delete_qb = midcom_helper_activitystream_activity_dba::new_query_builder();
$delete_qb->add_constraint('target', '=', $result->target);
$to_delete = $delete_qb->execute();
if (sizeof($to_delete) == 0) {
continue;
}
echo "Deleting " . sizeof($to_delete) . " entries for purged target " . $result->target . " \n";
flush();
foreach ($to_delete as $entry) {
if (!$entry->delete()) {
echo 'ERROR: Deleting entry ' . $entry->guid . ' failed: ' . midcom_connection::get_error_string() . " \n";
} else {
$entry->purge();
}
示例7: _create_topic
private function _create_topic($prefix)
{
if (!empty($this->_new_topic->symlink)) {
$name = $this->_new_topic->name;
$topic = $this->_new_topic;
while (!empty($topic->symlink)) {
// Only direct symlinks are supported, but indirect symlinks are ok as we change them to direct ones here
$this->_new_topic->symlink = $topic->symlink;
try {
$topic = new midcom_db_topic($topic->symlink);
} catch (midcom_error $e) {
debug_add("Could not get target for symlinked topic #{$this->_new_topic->id}: " . $e->getMessage(), MIDCOM_LOG_ERROR);
$topic = $this->_new_topic;
$this->_new_topic->purge();
throw new midcom_error("Refusing to create this symlink because its target folder was not found: " . $e->getMessage());
}
$name = $topic->name;
}
if ($this->_new_topic->up == $topic->up) {
$this->_new_topic->purge();
throw new midcom_error("Refusing to create this symlink because it is located in the same " . "folder as its target. You must have made a mistake. Sorry, but this " . "was for your own good.");
}
if ($this->_new_topic->up == $topic->id) {
$this->_new_topic->purge();
throw new midcom_error("Refusing to create this symlink because its parent folder is the same " . "folder as its target. You must have made a mistake because this would " . "have created an infinite loop situation. The whole site would have " . "been completely and irrevocably broken if this symlink would have been " . "allowed to exist. Infinite loops can not be allowed. Sorry, but this " . "was for your own good.");
}
$this->_new_topic->update();
if (!midcom_admin_folder_management::is_child_listing_finite($topic)) {
$this->_new_topic->purge();
throw new midcom_error("Refusing to create this symlink because it would have created an " . "infinite loop situation. The whole site would have been completely " . "and irrevocably broken if this symlink would have been allowed to " . "exist. Please redesign your usage of symlinks. Infinite loops can " . "not be allowed. Sorry, but this was for your own good.");
}
$this->_new_topic->name = $name;
while (!$this->_new_topic->update() && midcom_connection::get_error() == MGD_ERR_DUPLICATE) {
$this->_new_topic->name .= "-link";
}
}
midcom::get('uimessages')->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('folder created'));
// Generate name if it is missing
if (!$this->_new_topic->name) {
$this->_new_topic->name = midcom_helper_misc::generate_urlname_from_string($this->_new_topic->extra);
$this->_new_topic->update();
}
// Get the relocation url
$url = "{$prefix}{$this->_new_topic->name}/";
return $url;
}
示例8: import_blob
/**
* Import midgard_blob unserialized with midgard_replicator::unserialize()
*
* This method does ACL checks and triggers watchers etc.
*
* @param midgard_blob $unserialized_object midgard_blob gotten from midgard_replicator::unserialize()
* @param string $xml XML the midgard_blob was unserialized from
* @param boolean $use_force set use of force for the midcom_helper_replicator_import_from_xml() call
* @return boolean indicating success/failure
*/
function import_blob(&$unserialized_object, &$xml, $use_force = false)
{
if (!is_a($unserialized_object, 'midgard_blob')) {
debug_add("You should use the *import* method to import normal objects, passing control there", MIDCOM_LOG_WARNING);
return $this->import($unserialized_object, $use_force);
}
// We need this helper (workaround Zend bug)
if (!function_exists('midcom_helper_replicator_import_object')) {
midcom::get('componentloader')->load('midcom.helper.replicator');
}
try {
$acl_object = midcom::get('dbfactory')->get_object_by_guid($unserialized_object->parentguid);
} catch (midcom_error $e) {
debug_add("Could not get parent object (GUID: {$unserialized_object->parentguid}), aborting", MIDCOM_LOG_ERROR);
return false;
}
// midgard_blob has no action, update is the best check for allowing import of blob data
if (!midcom_baseclasses_core_dbobject::update_pre_checks($acl_object)) {
$parent_class = get_class($acl_object);
debug_add("parent ({$parent_class} {$acl_object->guid}) update pre-flight check returned false", MIDCOM_LOG_ERROR);
return false;
}
// Actual import
// NOTE: midgard_replicator::import_from_xml returns void, which evaluates to false, check midcom_connection::get_error instead
midcom_helper_replicator_import_from_xml($xml, $use_force);
if (midcom_connection::get_error() !== MGD_ERR_OK) {
debug_add('midcom_helper_replicator_import_from_xml returned false, errstr: ' . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
return false;
}
// Trigger parent updated
midcom_baseclasses_core_dbobject::update_post_ops($acl_object);
// And also imported
midcom::get('componentloader')->trigger_watches(MIDCOM_OPERATION_DBA_IMPORT, $acl_object);
return true;
}
示例9: __construct
public function __construct(midgard_error_exception $e, $id = null)
{
//catch last error which might be from dbaobject
$last_error = midcom_connection::get_error();
if (!is_null($id)) {
if ($last_error === MGD_ERR_NOT_EXISTS) {
$code = MIDCOM_ERRNOTFOUND;
$message = "The object with identifier {$id} was not found.";
} else {
if ($last_error == MGD_ERR_ACCESS_DENIED) {
$code = MIDCOM_ERRFORBIDDEN;
$message = midcom::get('i18n')->get_string('access denied', 'midcom');
} else {
if ($last_error == MGD_ERR_OBJECT_DELETED) {
$code = MIDCOM_ERRNOTFOUND;
$message = "The object with identifier {$id} was deleted.";
}
}
}
}
//If other options fail, go for the server error
if (!isset($code)) {
$code = MIDCOM_ERRCRIT;
$message = $e->getMessage();
}
parent::__construct($message, $code);
}
示例10: strftime
}
echo " <td class=\"revised\">" . strftime('%x %X', $object->metadata->revised) . "</td>\n";
echo " <td class=\"revisor\">{$revisor_name}</td>\n";
echo " <td class=\"approved\">{$approved_str}</td>\n";
echo " <td class=\"revision\">{$object->metadata->revision}</td>\n";
echo " </tr>\n";
}
} else {
$activities = midcom_helper_activitystream_activity_dba::get($data['config']->get('last_visited_size'));
if (count($activities) > 0) {
$reflectors = array();
foreach ($activities as $activity) {
try {
$object = midcom::get('dbfactory')->get_object_by_guid($activity->target);
} catch (midcom_error $e) {
if (midcom_connection::get_error() == MGD_ERR_OBJECT_DELETED) {
// TODO: Visualize deleted objects somehow
}
continue;
}
if (!isset($actors)) {
$actors = array();
}
if (!isset($actors[$activity->actor])) {
try {
$actors[$activity->actor] = new midcom_db_person($activity->actor);
} catch (midcom_error $e) {
$actors[$activity->actor] = new midcom_db_person();
}
}
$class = get_class($object);
示例11: _update_account
private function _update_account($fields)
{
$stat = false;
$password = null;
//new password?
if (!empty($fields["new_password"]->value)) {
$password = $fields["new_password"]->value;
}
$accounthelper = new org_openpsa_user_accounthelper($this->_person);
// Update account
$stat = $accounthelper->set_account($fields["username"]->value, $password);
if (!$stat && midcom_connection::get_error() != MGD_ERR_OK) {
// Failure, give a message
midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), $this->_l10n->get("failed to update the user account, reason") . ': ' . midcom_connection::get_error_string(), 'error');
}
return $stat;
}
示例12: _process
/**
* Process the request
*
* Basically this method will parse the URL and search for a component that can
* handle the request. If one is found, it will process the request, if not, it
* will report an error, depending on the situation.
*
* Details: The logic will traverse the node tree and for each node it will load
* the component that is responsible for it. This component gets the chance to
* accept the request (this is encapsulated in the _can_handle call), which is
* basically a call to can_handle. If the component declares to be able to handle
* the call, its handle function is executed. Depending if the handle was successful
* or not, it will either display an HTTP error page or prepares the content handler
* to display the content later on.
*
* If the parsing process doesn't find any component that declares to be able to
* handle the request, an HTTP 404 - Not Found error is triggered.
*/
private function _process(midcom_core_context $context)
{
$resolver = new midcom_core_resolver($context);
$handler = $resolver->process();
if (false === $handler) {
/**
* Simple: if current context is not '0' we were called from another context.
* If so we should not break application now - just gracefully continue.
*/
if ($context->id == 0) {
// We couldn't fetch a node due to access restrictions
if (midcom_connection::get_error() == MGD_ERR_ACCESS_DENIED) {
throw new midcom_error_forbidden(midcom::get('i18n')->get_string('access denied', 'midcom'));
} else {
throw new midcom_error_notfound("This page is not available on this server.");
}
}
$this->_status = MIDCOM_STATUS_ABORT;
return false;
}
$context->run($handler);
if ($context->id == 0 && $this->skip_page_style == true) {
$this->_status = MIDCOM_STATUS_CONTENT;
// Enter Context
$oldcontext = $context;
midcom_core_context::get(0)->set_current();
midcom::get('style')->enter_context(0);
$this->_output();
// Leave Context
midcom::get('style')->leave_context();
$oldcontext->set_current();
$this->finish();
_midcom_stop_request();
} else {
$this->_status = MIDCOM_STATUS_CONTENT;
}
}