Giter VIP home page Giter VIP logo

opencultureconsulting / simple-oai-pmh Goto Github PK

View Code? Open in Web Editor NEW
14.0 5.0 8.0 413 KB

This is a stand-alone OAI-PMH data provider. It serves records in any metadata format from directories of XML files using the directory name as metadata prefix, the filename as identifier and the filemtime as datestamp. 0-byte files are considered deleted records and handled accordingly. Resumption tokens are managed using files.

Home Page: https://demo.opencultureconsulting.com/simple-oai-pmh/?verb=Identify

License: GNU General Public License v3.0

PHP 64.69% XSLT 35.31%
oai oai-pmh data-provider code4lib repository php

simple-oai-pmh's Issues

PHP 8.1 compatibility / createElement Deprecated Warning

Hi,

the current code base throws a PHP warrning if ?verb=ListMetadataFormats is called:
Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in ./Classes/Response.php on line 64.

The is caused by the function public function addChild() which tries to create an element with an empty string as value. In my understanding this triggers a warning since PHP 8.1.

To create an empty element you can simply omit the value. Quick workaround (Response.php from line 63):

public function addChild($mom_node, $name, $value = '') {
        if (!empty($value)) {
                $added_node = $this->doc->createElement($name, $value);
        } else {
                $added_node = $this->doc->createElement($name);
        }
        $added_node = $mom_node->appendChild($added_node);
        return $added_node;
}

There might be a nicer fix to this, though.

Filw autoload filw

Hello, I downloaded the code, but it does not contain the autoload.php file.

how can I get it?
thank you.

Suggestion to improve security

Some recommendations to improve security:

  • Add .htaccess files to deny access to all directories except the stylesheet
  • Add .htaccess file to deny access to the "update.php" file

Possible bug in Server.php

Getting the following error with PHP 8.2 and the following request:
?verb=ListRecords&metadataPrefix=oai_dc&from=2023-01-15T00:00:00Z&until=2023-01-25T23:59:59Z

The error is:

stderr: Stack trace:
stderr: #0 /oai/Classes/Server.php(292): array_sum(false)
stderr: #1 /oai/Classes/Server.php(187): OCC\\OAI2\\Server->checkDateFormat('2023-01-15T00:0...')
stderr: #2 [internal function]: OCC\\OAI2\\Server->ListRecords()
stderr: #3 /oai/Classes/Server.php(56): call_user_func(Array)
stderr: #4 /oai/index.php(73): OCC\\OAI2\\Server->__construct('...', Array, Array, Array, Array)
stderr: #5 {main}
stderr:   thrown in /oai/Classes/Server.php on line 292
stderr: PHP Fatal error:  Uncaught TypeError: array_sum(): Argument #1 ($array) must be of type array, bool given in /oai/Classes/Server.php:292

I looked at the code in Server.php, line 292 here:
https://github.com/opencultureconsulting/oai_pmh/blob/master/Classes/Server.php#L292

 return ($datetime !== false) && !array_sum($datetime->getLastErrors());

The docs for "getLastErrors()" say that in case there are no errors a boolean is returned:
https://www.php.net/manual/en/datetime.getlasterrors.php

Returns array containing info about warnings and errors, or false if there are neither warnings nor errors.

I changed my copy of the code as follows and it is working now:

return ($datetime !== false) && ($datetime->getLastErrors() == false);

I can provide a pull request but I am not that familiar with PHP so I am not sure if this is a real bug.

POST requests not handled correctly

openarchives.org validation fails on my OAI repository based on opencultureconsulting / oai_pmh : POST requests are not handled correctly.

### Checking that HTTP POST requests are handled correctly
REQUEST https://oai.telemillevaches.net/ POST verb:Identify
FAIL POST test 1 for Identify was unsuccessful, an OAI error response was received
REQUEST https://oai.telemillevaches.net/ POST identifier:oai:oai.telemillevaches.net:2021-12-07:documentaire:exode-urbain-bonne-nouvelle-ou-nouveau-desastre metadataPrefix:oai_dc verb:GetRecord
FAIL POST test 2 for GetRecord was unsuccessful, an OAI error response was received

http://www.openarchives.org/Register/ValidateSite?log=V3Z0MIWI

FAIL Error code badArgument not found in response but should be given to the request: verb=ListRecords&metadataPrefix=oai_dc&from=2002-02-05&until=2002-02-06T05:35:00Z The request has different granularities for the from and until parameters.

openarchives.org validation fails on my OAI repository based on opencultureconsulting / oai_pmh : a request that has different granularities should receive a badArgument error.

### Checking for version 2.0 specific exceptions
REQUEST https://oai.telemillevaches.net/?verb=ListRecords&metadataPrefix=oai_dc&from=2002-02-05&until=2002-02-06T05:35:00Z GET
FAIL Error code badArgument not found in response but should be given to the request: verb=ListRecords&metadataPrefix=oai_dc&from=2002-02-05&until=2002-02-06T05:35:00Z The request has different granularities for the from and until parameters.

Full log : http://www.openarchives.org/Register/ValidateSite?log=V3Z0MIWI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.