collectiveaccess / pawtucket2

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

"Something went wrong" on first try to display related objects #110

Open karkraeg opened 1 month ago

karkraeg commented 1 month ago

Hi, after Updating to the php8 branch of Pawtucket2 I sometimes get "Something went wrong" errors on Occurrence detail pages where I try to display related objects (and sometimes related occurrences as well):

Screenshot of Arc at 14_ Aug 2024 at 07_51_52

When I reload the page it always works:

Screenshot of Arc at 14_ Aug 2024 at 07_52_01

I pulled the latest changes right now I do have a log_db_errors file now which contains errors like this:

2024-08-14 1:49:01 - ERROR --> [1::565376] {"code":250,"errorNumber":1064,"errorMessage":"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND ca_occurrences_x_vocabulary_terms.type_id IN (160,160) LIMIT 1' at line 11","sql":"\n\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\tFROM ca_occurrences\n\t\t\t\t\t\tINNER JOIN ca_occurrences_x_vocabulary_terms ON ca_occurrences.occurrence_id = ca_occurrences_x_vocabulary_terms.occurrence_id\n\nINNER JOIN ca_list_items ON ca_occurrences_x_vocabulary_terms.item_id = ca_list_items.item_id\n\nINNER JOIN ca_objects_x_occurrences ON ca_occurrences.occurrence_id = ca_objects_x_occurrences.occurrence_id\n\nINNER JOIN ca_objects ON ca_objects_x_occurrences.object_id = ca_objects.object_id\n\n\t\t\t\t\t\t\t WHERE (ca_objects.object_id IN (1372,3206,10927,19508,19599,5857,9712)) AND (ca_list_items.access IN (42)) AND (ca_occurrences.access IN (42)) AND (ca_occurrences.deleted = 0) AND (ca_list_items.deleted = 0) AND (ca_objects.deleted = 0) AND (ca_objects.access IN (42)) AND (ca_objects_x_occurrences.type_id IN ()) AND ca_occurrences_x_vocabulary_terms.type_id IN (160,160) LIMIT 1","stacktrace":"\/var\/www\/html\/pawtucket\/app\/lib\/Db\/mysqli.php::caPrintStacktrace@356<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Db\/DbStatement.php:Db_mysqli:execute@150<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Db.php:DbStatement:executeWithParamsAsArray@259<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:Db:query@7049<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:BrowseEngine:getFacetContent@3100<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:BrowseEngine:getFacet@3056<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:BrowseEngine:loadFacetContent@3015<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BaseBrowse.php:BrowseEngine:execute@48<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/controllers\/SearchController.php:BaseBrowse:execute@371<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Controller\/RequestDispatcher.php:SearchController:__call@289<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Controller\/AppController.php:RequestDispatcher:dispatch@108<br\/>\n\n\/var\/www\/html\/pawtucket\/index.php:AppController:dispatch@134<br\/>\n"}

2024-08-14 1:49:48 - ERROR --> [1::565376] {"code":250,"errorNumber":1064,"errorMessage":"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND ca_occurrences_x_vocabulary_terms.type_id IN (160,160) LIMIT 1' at line 11","sql":"\n\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\tFROM ca_occurrences\n\t\t\t\t\t\tINNER JOIN ca_occurrences_x_vocabulary_terms ON ca_occurrences.occurrence_id = ca_occurrences_x_vocabulary_terms.occurrence_id\n\nINNER JOIN ca_list_items ON ca_occurrences_x_vocabulary_terms.item_id = ca_list_items.item_id\n\nINNER JOIN ca_objects_x_occurrences ON ca_occurrences.occurrence_id = ca_objects_x_occurrences.occurrence_id\n\nINNER JOIN ca_objects ON ca_objects_x_occurrences.object_id = ca_objects.object_id\n\n\t\t\t\t\t\t\t WHERE (ca_objects.object_id IN (1372,3206,10927,19508,19599)) AND (ca_list_items.access IN (42)) AND (ca_occurrences.access IN (42)) AND (ca_occurrences.deleted = 0) AND (ca_list_items.deleted = 0) AND (ca_objects.deleted = 0) AND (ca_objects.access IN (42)) AND (ca_objects_x_occurrences.type_id IN ()) AND ca_occurrences_x_vocabulary_terms.type_id IN (160,160) LIMIT 1","stacktrace":"\/var\/www\/html\/pawtucket\/app\/lib\/Db\/mysqli.php::caPrintStacktrace@356<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Db\/DbStatement.php:Db_mysqli:execute@150<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Db.php:DbStatement:executeWithParamsAsArray@259<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:Db:query@7049<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:BrowseEngine:getFacetContent@3100<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:BrowseEngine:getFacet@3056<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BrowseEngine.php:BrowseEngine:loadFacetContent@3015<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Browse\/BaseBrowse.php:BrowseEngine:execute@48<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/controllers\/SearchController.php:BaseBrowse:execute@371<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Controller\/RequestDispatcher.php:SearchController:__call@289<br\/>\n\n\/var\/www\/html\/pawtucket\/app\/lib\/Controller\/AppController.php:RequestDispatcher:dispatch@108<br\/>\n\n\/var\/www\/html\/pawtucket\/index.php:AppController:dispatch@134<br\/>\n"}

Is this due to a misconfiguration on my parts or a valid bug? Thanks!

karkraeg commented 1 month ago

I use the following snippet to render this "Related objects" passage in ca_occurrences_default_html.php in my theme:

{{{<ifcount code="ca_objects" min="1"><h5>Related Objects (^ca_objects._count)</h5>
    <div class="row">
        <div id="browseResultsContainer">
            <?php echo caBusyIndicatorIcon($this->request).' '.addslashes(_t('Lädt...')); ?>
        </div><!-- end browseResultsContainer -->
    </div><!-- end row -->
    <script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery("#browseResultsContainer").load("<?php echo caNavUrl($this->request, '', 'Search', 'objects', array('search' => 'occurrence_id:^ca_occurrences.occurrence_id'), array('dontURLEncodeParameters' => true)); ?>", function () {
                jQuery('#browseResultsContainer').jscroll({
                    autoTrigger: true,
                    loadingHtml: '<?php echo caBusyIndicatorIcon($this->request).' '.addslashes(_t('Loading...')); ?>',
                    padding: 20,
                    nextSelector: 'a.jscroll-next'
                });
            });
        });
    </script>
</ifcount>}}}
collectiveaccess commented 1 month ago

What does your browse.conf look like?

I just pushed a change that should address this issue, but I'll need your browse.conf config to better test it.