summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Ventura2009-05-06 00:22:32 (GMT)
committer Joao Ventura2009-05-06 00:22:32 (GMT)
commitabd96759dbf81c514056912002ca74eafc795664 (patch)
tree22bcd39252e6aeb012e9a7aed82ea120ccd74cac
parentaf20b2cf2130b4823595730cb7ff432b9dcba178 (diff)
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
-rw-r--r--print.module9
-rw-r--r--print.pages.inc8
-rw-r--r--print_mail/print_mail.module7
-rw-r--r--print_pdf/print_pdf.module7
-rw-r--r--print_pdf/print_pdf.pages.inc3
5 files changed, 15 insertions, 19 deletions
diff --git a/print.module b/print.module
index 5be876d..448efb9 100644
--- a/print.module
+++ b/print.module
@@ -247,7 +247,7 @@ function print_link_alter(&$node, &$links) {
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;
}
@@ -317,7 +317,7 @@ function print_nodeapi(&$node, $op = 'view', $teaser, $page) {
break;
case 'delete':
db_query("DELETE FROM {print_node_conf} WHERE nid = %d", $node->nid);
- db_query("DELETE FROM {print_page_counter} WHERE path = '%s'", $node->path);
+ db_query("DELETE FROM {print_page_counter} WHERE path = 'node/%d'", $node->nid);
break;
}
}
@@ -683,9 +683,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 (!empty($node->printing) ||
- !_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)) {
diff --git a/print.pages.inc b/print.pages.inc
index 4cc6b5a..9970e45 100644
--- a/print.pages.inc
+++ b/print.pages.inc
@@ -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,7 +28,7 @@ function print_controller_html() {
$node = $print['node'];
include_once(_print_get_template(PRINT_HTML_FORMAT, $print['type']));
- $nodepath = drupal_get_normal_path($node->path);
+ $nodepath = (isset($node->path)) ? drupal_get_normal_path($node->path) : 'node/'. $path;
db_query("UPDATE {print_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
// If we affected 0 rows, this is the first time viewing the node.
if (!db_affected_rows()) {
@@ -662,8 +661,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();
- $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) {
@@ -683,6 +680,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);
diff --git a/print_mail/print_mail.module b/print_mail/print_mail.module
index e653bbe..f63e44e 100644
--- a/print_mail/print_mail.module
+++ b/print_mail/print_mail.module
@@ -229,7 +229,7 @@ function print_mail_nodeapi(&$node, $op = 'view', $teaser, $page) {
break;
case 'delete':
db_query("DELETE FROM {print_mail_node_conf} WHERE nid = %d", $node->nid);
- db_query("DELETE FROM {print_mail_page_counter} WHERE path = '%s'", $node->path);
+ db_query("DELETE FROM {print_mail_page_counter} WHERE path = 'node/%d'", $node->nid);
break;
}
}
@@ -452,9 +452,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 (!empty($node->printing) ||
- !_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)) {
diff --git a/print_pdf/print_pdf.module b/print_pdf/print_pdf.module
index 54c3754..3e8ede8 100644
--- a/print_pdf/print_pdf.module
+++ b/print_pdf/print_pdf.module
@@ -228,7 +228,7 @@ function print_pdf_nodeapi(&$node, $op = 'view', $teaser, $page) {
break;
case 'delete':
db_query("DELETE FROM {print_pdf_node_conf} WHERE nid = %d", $node->nid);
- db_query("DELETE FROM {print_pdf_page_counter} WHERE path = '%s'", $node->path);
+ db_query("DELETE FROM {print_pdf_page_counter} WHERE path = 'node/%d'", $node->nid);
break;
}
}
@@ -443,9 +443,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 (!empty($node->printing) ||
- !_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)) {
diff --git a/print_pdf/print_pdf.pages.inc b/print_pdf/print_pdf.pages.inc
index eb95405..3de5544 100644
--- a/print_pdf/print_pdf.pages.inc
+++ b/print_pdf/print_pdf.pages.inc
@@ -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;
@@ -82,7 +81,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_query("UPDATE {print_pdf_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath);
// If we affected 0 rows, this is the first time viewing the node.
if (!db_affected_rows()) {