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
Settings #9420
Settings #9420
Conversation
5b489a8
to
b3ed0aa
Compare
@eileenmcnaughton jfyi, this is crashing here:
A bit of good news, though -- it appears that nothing else in the known universe references those functions:
|
@@ -69,7 +69,7 @@ public static function retrieve(&$params, &$defaults) { | |||
* | |||
* @return CRM_Core_BAO_Domain|null | |||
*/ | |||
public static function &getDomain($reset = NULL) { | |||
public static function getDomain($reset = NULL) { |
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.
Saying this out loud to ensure we agree: changing this function signature is safe because:
- There shouldn't be any subclasses (let alone folks overriding the function), and
- The function returns an object which means that the
&
should have negligible impact behavior (for better or worse or mystery, both signatures allow the caller to mutate the domain object)
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.
Yes & a third point is that I have learnt those & were ADDED to support php4
Ive just pushed a commit to remove that test |
CRM/Core/Error.php
Outdated
@@ -600,7 +600,15 @@ public static function debug_log_message($message, $out = FALSE, $comp = '', $pr | |||
} | |||
$file_log->close(); | |||
|
|||
if (!empty($config->userFrameworkLogging)) { | |||
if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['userFrameworkLogging'])) { |
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.
(a) In my experience/environment, the first isset()
hasn't been necessary. If it is necessary, then we probably need to cleanup a lot of others. (Also: curious to know what environment you have where it's necessary.)
(b) If it is necessary to explicitly check both, then you can probably combine the two isset()
s:
if (!isset(\Civi::$statics[__CLASS__], \Civi::$statics[__CLASS__]['userFrameworkLogging']))
Civi.php
Outdated
@@ -95,6 +95,7 @@ public static function service($id) { | |||
public static function reset() { | |||
self::$statics = array(); | |||
Civi\Core\Container::singleton(); | |||
\Civi::service('settings_manager')->useDefaults(); |
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.
Agree that putting useDefaults()
in boot()
would have unintended consequences. IIRC, during dev, I'd originally applied defaults during boot()
but had to move it. (Maybe to support edge cases around using hook_civicrm_config
to manipulate $civicrm_setting
data?)
FWIW, in my mind, there are two different notions of "reset":
- Thin reset: Tear down running service objects... basically just flush statics. This was a new function,
Civi::reset()
. It leaves the system in an unbootstrapped state. (FWIW, in a design like "Symfony Standard Edition", that's a pretty much all you need to do. Much of the initialization is sequenced automatically/implicitly/on-demand when you request things from the container.) - Full reset: Tear down and restart the services. This was
CRM_Core_Config::singleton(1,1)
. It leaves the system in a bootstrapped state. This was the preexisting functionality used byCiviUnitTestCase
(and takes a lot of care to preserve sequence of steps).
FWIW, the current CiviUnitTestCase
says this:
\Civi::reset();
$config = CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance
My gut says this patch is more intellectually consistent:
diff --git a/Civi/Test/CiviTestListener.php b/Civi/Test/CiviTestListener.php
index 3bd6f0d..c87f60f 100644
--- a/Civi/Test/CiviTestListener.php
+++ b/Civi/Test/CiviTestListener.php
@@ -98,6 +98,7 @@ class CiviTestListener extends \PHPUnit_Framework_BaseTestListener {
$config = \CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance
\CRM_Utils_System::flushCache();
\Civi::reset();
+ \CRM_Core_Config::singleton(TRUE, TRUE);
\CRM_Core_Session::singleton()->set('userID', NULL);
if (property_exists($config->userPermissionClass, 'permissions')) {
although (either way) we probably want to spot-check a couple other extensions to see that they still run tests correctly.
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 find the fact that
\CRM_Core_Config::singleton(TRUE, TRUE);
instantiates the system desparately confusing!
does it need to be called twice above?
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.
Agree it's really confusing. IMHO, the $force
idiom is at least consistent with other stuff, but $loadFromDB==FALSE
is really weird. (If I had to guess, it probably exists because some common utility function like ts()
or escapeString()
turns batty without CRM_Core_Config
.)
When refactoring before, I figured we needed to retain it on general principle, but now I'm not so sure: grepping universe (rgrep CRM_Core_Config::singleton | grep -v 'singleton()'
), there are only a handful of cases which use $loadFromDB==FALSE
. Feel like there's 2/3 chance we could kill that mode with 1-2 days work.
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.
Hmm, regarding CiviTestListener
, it's interesting that CRM_Core_Config::singleton(TRUE,TRUE)
is called 3 lines higher...
9b501a5
to
70f6a7c
Compare
@totten I tried just moving that line in the same file & it worked for my test in the extended reports extension. I tried running the mosaico & civivolunteer tests. Both failed with or without the patch - mosaico Fatal error: Class 'Civi\FlexMailer\Listener\BaseListener' not found in /Users/emcnaughton/buildkit/build/dmaster/sites/default/files/civicrm/ext/uk.co.vedaconsulting.mosaico/CRM/Mosaico/UrlFilter.php on line 12 civivolunteer I'm trying to run the mosaico one properly but I did get several tests in so it wasn't a complete miss. I'm inclined to say we should merge this & add extended reports to CI - this will only affect tests, not any live code & by locking this much in then any fall out (unlikely) can be a step up the ladder |
dbe9f29
to
f8d9eed
Compare
…ng once fix code style per Tim
f8d9eed
to
f1a0f01
Compare
CRM-19672 remove test that calls removed functions. The point of the test (& the function) was to cope with the settings stored in which no longer exist
I used buildkit to generate & run the extension test. The issue was that the settings were being loaded but later the \Civi::reset(); function was being called - From the testListener I think and it was flushing the settings bag so it no longer held default variables I did look at putting this in the boot function instead and only rejected that for fear of unintended consequences.
f1a0f01
to
33fefd5
Compare
A recent commit for CRM-19672 changed the signature for `getDomain()`. It now returns a regular object (not a reference), but this means that you cannot pass the domain directly through to `replaceDomainTokens()`. This manifested as a test error when running `flexmailer` on my local PHP 5.6/7.0 system.
@eileenmcnaughton The regression in running the Based on grepping the known universe, I can't find anything else which is likely to be affected:
I'm not certain why this issue manifested in the test for
|
It's passing with your fix & I checked for CRM_Core_BAO_Domain::getDomain & it is not passed into a function anywhere else - so I think this is good now? |
As an aside, I think it's a bit silly that domain is passed into that function at all, since every calling function just loads it in preparation for that function |
Yeah, I had the same reaction about its silliness. Anyway, no point in procrastinating more on a merge! |
yay |
This is another PR I can't document. Stuff is removed, and it has to do with settings, and it sounds like a good thing? Could anyone take a stab at a sentence or two of explanation on this? |
From my recollection of the Mattermost conversations, the general impression was this: #9420 improves an edge-case observed when unit-testing Extended Reports, and it removes some obsolete functions from the Domain BAO. The commits reference a couple JIRA issues. However, and I can't draw a straight-line between that recollection and the JIRA issues. |
Thanks @totten this helps. Those issues explain the changes to CRM/Core/Error.php that I saw, and I'm glad to hear that the other stuff really was just cleanup. |
CRM-19672 has been recently reported by others, on MM - it affects Wordpress users in some edge cases having the page not load when the browser returns from a payment processor |
The other one prevents an even-more edge-case code loop |
No description provided.