-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove be_strict
.
#968
Remove be_strict
.
#968
Conversation
45e8868
to
cde44d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through a few problems to test this out -- things look good 👍
cde44d1
to
93e942a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Tested a number of problems and work as expected. Requiring use strict
(and use warnings
) for modules as well as strict->import;
for macros will be good moving forward.
93e942a
to
9302b11
Compare
All modules should call `use strict` and certainly have no need of this method. They are not restricted from using `use` as they are outside of the safe zone. They should also all call `use warnings`. More work is needed because many of the modules actually have problems that cause warnings. Macros can (and should) call `BEGIN { strict->import }`. This is actually entirely equivalent to previously calling `BEGIN { be_strict() }` (due to an incorrect `import` call -- see below) and can be done in the safe compartment. Note that `use strict` is (essentially) the equivalent of `BEGIN { require strict; strict->import; }`. For macros there is no need to `require strict` as `strict` will already have been loaded. So using `BEGIN { strict->import }` does essentially what `use strict` does for a macro. This does not go as far as is really needed. All macros should call `BEGIN { strict->import; }`. This should be a requirement for macros in PG going forward. This is added in `parserGraphTool.pl` in this pull request, and the one issue with that macro is fixed. This is also added in `parserRadioMultiAnswer.pl` which has no issues with it. This is deferred for other macros. Also remove the unused `ww_strict.pm` module. Note that module was not actually used even by the `be_strict` method. The `be_strict` method was defined by ```perl sub be_strict { require ww_strict; strict::import(); return; } ``` This means that the `ww_strict` module was required, but the line `strict::import()` did not import that module. Instead that imports the real perl `strict` module. In order to import the `ww_strict` module it would have needed to call `ww_strict->import`. Notice that the `be_strict` method also used an incorrect way of calling the `import` method of `strict`. The `import` method is a package method that should be called with an invocant (via `strict->import`, and not a static method which would be called as `strict::import()` as was done in the `be_strict` method. It worked though because the `import` method doesn't use the invocant, and the `be_strict` method did not accept any arguments.
9302b11
to
d8a4543
Compare
Today on
|
It seems to come from the |
I assume that you have restarted the webwork2 app, right? Is this happening on the problem page? What version of perl are you using? |
I have restarted the app. I see this on the problem's page as well as the editor page. This is on an Oracle 8.7 server, with perl 5.26.3. My production server is the same OS, but perl is 5.36.1. Seems like the perl version is the issue. If it's for sure that we don't want to support this old of perl, I will try to upgrade perl on my dev server. |
It seems that perl 5.34 or newer is needed for this. I tested with versions 5.26, 5.28, 5.30, and 5.32, and all of those have this issue. I have a solution that will make this work for those versions though. The |
All modules should call
use strict
and certainly have no need of this method. They are not restricted from usinguse
as they are outside of the safe zone. They should also all calluse warnings
. More work is needed because many of the modules actually have problems that cause warnings.Macros can (and should) call
BEGIN { strict->import }
. This is actually entirely equivalent to previously callingBEGIN { be_strict() }
(due to an incorrectimport
call -- see below) and can be done in the safe compartment. Note thatuse strict
is (essentially) the equivalent ofBEGIN { require strict; strict->import; }
. For macros there is no need torequire strict
asstrict
will already have been loaded. So usingBEGIN { strict->import }
does essentially whatuse strict
does for a macro.This does not go as far as is really needed. All macros should call
BEGIN { strict->import; }
. This should be a requirement for macros in PG going forward. This is added inparserGraphTool.pl
in this pull request, and the one issue with that macro is fixed. This is deferred for other macros.Also remove the unused
ww_strict.pm
module. Note that module was not actually used even by thebe_strict
method. Thebe_strict
method was defined byThis means that the
ww_strict
module was required, but the linestrict::import()
did not import that module. Instead that imports the real perlstrict
module. In order to import theww_strict
module it would have needed to callww_strict->import
. Notice that thebe_strict
method also used an incorrect way of calling theimport
method ofstrict
. Theimport
method is a package method that should be called with an invocant (viastrict->import
, and not a static method which would be called asstrict::import()
as was done in thebe_strict
method. It worked though because theimport
method doesn't use the invocant, and thebe_strict
method did not accept any arguments.