Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apa.csl, sort, Undefined property: stdClass::$status in Style\Sort\Sort.php on line 126 #157

Open
3 tasks done
glorieux-f opened this issue Aug 1, 2023 · 2 comments
Open
3 tasks done

Comments

@glorieux-f
Copy link
Contributor

glorieux-f commented Aug 1, 2023

Please follow the general troubleshooting steps first:

  • I read the README and followed the instructions.
  • I am sure that the used CSL metadata follows the CSL schema.
  • I use a valid CSL stylesheet

Bug reports:

In apa.csl#L285 we can read « APA sorts 1. no-date items, 2. items with dates, 3. in-press (status) items ». Your sort algorithm seems (sorry, I have not dig it fully) to suppose that the status property is always available. « Undefined property: stdClass::$status in Style\Sort\Sort.php on line 126 ».

Used CSL stylesheet:

apa.csl

Used CSL metadata

Minimum CSL data to reproduce the bug.

[
    {
        "id": "http://zotero.org/groups/5048422/items/E9V3HGZ9",
        "type": "article-journal",
        "title": "title",
        "author": [
            {
                "family": "Doe",
                "given": "John"
            }
        ],
        "issued": {
            "date-parts": [
                [
                    "1911"
                ]
            ]
        }
    },
    {
        "id": "http://zotero.org/groups/5048422/items/KFWGRZP2",
        "type": "article-journal",
        "title": "title",
        "author": [
            {
                "family": "Doe",
                "given": "John"
            }
        ],
        "issued": {
            "date-parts": [
                [
                    "1911"
                ]
            ]
        }
    }
]
glorieux-f added a commit to glorieux-f/citeproc-php that referenced this issue Aug 3, 2023
@glorieux-f
Copy link
Contributor Author

Other bug in Sort, l. 116, if a sort variable is not available.

@rob-zivtech
Copy link

rob-zivtech commented Apr 25, 2024

Getting this too: Warning: Undefined property: stdClass::$status in /app/vendor/seboettg/citeproc-php/src/Style/Sort/Sort.php on line 126 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /app/vendor/seboettg/citeproc-php/src/Style/Sort/Sort.php on line 126

Line 126 is:

 $sortKey = mb_strtolower(strip_tags($dataItem->{$variable}));

I would recommend adding defensive code:

$sortKey = '';
if(isset($dataItem->{$variable}) && is_string($dataItem->{$variable})) {
   $sortKey = mb_strtolower(strip_tags($dataItem->{$variable}));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants