Skip to content

Commit 15ffca5

Browse files
committed
Merge branch 'main' into next
2 parents 146e878 + e266417 commit 15ffca5

File tree

6 files changed

+191
-25
lines changed

6 files changed

+191
-25
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ If you see SQL errors after upgrading please remember to check for this specific
267267

268268
UPS shut down their old CGI APIs so we removed the support for it from the Mage_Usa module.
269269

270+
### Between OpenMage 20.x and 21.x (unreleased, available on branch `next`)
271+
272+
- PHP 8.1 as minimum required version
273+
- Removed scriptaculous/dragdrop.js (#3215)
274+
- RWD theme: updated jQuery to 3.7.0 (#3204)
275+
- Unified CSRF configuration (#3147) and added form key validation to Contacts form (#3146)
276+
- Removed double span element from HTML buttons (#3123)
277+
- Removed all deprecated Mysql4_ classes (#2730). If there are any old modules/extensions in your installation that use such classes, you must run `shell/rename-mysql4-class-to-resource.php` in the command line in order to convert them. Backup all files before running the script
278+
270279
### New Config Options
271280

272281
- `admin/design/use_legacy_theme`
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* OpenMage
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available at https://opensource.org/license/osl-3-0-php
8+
*
9+
* @category Mage
10+
* @package Mage
11+
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
12+
* @copyright Copyright (c) 2020 The OpenMage Contributors (https://www.openmage.org)
13+
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14+
*/
15+
16+
/**
17+
* @category Mage
18+
* @package Mage_Api
19+
*/
20+
class Mage_Api_Model_Server_Adapter_Jsonrpc extends Varien_Object implements Mage_Api_Model_Server_Adapter_Interface
21+
{
22+
protected $_jsonRpc = null;
23+
24+
/**
25+
* Set handler class name for webservice
26+
*
27+
* @param string $handler
28+
* @return $this
29+
*/
30+
public function setHandler($handler)
31+
{
32+
$this->setData('handler', $handler);
33+
return $this;
34+
}
35+
36+
/**
37+
* Retrieve handler class name for webservice
38+
*
39+
* @return string
40+
*/
41+
public function getHandler()
42+
{
43+
return $this->getData('handler');
44+
}
45+
46+
/**
47+
* Set webservice api controller
48+
*
49+
* @param Mage_Api_Controller_Action $controller
50+
* @return $this
51+
*/
52+
public function setController(Mage_Api_Controller_Action $controller)
53+
{
54+
$this->setData('controller', $controller);
55+
return $this;
56+
}
57+
58+
/**
59+
* Retrieve webservice api controller. If no controller have been set - emulate it by the use of Varien_Object
60+
*
61+
* @return Mage_Api_Controller_Action|Varien_Object
62+
*/
63+
public function getController()
64+
{
65+
$controller = $this->getData('controller');
66+
67+
if (null === $controller) {
68+
$controller = new Varien_Object(
69+
array('request' => Mage::app()->getRequest(), 'response' => Mage::app()->getResponse())
70+
);
71+
72+
$this->setData('controller', $controller);
73+
}
74+
return $controller;
75+
}
76+
77+
/**
78+
* Run webservice
79+
*
80+
* @return $this
81+
*/
82+
public function run()
83+
{
84+
$this->_jsonRpc = new Zend_Json_Server();
85+
$this->_jsonRpc->setClass($this->getHandler());
86+
$this->getController()->getResponse()
87+
->clearHeaders()
88+
->setHeader('Content-Type', 'application/json; charset=utf8')
89+
->setBody($this->_jsonRpc->handle());
90+
return $this;
91+
}
92+
93+
/**
94+
* Dispatch webservice fault
95+
*
96+
* @param int $code
97+
* @param string $message
98+
*/
99+
public function fault($code, $message)
100+
{
101+
throw new Zend_Json_Exception($message, $code);
102+
}
103+
}

app/code/core/Mage/Api/Model/Server/Handler/Abstract.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public function __construct()
3535
* @param string $errorFile
3636
* @return bool
3737
*/
38-
public function handlePhpError($errorCode, $errorMessage, $errorFile)
38+
public function handlePhpError($errorCode, $errorMessage, $errorFile, $errLine)
3939
{
40-
Mage::log($errorMessage . $errorFile);
40+
Mage::log($errorMessage . ' in ' . $errorFile . ' on line ' . $errLine, Zend_Log::ERR);
4141
if (in_array($errorCode, [E_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR])) {
4242
$this->_fault('internal');
4343
}
@@ -225,6 +225,10 @@ public function login($username, $apiKey = null)
225225
*/
226226
public function call($sessionId, $apiPath, $args = [])
227227
{
228+
// Allow insta-login via HTTP Basic Auth
229+
if ($sessionId === null && ! empty($_SERVER['PHP_AUTH_USER']) && ! empty($_SERVER['PHP_AUTH_PW'])) {
230+
$sessionId = $this->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
231+
}
228232
$this->_startSession($sessionId);
229233

230234
if (!$this->_getSession()->isLoggedIn($sessionId)) {
@@ -309,6 +313,10 @@ public function call($sessionId, $apiPath, $args = [])
309313
*/
310314
public function multiCall($sessionId, array $calls = [], $options = [])
311315
{
316+
// Allow insta-login via HTTP Basic Auth
317+
if ($sessionId === null && ! empty($_SERVER['PHP_AUTH_USER']) && ! empty($_SERVER['PHP_AUTH_PW'])) {
318+
$sessionId = $this->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
319+
}
312320
$this->_startSession($sessionId);
313321

314322
if (!$this->_getSession()->isLoggedIn($sessionId)) {
@@ -437,6 +445,10 @@ public function multiCall($sessionId, array $calls = [], $options = [])
437445
*/
438446
public function resources($sessionId)
439447
{
448+
// Allow insta-login via HTTP Basic Auth
449+
if ($sessionId === null && ! empty($_SERVER['PHP_AUTH_USER']) && ! empty($_SERVER['PHP_AUTH_PW'])) {
450+
$sessionId = $this->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
451+
}
440452
$this->_startSession($sessionId);
441453

442454
if (!$this->_getSession()->isLoggedIn($sessionId)) {
@@ -501,6 +513,10 @@ public function resources($sessionId)
501513
*/
502514
public function resourceFaults($sessionId, $resourceName)
503515
{
516+
// Allow insta-login via HTTP Basic Auth
517+
if ($sessionId === null && ! empty($_SERVER['PHP_AUTH_USER']) && ! empty($_SERVER['PHP_AUTH_PW'])) {
518+
$sessionId = $this->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
519+
}
504520
$this->_startSession($sessionId);
505521

506522
if (!$this->_getSession()->isLoggedIn($sessionId)) {
@@ -537,6 +553,10 @@ public function resourceFaults($sessionId, $resourceName)
537553
*/
538554
public function globalFaults($sessionId)
539555
{
556+
// Allow insta-login via HTTP Basic Auth
557+
if ($sessionId === null && ! empty($_SERVER['PHP_AUTH_USER']) && ! empty($_SERVER['PHP_AUTH_PW'])) {
558+
$sessionId = $this->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
559+
}
540560
$this->_startSession($sessionId);
541561
return array_values($this->_getConfig()->getFaults());
542562
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* OpenMage
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available at https://opensource.org/license/osl-3-0-php
8+
*
9+
* @category Mage
10+
* @package Mage_Api
11+
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
12+
* @copyright Copyright (c) 2020-2022 The OpenMage Contributors (https://www.openmage.org)
13+
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14+
*/
15+
16+
/**
17+
* Webservice main controller
18+
*
19+
* @category Mage
20+
* @package Mage_Api
21+
*/
22+
class Mage_Api_JsonrpcController extends Mage_Api_Controller_Action
23+
{
24+
public function indexAction()
25+
{
26+
$this->_getServer()->init($this, 'jsonrpc')
27+
->run();
28+
}
29+
}

app/code/core/Mage/Api/etc/api.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
<handler>default</handler>
5959
<active>1</active>
6060
</xmlrpc>
61+
<jsonrpc>
62+
<model>api/server_adapter_jsonrpc</model>
63+
<handler>default</handler>
64+
<active>1</active>
65+
</jsonrpc>
6166
<default>
6267
<use>soap</use>
6368
</default>

composer.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)