mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-26069 detect missing file postprocessing
This commit is contained in:
parent
8cdc85ac62
commit
893fe4b6b2
31
brokenfile.php
Normal file
31
brokenfile.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This is an empty file which is used in order to prevent
|
||||
* error logs in the serverlog.
|
||||
*
|
||||
* Sometimes developer forgets to postprocess files when saving
|
||||
* submitted form data or forget to replace the file placeholders
|
||||
* with the current area information.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage file
|
||||
* @copyright 2011 Petr Skoda (http://skodak.org)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@header('HTTP/1.0 404 not found');
|
@ -321,7 +321,7 @@ function file_get_unused_draft_itemid() {
|
||||
* @return string if $text was passed in, the rewritten $text is returned. Otherwise NULL.
|
||||
*/
|
||||
function file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $CFG;
|
||||
|
||||
$options = (array)$options;
|
||||
if (!isset($options['subdirs'])) {
|
||||
@ -351,6 +351,12 @@ function file_prepare_draft_area(&$draftitemid, $contextid, $component, $fileare
|
||||
$fs->create_file_from_storedfile($file_record, $file);
|
||||
}
|
||||
}
|
||||
if (!is_null($text)) {
|
||||
// at this point there should not be any draftfile links yet,
|
||||
// because this is a new text from database that should still contain the @@pluginfile@@ links
|
||||
// this happens when developers forget to post process the text
|
||||
$text = str_replace("\"$CFG->httpswwwroot/draftfile.php", "\"$CFG->httpswwwroot/brokenfile.php#", $text);
|
||||
}
|
||||
} else {
|
||||
// nothing to do
|
||||
}
|
||||
|
@ -1106,6 +1106,13 @@ function format_text($text, $format = FORMAT_MOODLE, $options = NULL, $courseid_
|
||||
$text = $filtermanager->filter_text($text, $context, array('originalformat' => $format));
|
||||
break;
|
||||
}
|
||||
if ($options['filter']) {
|
||||
// at this point there should not be any draftfile links any more,
|
||||
// this happens when developers forget to post process the text.
|
||||
// The only potential problem is that somebody might try to format
|
||||
// the text before storing into database which would be itself big bug.
|
||||
$text = str_replace("\"$CFG->httpswwwroot/draftfile.php", "\"$CFG->httpswwwroot/brokenfile.php#", $text);
|
||||
}
|
||||
|
||||
// Warn people that we have removed this old mechanism, just in case they
|
||||
// were stupid enough to rely on it.
|
||||
|
Loading…
x
Reference in New Issue
Block a user