Skip to content

Commit

Permalink
ENH Remove code that had been retained for backwards compatibility (#…
Browse files Browse the repository at this point in the history
…11541)

We don't need to retain this compatibility anymore. Some of this is dead
code, and some is just tech debt that should have been properly
deprecated.
  • Loading branch information
GuySartorelli authored Jan 9, 2025
1 parent 6752490 commit cea977d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
28 changes: 2 additions & 26 deletions src/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1338,32 +1338,8 @@ public function validate(): ValidationResult
* form that has some fields that save to one object, and some that save to another.
* @return $this
*/
public function loadDataFrom($data, $mergeStrategy = 0, $fieldList = null)
public function loadDataFrom(object|array $data, int $mergeStrategy = 0, array $fieldList = [])
{
if (!is_object($data) && !is_array($data)) {
user_error("Form::loadDataFrom() not passed an array or an object", E_USER_WARNING);
return $this;
}

// Handle the backwards compatible case of passing "true" as the second argument
if ($mergeStrategy === true) {
Deprecation::notice(
'5.4.0',
'Passing `true` to the $mergeStrategy argument in ' . Form::class . '::loadDataFrom() is deprecated.'
. ' Pass ' . Form::class . '::MERGE_CLEAR_MISSING instead.',
Deprecation::SCOPE_GLOBAL
);
$mergeStrategy = Form::MERGE_CLEAR_MISSING;
} elseif ($mergeStrategy === false) {
Deprecation::notice(
'5.4.0',
'Passing `false` to the $mergeStrategy argument in ' . Form::class . '::loadDataFrom() is deprecated.'
. ' Pass 0 instead.',
Deprecation::SCOPE_GLOBAL
);
$mergeStrategy = 0;
}

// If an object is passed, save it for historical reference through {@link getRecord()}
// Also use this to determine if we are loading a submitted form, or loading
// from a record
Expand Down Expand Up @@ -1392,7 +1368,7 @@ public function loadDataFrom($data, $mergeStrategy = 0, $fieldList = null)
$name = $field->getName();

// Skip fields that have been excluded
if ($fieldList && !in_array($name, $fieldList ?? [])) {
if (!empty($fieldList) && !in_array($name, $fieldList)) {
continue;
}

Expand Down
11 changes: 2 additions & 9 deletions src/ORM/Connect/MySQLDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,9 @@ public function searchEngine(
}
}

// Always ensure that only pages with ShowInSearch = 1 can be searched
// Always ensure that only pages/files with ShowInSearch = 1 can be searched
$extraFilters[$pageClass] .= " AND ShowInSearch <> 0";

// File.ShowInSearch was added later, keep the database driver backwards compatible
// by checking for its existence first
$fileTable = DataObject::getSchema()->tableName($fileClass);
$fields = $this->getSchemaManager()->fieldList($fileTable);
if (array_key_exists('ShowInSearch', $fields ?? [])) {
$extraFilters[$fileClass] .= " AND ShowInSearch <> 0";
}
$extraFilters[$fileClass] .= " AND ShowInSearch <> 0";

$limit = (int)$start . ", " . (int)$pageLength;

Expand Down

0 comments on commit cea977d

Please sign in to comment.