我可以在模块构建中检查什么以确保drupal中没有崩溃

我可以在模块构建中检查什么以确保drupal中没有崩溃,drupal,drupal-6,module,drupal-modules,Drupal,Drupal 6,Module,Drupal Modules,我有一个简短的问题,我目前正在运行Drupal的一个测试站点。我有一个为6.16版本之前的测试站点编写和支持的模块,我当前希望在启用该模块时在崩溃中使用该模块 我想知道我可以查看哪些基本元素来确保代码兼容,或者是否需要更改 此模块提供了CRM与Drupal for SSO的集成 我想,如果其他人遇到创建模块来弥合系统之间的差距,他们可能会为我指明正确的方向 这是我启用模块时收到的错误: Parse error: syntax error, unexpected T_OBJECT_OPERATOR

我有一个简短的问题,我目前正在运行Drupal的一个测试站点。我有一个为6.16版本之前的测试站点编写和支持的模块,我当前希望在启用该模块时在崩溃中使用该模块

我想知道我可以查看哪些基本元素来确保代码兼容,或者是否需要更改

此模块提供了CRM与Drupal for SSO的集成

我想,如果其他人遇到创建模块来弥合系统之间的差距,他们可能会为我指明正确的方向

这是我启用模块时收到的错误:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /homepages/22/d223624283/htdocs/drupal6/sites/all/modules/convio/convio.module on line 104
这是名为convio.module的文件中的代码,它给了我一个问题:

<?php

/**
 * Classes. (The order is important.)
 */
module_load_include("inc", "convio", "ConvioConstants");
module_load_include("inc", "convio", "ConvioUtils");
module_load_include("inc", "convio", "ConvioConfiguration");
module_load_include("inc", "convio", "ConvioAPIClient");
module_load_include("inc", "convio", "ConvioUser");
module_load_include("inc", "convio", "ConvioLoginHandler");
module_load_include("inc", "convio", "ConvioTokenHandler");


/**
* Implementation of hook_help.
*/
function convio_help() {
if ($path == 'admin/help#convio') {
$txt = 'The Convio module uses the !convio_url API to .';
$link = l('Convio Open', 'http://open.convio.com');
$replace = array('!convio_url' => $link);
return '<p>' . t($txt, $replace) . '</p>';
  }
 }

/**
* Implementation of hook_menu.
*/
function convio_menu() {

// Test
$items['convio/test'] = array(
'title' => 'Convio Test',
'description' => 'Testing.',
'page callback' => 'convio_test',
'file' => 'ui/test.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
 );

// Admin configuration page.
$items['admin/convio/configure'] = array(
'title' => 'Convio Integration',
'description' => 'Settings for the Convio Open API.',
'page callback' => 'drupal_get_form',
'page arguments' => array('convio_configuration_form'),
'file' => 'ui/admin/configure.inc',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);

// SSO Authentication callback.
$items['convio/session/status'] = array(
'title' => 'Convio Session Status',
'description' => 'Validates the Convio user session and updates the Drupal user session.',
'page callback' => 'convio_session_status',
'file' => 'ui/session/status.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
 );

 // SSO Authentication callback.
 $items['convio/session/validate'] = array(
'title' => 'Convio Session Validation',
'description' => 'Validates the Convio user session and updates the Drupal user session.',
'page callback' => 'convio_session_validate',
'file' => 'ui/session/validate.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
 );

// SSO Authentication callback.
$items['convio/session/clear'] = array(
'title' => 'Convio Session Reset',
'description' => 'Clears the Drupal user session.',
'page callback' => 'convio_session_clear',
'file' => 'ui/session/clear.inc',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
 );

 return $items;
}

// Only enable the following hooks if the Open APIs have been configured.
if (ConvioConfiguration::getInstance()->isEnabled()) {

/**
* Implementation of hook_menu_alter()
*
* Alter the user/registration menu item to point to the external
* user account registration page
*/
function convio_menu_alter($items) {

// Always allow access to the user/login.
$items['user/login']['access callback'] = TRUE;

/**
 * Overrides user/register from user.module.
 *
 * $items['user/register'] = array(
 *   'title' => 'Create new account',
 *   'page callback' => 'drupal_get_form',
 *   'page arguments' => array('user_register'),
 *   'access callback' => 'user_register_access',
 *   'type' => MENU_LOCAL_TASK,
 *   'file' => 'user.pages.inc',
 * );
 */
unset($items['user/register']);
$items['user/register'] = array(
                                'title' => 'Sign up',
                                'page callback' => 'convio_user_signup',
                                'access callback' => 'user_register_access',
                                'type' => MENU_CALLBACK,
                                'file path' => drupal_get_path('module','convio'),
                                'file' => 'ui/register.inc',
                                );

// Disable Forgot/Reset Password pages from user.module.
unset($items['user/password']);
unset($items['user/reset/%/%/%']);

// Disable Manage User Profile pages from user.module.
unset($items['user/autocomplete']);
unset($items['user/%user/delete']);

//TODO: alter profile edit form
//unset($items['user/%user_category/edit']);
unset($items['user/%user_category/edit/account']);
unset($items['admin/user/user/create']);

return $items;
}


/**
* Implementation of hook_form_alter.
*
* Replaces the standard login form with a Convio login form.
*/
function convio_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'user_login_block' || $form_id == 'user_login') {
  ConvioLoginHandler::getInstance()->getLoginForm($form, $form_state, $form_id);
}

return $form;
}


/**
* Implementation of hook_user.
*
* Maps cons_id to the Drupal user account.
*/
function convio_user($op, &$edit, &$account, $category = NULL) {

if ($op == "load") {
  // Make cons_id available from the user.

  $result = db_query("SELECT user_id, cons_id FROM {convio_users} where cons_id = %d", $cons_id);
  $convio_user = db_fetch_object($result);
  if ($convio_user) {
    $account->convio_cons_id = $convio_user->cons_id;
  }

  } else if ($op == "insert") {
  // The user account was created. Map it to the cons_id.

  db_query("INSERT INTO {convio_users} (user_id, cons_id) VALUES (%d, %d)",
           $account->uid,
           $edit["convio_cons_id"]);

  } else if ($op == "after_update") {
  // The user account was updated. 

  $result = db_query("SELECT user_id, cons_id FROM {convio_users} where cons_id = %d", $edit["convio_cons_id"]);
  $convio_user = db_fetch_object($result);
  if (! $convio_user) {
    db_query("INSERT INTO {convio_users} (user_id, cons_id) VALUES (%d, %d)",
             $account->uid,
             $edit["convio_cons_id"]);
  }

  } else if ($op == "delete") {
  // The user account was deleted. Delete any associated Convio mappings.
  // It would be better to have MySQL FK support with cascading deletes.

  db_query("DELETE FROM {convio_users} WHERE user_id = %d", $account->uid);

  } else if ($op == "logout") {

  ConvioLoginHandler::getInstance()->logout();
  }
  }


 /**
 * Implements hook_token_values();
 */
 function convio_token_values($type, $object = NULL) {
  if ($type == 'convio') {
  return ConvioTokenHandler::getInstance()->getValues();
  }
  }

 /**
 * Implements hook_token_list();
 */
 function convio_token_list($type = 'all') {
if ($type == 'convio' || $type == 'all') {
  return ConvioTokenHandler::getInstance()->getList();
  }
 }

/**
* Adds standard includes to every page.
*
* 1) Open API JS lib and init script -> <head>
* 2) Session tracking beacon -> header region
* 3) Keep-alive beacon -> footer region
*/
function _convio_add_includes() {
static $included = FALSE;
if (!$included) {

  $api_config = ConvioConfiguration::getInstance();

  // Establish a new C360 session if one doesn't exist already.
  if (ConvioLoginHandler::getInstance()->newUserSession()) {
    return;
  }

  $api_uri = $api_config->getURI();
  $api_key = $api_config->getPublicKey();

  // TODO: allow the regions to be overriden in the module configuration.
  $region_header = "header";
  $region_footer = "footer";

  // Add Convio Open API JS library and init script.
  drupal_set_html_head('<script type="text/javascript" src="' . $api_uri . '/../api/ConvioApi.js"></script>');

  $script = '<script type="text/javascript">';
  $script .= '  var CONVIO = {};';
  $script .= '  CONVIO.OPEN = new ConvioApiClient("' . $api_key . '","/api_client.html","json");';
  $script .= '</script>';
  drupal_set_html_head($script);

  // Add the session tracking beacon to the body of every page.
  $trackerUrl = url('convio/session/status', array('query' => drupal_get_destination()));
  $tracker = '<script type="text/javascript" src="' . $trackerUrl . '"></script>';
  drupal_set_content($region_header, $tracker);

  // Add a keepalive beacon to the bottom of every page.
  $img = '<img src="' . $api_uri . '/PixelServer" />';
  drupal_set_content($region_footer, $img);
}
    $included = TRUE;
  }

  // Include Convio module JS libraries on every page.
  _convio_add_includes();

} // end: if (ConvioConfiguration::getInstance()->isEnabled())

新评论后更新:

您是否仍在使用PHP4?这可以解释错误-方法链接(意味着直接在应该返回对象的函数上使用“->”运算符)仅在PHP 5 IIRC中支持

如果是这样,正确的解决方案是切换到PHP5

作为临时解决方案,您可以搜索直接在函数/方法结果上使用'->'运算符的所有位置(
functionCall()->…
),并通过另一个变量插入分隔符请注意,我不建议这样做-PHP 4已弃用,不再接收安全更新。在it上运行生产环境是一个大问题


原始答案:

该代码中唯一的
T_OBJECT_运算符
('->')似乎位于:

if (ConvioConfiguration::getInstance()->isEnabled()) { ...
因此,您可能希望将该行更改为以下内容:

$convioConfiguration = ConvioConfiguration::getInstance();
if (is_object($convioConfiguration) && $convioConfiguration->isEnabled()) { ...

嗯,这是convio.module
第104行的语法错误-您应该在问题中添加该行(以及周围环境,如果不太长,可能是整个函数),因为它可能很容易修复。@Henrik Opel感谢您的回答。。。我现在要补充一点。第104行到底是什么,您是否在104之前包含了一些行,问题也可能出现在哪里?或者,你可以将整个文件粘贴到@googletorp之类的东西中。。。我不熟悉这个drupal.pastebin.com,这是一个帮助更正代码的开发人员社区吗?我非常乐意包含这个模块的所有文件,如果这意味着我可以让它与6.19版及更高版本一起使用:)我现在就试试,然后再给你回复。@Matthew:看起来你还在使用PHP4-我相应地更新了我的答案。。。我将运行PHP5,看看会发生什么。