function _locale_translation_source_compare
Same name and namespace in other branches
- 10 core/modules/locale/locale.translation.inc \_locale_translation_source_compare()
- 11.x core/modules/locale/locale.translation.inc \_locale_translation_source_compare()
- 9 core/modules/locale/locale.translation.inc \_locale_translation_source_compare()
- 8.9.x core/modules/locale/locale.translation.inc \_locale_translation_source_compare()
Compare two update sources, looking for the newer one.
The timestamp property of the source objects are used to determine which is the newer one.
Parameters
object $source1: Source object of the first translation source.
object $source2: Source object of available update.
Return value
int
- "LOCALE_TRANSLATION_SOURCE_COMPARE_LT": $source1 < $source2 OR $source1 is missing.
- "LOCALE_TRANSLATION_SOURCE_COMPARE_EQ": $source1 == $source2 OR both $source1 and $source2 are missing.
- "LOCALE_TRANSLATION_SOURCE_COMPARE_GT": $source1 > $source2 OR $source2 is missing.
Deprecated
in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement.
See also
https://www.drupal.org/node/3569330
File
-
core/
modules/ locale/ locale.translation.inc, line 358
Code
function _locale_translation_source_compare($source1, $source2) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3569330', E_USER_DEPRECATED);
if (isset($source1->timestamp) && isset($source2->timestamp)) {
if ($source1->timestamp == $source2->timestamp) {
return LOCALE_TRANSLATION_SOURCE_COMPARE_EQ;
}
else {
return $source1->timestamp > $source2->timestamp ? LOCALE_TRANSLATION_SOURCE_COMPARE_GT : LOCALE_TRANSLATION_SOURCE_COMPARE_LT;
}
}
elseif (isset($source1->timestamp) && !isset($source2->timestamp)) {
return LOCALE_TRANSLATION_SOURCE_COMPARE_GT;
}
elseif (!isset($source1->timestamp) && isset($source2->timestamp)) {
return LOCALE_TRANSLATION_SOURCE_COMPARE_LT;
}
else {
return LOCALE_TRANSLATION_SOURCE_COMPARE_EQ;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.