Skip to content
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

CRM-21568 - Move emptiness judgments from SettingsBag::setDb to InnoDBIndexer #11423

Merged
merged 1 commit into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CRM/Core/InnoDBIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public static function singleton($fresh = FALSE) {
* Specification of the setting (per *.settings.php).
*/
public static function onToggleFts($oldValue, $newValue, $metadata) {
if (empty($oldValue) && empty($newValue)) {
return;
}

$indexer = CRM_Core_InnoDBIndexer::singleton();
$indexer->setActive($newValue);
$indexer->fixSchemaDifferences();
Expand Down
8 changes: 5 additions & 3 deletions Civi/Core/SettingsBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,11 @@ protected function setDb($name, $value) {
}
$dao->find(TRUE);

// string comparison with 0 always return true, so to be ensure the type use ===
// ref - https://stackoverflow.com/questions/8671942/php-string-comparasion-to-0-integer-returns-true
if (isset($metadata['on_change']) && !($value === 0 && ($dao->value === NULL || unserialize($dao->value) == 0))) {
// Call 'on_change' listeners. It would be nice to only fire when there's
// a genuine change in the data. However, PHP developers have mixed
// expectations about whether 0, '0', '', NULL, and FALSE represent the same
// value, so there's no universal way to determine if a change is genuine.
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(
\Civi\Core\Resolver::singleton()->get($callback),
Expand Down