Error updating from 7.x-2.2 to 7.x-2.4

Created on 29 July 2022, over 2 years ago
Updated 16 June 2024, 5 months ago

Problem/Motivation

Updating the print module from 7.x-2.2 to 7.x-2.4 (or 7.x-2.3, as I tried to take the update in smaller steps) results in the following error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: [site]/update.php?op=selection&token=a2J5mpLTgZdHGOL1gJGW66g9s8_JofXEt2QZBM0c4i8&id=14803&op=do_nojs&op=do StatusText: Service unavailable (with message) ResponseText: Error: Call to undefined function print_pdf_cache_delete() in print_pdf_update_7206() (line 341 of [path]/sites/all/modules/print/print_pdf/print_pdf.install).

Steps to reproduce

Update the print module through git(https://git.drupalcode.org/project/print/tree/7.x-2.4) or through the .zip file(https://ftp.drupal.org/files/projects/print-7.x-2.4.zip). I have several servers that I need to update and this has happened on 3/3 that I have updated so far.

Proposed resolution

I have to copy the below two functions out of print_pdf.module into print_pdf.install in order for the module to actually install properly; removing them after the update is complete.

/**
* Returns the cache directory.
*
* @return string
* The scheme://path of the cache directory
*/
function print_pdf_cache_dir() {
global $language_url;
$scheme = 'private';
if (!file_stream_wrapper_valid_scheme($scheme)) {
$scheme = 'temporary';
}
return $scheme . '://print_pdf/cache/' . $language_url->language;
}

/**
* Deletes one or more files from the PDF cache directory.
*
* @param int $nid
* The node ID of the page for which the cached PDF should be deleted.
* If not provided, the entire cache directory will be deleted.
*/
function print_pdf_cache_delete($nid = NULL) {
$directory = print_pdf_cache_dir();

if ($nid) {
$filename = $directory . '/' . $nid . '.pdf';
if (is_file($filename)) {
file_unmanaged_delete($filename);
}
}
else {
// If no nid is provided, flush the entire cache.
if (is_dir($directory)) {
file_unmanaged_delete_recursive($directory);
}
}
}

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024