Commit c8aee091 authored by jcnventura's avatar jcnventura

Fix #451036: don't call drupal_get_title when the non-node path was not found

Don't try to use URL aliases when the node doesn't have one
parent bd02b7ac
......@@ -213,7 +213,7 @@ function print_link_alter(&$links, $node) {
break;
case 2:
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT);
$path = $print_html_link_use_alias ? $node->path : $node->nid;
$path = ($print_html_link_use_alias && isset($node->path)) ? $node->path : $node->nid;
break;
}
......@@ -333,7 +333,7 @@ function print_node_delete($node) {
->condition('nid', $node->nid)
->execute();
db_delete('print_page_counter')
->condition('path', $node->path)
->condition('path', 'node/' . $node->nid)
->execute();
}
......@@ -698,9 +698,8 @@ function print_link_allowed($args) {
$print_html_node_link_visibility = variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT);
$print_html_node_link_pages = variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT);
if ((isset($node->build_mode) && ($node->build_mode == NODE_BUILD_PRINT)) ||
!_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) {
// Page not in visibility list or we are working!
if (!_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) {
// Page not in visibility list
return FALSE;
}
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
......
......@@ -20,7 +20,6 @@ $_print_urls = PRINT_URLS_DEFAULT;
*/
function print_controller_html() {
$args = func_get_args();
// Remove the print/ prefix
$path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
......@@ -29,12 +28,7 @@ function print_controller_html() {
$node = $print['node'];
include_once(DRUPAL_ROOT . '/' . _print_get_template(PRINT_HTML_FORMAT, $print['type']));
if (is_numeric($path)) {
$nodepath = 'node/' . $path;
}
else {
$nodepath = drupal_get_normal_path($path);
}
$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/' . $path;
db_merge('print_page_counter')
->key(array('path' => $nodepath))
->fields(array(
......@@ -669,8 +663,6 @@ function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALS
// Adapted from index.php.
$node = new stdClass();
$node->body = menu_execute_active_handler($path);
$node->title = drupal_get_title();
$node->path = $path;
// It may happen that a drupal_not_found is called in the above call
if (preg_match('/404 Not Found/', drupal_get_headers()) == 1) {
......@@ -690,6 +682,9 @@ function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALS
}
}
$node->title = drupal_get_title();
$node->path = $path;
// Delete any links area
$node->body = preg_replace('!\s*<div class="links">.*?</div>!sim', '', $node->body);
......
......@@ -209,7 +209,7 @@ function print_mail_node_delete($node) {
->condition('nid', $node->nid)
->execute();
db_delete('print_mail_page_counter')
->condition('path', $node->path)
->condition('path', 'node/' . $node->nid)
->execute();
}
......@@ -438,9 +438,8 @@ function print_mail_link_allowed($args) {
$print_mail_node_link_visibility = variable_get('print_mail_node_link_visibility', PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT);
$print_mail_node_link_pages = variable_get('print_mail_node_link_pages', PRINT_MAIL_NODE_LINK_PAGES_DEFAULT);
if ((isset($node->build_mode) && ($node->build_mode == NODE_BUILD_PRINT)) ||
!_print_page_match($print_mail_node_link_visibility, $print_mail_node_link_pages)) {
// Page not in visibility list or we are working!
if (!_print_page_match($print_mail_node_link_visibility, $print_mail_node_link_pages)) {
// Page not in visibility list
return FALSE;
}
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
......
......@@ -251,7 +251,7 @@ function print_pdf_node_delete($node) {
->condition('nid', $node->nid)
->execute();
db_delete('print_pdf_page_counter')
->condition('path', $node->path)
->condition('path', 'node/' . $node->nid)
->execute();
}
......@@ -472,9 +472,8 @@ function print_pdf_link_allowed($args) {
$print_pdf_node_link_visibility = variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT);
$print_pdf_node_link_pages = variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT);
if ((isset($node->build_mode) && ($node->build_mode == NODE_BUILD_PRINT)) ||
!_print_page_match($print_pdf_node_link_visibility, $print_pdf_node_link_pages)) {
// Page not in visibility list or we are working!
if (!_print_page_match($print_pdf_node_link_visibility, $print_pdf_node_link_pages)) {
// Page not in visibility list
return FALSE;
}
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
......
......@@ -26,7 +26,6 @@ function print_pdf_controller() {
$GLOBALS['conf']['cache'] = FALSE;
$args = func_get_args();
// Remove the printpdf/ prefix
$path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
......@@ -91,7 +90,7 @@ function print_pdf_controller() {
return drupal_not_found();
}
$nodepath = drupal_get_normal_path($node->path);
$nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/' . $path;
db_merge('print_pdf_page_counter')
->key(array('path' => $nodepath))
->fields(array(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment