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) { ...@@ -213,7 +213,7 @@ function print_link_alter(&$links, $node) {
break; break;
case 2: case 2:
$print_html_link_use_alias = variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT); $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; break;
} }
...@@ -333,7 +333,7 @@ function print_node_delete($node) { ...@@ -333,7 +333,7 @@ function print_node_delete($node) {
->condition('nid', $node->nid) ->condition('nid', $node->nid)
->execute(); ->execute();
db_delete('print_page_counter') db_delete('print_page_counter')
->condition('path', $node->path) ->condition('path', 'node/' . $node->nid)
->execute(); ->execute();
} }
...@@ -698,9 +698,8 @@ function print_link_allowed($args) { ...@@ -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_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); $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)) || if (!_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) {
!_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) { // Page not in visibility list
// Page not in visibility list or we are working!
return FALSE; return FALSE;
} }
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) { elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
......
...@@ -20,7 +20,6 @@ $_print_urls = PRINT_URLS_DEFAULT; ...@@ -20,7 +20,6 @@ $_print_urls = PRINT_URLS_DEFAULT;
*/ */
function print_controller_html() { function print_controller_html() {
$args = func_get_args(); $args = func_get_args();
// Remove the print/ prefix
$path = implode('/', $args); $path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL; $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
...@@ -29,12 +28,7 @@ function print_controller_html() { ...@@ -29,12 +28,7 @@ function print_controller_html() {
$node = $print['node']; $node = $print['node'];
include_once(DRUPAL_ROOT . '/' . _print_get_template(PRINT_HTML_FORMAT, $print['type'])); include_once(DRUPAL_ROOT . '/' . _print_get_template(PRINT_HTML_FORMAT, $print['type']));
if (is_numeric($path)) { $nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/' . $path;
$nodepath = 'node/' . $path;
}
else {
$nodepath = drupal_get_normal_path($path);
}
db_merge('print_page_counter') db_merge('print_page_counter')
->key(array('path' => $nodepath)) ->key(array('path' => $nodepath))
->fields(array( ->fields(array(
...@@ -669,8 +663,6 @@ function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALS ...@@ -669,8 +663,6 @@ function _print_generate_path($path, $format = PRINT_HTML_FORMAT, $teaser = FALS
// Adapted from index.php. // Adapted from index.php.
$node = new stdClass(); $node = new stdClass();
$node->body = menu_execute_active_handler($path); $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 // It may happen that a drupal_not_found is called in the above call
if (preg_match('/404 Not Found/', drupal_get_headers()) == 1) { 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 ...@@ -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 // Delete any links area
$node->body = preg_replace('!\s*<div class="links">.*?</div>!sim', '', $node->body); $node->body = preg_replace('!\s*<div class="links">.*?</div>!sim', '', $node->body);
......
...@@ -209,7 +209,7 @@ function print_mail_node_delete($node) { ...@@ -209,7 +209,7 @@ function print_mail_node_delete($node) {
->condition('nid', $node->nid) ->condition('nid', $node->nid)
->execute(); ->execute();
db_delete('print_mail_page_counter') db_delete('print_mail_page_counter')
->condition('path', $node->path) ->condition('path', 'node/' . $node->nid)
->execute(); ->execute();
} }
...@@ -438,9 +438,8 @@ function print_mail_link_allowed($args) { ...@@ -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_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); $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)) || if (!_print_page_match($print_mail_node_link_visibility, $print_mail_node_link_pages)) {
!_print_page_match($print_mail_node_link_visibility, $print_mail_node_link_pages)) { // Page not in visibility list
// Page not in visibility list or we are working!
return FALSE; return FALSE;
} }
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) { elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
......
...@@ -251,7 +251,7 @@ function print_pdf_node_delete($node) { ...@@ -251,7 +251,7 @@ function print_pdf_node_delete($node) {
->condition('nid', $node->nid) ->condition('nid', $node->nid)
->execute(); ->execute();
db_delete('print_pdf_page_counter') db_delete('print_pdf_page_counter')
->condition('path', $node->path) ->condition('path', 'node/' . $node->nid)
->execute(); ->execute();
} }
...@@ -472,9 +472,8 @@ function print_pdf_link_allowed($args) { ...@@ -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_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); $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)) || if (!_print_page_match($print_pdf_node_link_visibility, $print_pdf_node_link_pages)) {
!_print_page_match($print_pdf_node_link_visibility, $print_pdf_node_link_pages)) { // Page not in visibility list
// Page not in visibility list or we are working!
return FALSE; return FALSE;
} }
elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) { elseif (isset($args['type']) && ($args['type'] == 'comment') && isset($node_type)) {
......
...@@ -26,7 +26,6 @@ function print_pdf_controller() { ...@@ -26,7 +26,6 @@ function print_pdf_controller() {
$GLOBALS['conf']['cache'] = FALSE; $GLOBALS['conf']['cache'] = FALSE;
$args = func_get_args(); $args = func_get_args();
// Remove the printpdf/ prefix
$path = implode('/', $args); $path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL; $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
...@@ -91,7 +90,7 @@ function print_pdf_controller() { ...@@ -91,7 +90,7 @@ function print_pdf_controller() {
return drupal_not_found(); 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') db_merge('print_pdf_page_counter')
->key(array('path' => $nodepath)) ->key(array('path' => $nodepath))
->fields(array( ->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