mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'm31_MDL-53837_Is_Executable_Python_Script_Windows' of https://github.com/scara/moodle
This commit is contained in:
commit
b0ab1fdcff
@ -2543,9 +2543,10 @@ class admin_setting_configexecutable extends admin_setting_configfile {
|
||||
public function output_html($data, $query='') {
|
||||
global $CFG;
|
||||
$default = $this->get_defaultsetting();
|
||||
require_once("$CFG->libdir/filelib.php");
|
||||
|
||||
if ($data) {
|
||||
if (file_exists($data) and !is_dir($data) and is_executable($data)) {
|
||||
if (file_exists($data) and !is_dir($data) and file_is_executable($data)) {
|
||||
$executable = '<span class="pathok">✔</span>';
|
||||
} else {
|
||||
$executable = '<span class="patherror">✘</span>';
|
||||
|
@ -2659,6 +2659,35 @@ function file_modify_html_header($text) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the filename is executable.
|
||||
*
|
||||
* @link http://php.net/manual/en/function.is-executable.php
|
||||
* @link https://bugs.php.net/bug.php?id=41062
|
||||
* @param string $filename Path to the file.
|
||||
* @return bool True if the filename exists and is executable; otherwise, false.
|
||||
*/
|
||||
function file_is_executable($filename) {
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
if (is_executable($filename)) {
|
||||
return true;
|
||||
} else {
|
||||
$fileext = strrchr($filename, '.');
|
||||
// If we have an extension we can check if it is listed as executable.
|
||||
if ($fileext && file_exists($filename) && !is_dir($filename)) {
|
||||
$winpathext = strtolower(getenv('PATHEXT'));
|
||||
$winpathexts = explode(';', $winpathext);
|
||||
|
||||
return in_array(strtolower($fileext), $winpathexts);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return is_executable($filename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RESTful cURL class
|
||||
*
|
||||
|
@ -224,7 +224,7 @@ class file_storage {
|
||||
protected function create_converted_document(stored_file $file, $format) {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->pathtounoconv) || !is_executable(trim($CFG->pathtounoconv))) {
|
||||
if (empty($CFG->pathtounoconv) || !file_is_executable(trim($CFG->pathtounoconv))) {
|
||||
// No conversions are possible, sorry.
|
||||
return false;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class core_unoconv_testcase extends advanced_testcase {
|
||||
public function test_generate_pdf() {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->pathtounoconv) || !is_executable(trim($CFG->pathtounoconv))) {
|
||||
if (empty($CFG->pathtounoconv) || !file_is_executable(trim($CFG->pathtounoconv))) {
|
||||
// No conversions are possible, sorry.
|
||||
return $this->markTestSkipped();
|
||||
}
|
||||
@ -90,7 +90,7 @@ class core_unoconv_testcase extends advanced_testcase {
|
||||
public function test_generate_markdown() {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->pathtounoconv) || !is_executable(trim($CFG->pathtounoconv))) {
|
||||
if (empty($CFG->pathtounoconv) || !file_is_executable(trim($CFG->pathtounoconv))) {
|
||||
// No conversions are possible, sorry.
|
||||
return $this->markTestSkipped();
|
||||
}
|
||||
|
@ -119,6 +119,8 @@ information provided here is intended especially for developers.
|
||||
* table_sql download process is using the new data formats plugin which you can't use if you are buffering any output
|
||||
* flexible_table::get_download_menu(), considered private, has been deleted. Use
|
||||
$OUTPUT->download_dataformat_selector() instead.
|
||||
when building Xpath, or pass the unescaped value when using the named selector.
|
||||
* Add new file_is_executable(), to consistently check for executables even in Windows (PHP bug #41062).
|
||||
|
||||
=== 3.0 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user