collectiveaccess / pawtucket2

Pawtucket Improved
GNU General Public License v3.0
82 stars 75 forks source link

Carousel Slides in Wrong Order #53

Closed miqrogroove closed 1 year ago

miqrogroove commented 1 year ago

When loading an object Details page in v1.7.15, the carousel slides are in ascending numerical order by representation ID. The detailRepresentationThumbnails on the other hand are in catalog order. This discrepancy causes unexpected behavior of the left and right arrow clicks.

This is a continuation of problems described in #38.

miqrogroove commented 1 year ago

This is where it looks like representations are being ordered by ID for slides:

https://github.com/collectiveaccess/pawtucket2/blob/546efe40ffe92eb44f37239d0865c32e992088e5/app/helpers/displayHelpers.php#L3724

The array keys are set to zero for primary representation, otherwise by ID (?) -- needs testing.

Here is the input data I will use to test this:

mysql> SELECT * FROM ca_objects_x_object_representations WHERE object_id = 2906;
+-------------+-----------+-------------------+------------+------+
| relation_id | object_id | representation_id | is_primary | rank |
+-------------+-----------+-------------------+------------+------+
|        3636 |      2906 |              3542 |          1 | 3542 |
|        3637 |      2906 |              3543 |          0 | 3543 |
|        3638 |      2906 |              3544 |          0 | 3544 |
|        3642 |      2906 |              3545 |          0 | 3642 |
|        3644 |      2906 |              3546 |          0 | 3644 |
|        3643 |      2906 |              3547 |          0 | 3643 |
+-------------+-----------+-------------------+------------+------+
6 rows in set (0.00 sec)
miqrogroove commented 1 year ago

My test stubs using above input data failed as expected. For each of the last five rows, this expression evaluated to true and forced the $vn_index assignment to the representation ID on the next line after that:

https://github.com/collectiveaccess/pawtucket2/blob/546efe40ffe92eb44f37239d0865c32e992088e5/app/helpers/displayHelpers.php#L3719

miqrogroove commented 1 year ago

New test using the same data and the following stub...

var_export( $qr_reps->get(RepresentableBaseModel::getRepresentationRelationshipTableName($qr_reps->tableName()).'.rank'), true )

... always returns NULL

Drilling down further, $qr_reps->tableName() returns as expected with 'ca_object_representations'.

Then RepresentableBaseModel::getRepresentationRelationshipTableName() returns NULL. Here is the culprit!

PR will be sent shortly.