Skip to content

Commit

Permalink
Fixed missing assets for stale aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Skrypnyk committed Mar 31, 2020
1 parent 80994f9 commit 36477dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public static function load($id) {
$values = Database::getConnection()->select('minisite_asset', 'ma')
->fields('ma')
->condition('id', $id)
->orderBy('id', 'DESC')
->execute()
->fetchAssoc();

Expand All @@ -202,6 +203,7 @@ public static function loadByUri($uri) {
$values = Database::getConnection()->select('minisite_asset', 'ma')
->fields('ma')
->condition('source', $uri)
->orderBy('id', 'DESC')
->execute()
->fetchAssoc();

Expand All @@ -223,6 +225,7 @@ public static function loadByAlias($alias) {
$values = Database::getConnection()->select('minisite_asset', 'ma')
->fields('ma')
->condition('alias', $alias)
->orderBy('id', 'DESC')
->execute()
->fetchAssoc();

Expand All @@ -239,6 +242,7 @@ public static function loadByAlias($alias) {
public static function loadAll() {
$values = Database::getConnection()->select('minisite_asset', 'ma')
->fields('ma')
->orderBy('id', 'DESC')
->execute()
->fetchAllAssoc('id', \PDO::FETCH_ASSOC);

Expand Down
4 changes: 2 additions & 2 deletions tests/src/Functional/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ public function testLoadAll() {
$loaded = Asset::loadAll();

$this->assertEquals(3, count($loaded));
$this->assertEquals($asset1->id(), $loaded[0]->id());
$this->assertEquals($asset3->id(), $loaded[0]->id());
$this->assertEquals($asset2->id(), $loaded[1]->id());
$this->assertEquals($asset3->id(), $loaded[2]->id());
$this->assertEquals($asset1->id(), $loaded[2]->id());
}

}

0 comments on commit 36477dc

Please sign in to comment.