Skip to content

Commit

Permalink
Merge pull request #898 from drgrice1/no-expose-create-directory
Browse files Browse the repository at this point in the history
Remove the pass through createDirectory method in PGcore.pm.
  • Loading branch information
Alex-Jordan authored Aug 24, 2023
2 parents 983a085 + 7c74a99 commit badd6e3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
26 changes: 18 additions & 8 deletions conf/pg_config.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ directories:
- $pg_root/macros/ui
- $pg_root/macros/deprecated


URLs:
# The public URL of the html directory above.
html: /pg_files
Expand Down Expand Up @@ -201,9 +200,10 @@ displayModeOptions:
passwd: ''

# PG modules to load
# The first item of each list is the module to load. The remaining items are additional packages to import.
# That is: If you wish to include a module MyModule.pm which depends on additional modules Dependency1.pm and
# Dependency2.pm, these should appear as [Mymodule, Dependency1, Dependency2]
# The first item of each list is the module file to load. The remaining items are additional packages to import that are
# also contained in that file.
# That is, if you wish to include a file MyModule.pm which containes the package MyModule and the additional packages
# Dependency1 and Dependency2, then these should appear as [Mymodule, Dependency1, Dependency2].
modules:
- [Encode]
- ['Encode::Encoding']
Expand All @@ -212,7 +212,8 @@ modules:
- [DynaLoader]
- [Exporter]
- [GD]
- [AlgParser, AlgParserWithImplicitExpand, Expr, ExprWithImplicitExpand, utf8]
- [utf8]
- [AlgParser, AlgParserWithImplicitExpand, Expr, ExprWithImplicitExpand]
- [AnswerHash, AnswerEvaluator]
- [LaTeXImage]
- [WWPlot] # required by Circle (and others)
Expand All @@ -235,14 +236,23 @@ modules:
- [Select]
- [Units]
- [VectorField]
- [Parser, Value]
- [Parser]
- [Value]
- ['Parser::Legacy']
- [Statistics]
- [Chromatic] # for Northern Arizona graph problems
- [Applet]
- [PGcore, PGalias, PGresource, PGloadfiles, PGanswergroup, PGresponsegroup, 'Tie::IxHash']
- [PGcore]
- [PGalias]
- [PGresource]
- [PGloadfiles]
- [PGanswergroup]
- [PGresponsegroup]
- ['Tie::IxHash']
- ['Locale::Maketext']
- [JSON]
- [Rserve, 'Class::Tiny', 'IO::Handle']
- ['Class::Tiny']
- ['IO::Handle']
- ['Rserve']
- [DragNDrop]
- ['Types::Serialiser']
8 changes: 4 additions & 4 deletions lib/LaTeXImage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
# simple images using LaTeX, and converting them into a web-useable format. Its
# typical usage is via the macro PGtikz.pl and is documented there.

package LaTeXImage;

use strict;
use warnings;
use Carp;
use WeBWorK::PG::IO;
use WeBWorK::PG::ImageGenerator;

package LaTeXImage;
require WeBWorK::PG::IO;
require WeBWorK::PG::ImageGenerator;

# The constructor (it takes no parameters)
sub new {
Expand Down
13 changes: 3 additions & 10 deletions lib/PGcore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use PGrandom;
use PGalias;
use PGloadfiles;
use AnswerHash;
use WeBWorK::PG::IO(); # don't important any command directly
require WeBWorK::PG::IO;
use Tie::IxHash;
use MIME::Base64();
use PGUtil();
Expand Down Expand Up @@ -764,7 +764,6 @@ sub getUniqueName {
convertPath
fileFromPath
directoryFromPath
createDirectory
=cut

Expand Down Expand Up @@ -801,11 +800,6 @@ sub directoryFromPath {
WeBWorK::PG::IO::directoryFromPath(@_);
}

sub createDirectory {
my $self = shift;
WeBWorK::PG::IO::createDirectory(@_);
}

sub AskSage {
my $self = shift;
my $python = shift;
Expand Down Expand Up @@ -835,7 +829,6 @@ course temp directory.

# ^function surePathToTmpFile
# ^uses getCourseTempDirectory
# ^uses createDirectory

sub surePathToTmpFile {
# constructs intermediate directories if needed beginning at ${Global::htmlDirectory}tmp/
Expand All @@ -851,7 +844,7 @@ sub surePathToTmpFile {
$parentDirectory = $self->directoryFromPath($parentDirectory);
my ($perms, $groupID) = (stat $parentDirectory)[ 2, 5 ];
#warn "Creating tmp directory at $tmpDirectory, perms $perms groupID $groupID";
$self->createDirectory($tmpDirectory, $perms, $groupID)
WeBWorK::PG::IO::createDirectory($tmpDirectory, $perms, $groupID)
or warn "Failed to create parent tmp directory at $path";

}
Expand All @@ -872,7 +865,7 @@ sub surePathToTmpFile {
$path = $path . shift(@nodes) . "/"; #convertPath($path . shift (@nodes) . "/");

unless (-e $path) {
$self->createDirectory($path, $perms, $groupID)
WeBWorK::PG::IO::createDirectory($path, $perms, $groupID)
or $self->warning_message(
"Failed to create directory at $path with permissions $perms and groupID $groupID");
}
Expand Down
8 changes: 1 addition & 7 deletions lib/WeBWorK/PG/IO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ WeBWorK::PG::IO - Functions used by WeBWorK::PG::Translator for file IO.
=cut

our @EXPORT = qw(
our @EXPORT_OK = qw(
includePGtext
read_whole_problem_file
read_whole_file
convertPath
fileFromPath
directoryFromPath
createDirectory
);

=head1 SYNOPSIS
use WeBWorK::PG::IO;
my %functions_to_share = %WeBWorK::PG::IO::SHARE;
=head1 DESCRIPTION
This module defines several functions to be shared with a safe compartment by
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/PG/Translator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ sub initialize {
my $safe_cmpt = $self->{safe};

$safe_cmpt->share_from('WeBWorK::PG::Translator', \@Translator_shared_subroutine_array);
$safe_cmpt->share_from('WeBWorK::PG::IO', \@WeBWorK::PG::IO::EXPORT);
$safe_cmpt->share_from('WeBWorK::PG::IO', \@WeBWorK::PG::IO::EXPORT_OK);

no strict;
local (%envir) = %{ $self->{envir} };
Expand Down

0 comments on commit badd6e3

Please sign in to comment.