| @@ -7,9 +7,8 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace Calotes\Component; |
| 9 | 9 | |
| 10 | 10 | use Calotes\Base\Model; |
| 11 | -use Calotes\Helper\HTTP; | |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * Parse and validate request data. |
| 15 | 14 | */ |
| @@ -26,12 +25,16 @@ | ||
| 26 | 25 | * Constructor to initialize the object with data from the POST or GET request. |
| 27 | 26 | */ |
| 28 | 27 | public function __construct() { |
| 29 | 28 | if ( 'POST' === defender_get_data_from_request( 'REQUEST_METHOD', 's' ) ) { |
| 30 | - $this->data = HTTP::post( 'data', '' ); | |
| 29 | + $this->data = defender_get_data_from_request( 'data', 'p' ); | |
| 31 | 30 | } else { |
| 32 | - $this->data = HTTP::get( 'data', '' ); | |
| 31 | + $this->data = defender_get_data_from_request( 'data', 'g' ); | |
| 33 | 32 | } |
| 33 | + // defender_get_data_from_request( 'data', … ) JSON-decodes; empty/malformed yields null. Central assigns get_data() to $_POST — must stay array (PHP 8+). | |
| 34 | + if ( ! is_array( $this->data ) ) { | |
| 35 | + $this->data = array(); | |
| 36 | + } | |
| 34 | 37 | } |
| 35 | 38 | |
| 36 | 39 | /** |
| 37 | 40 | * Retrieve the data that will be in use, it's recommended that $filters should be provided for data validation and |
| @@ -41,9 +44,9 @@ | ||
| 41 | 44 | * |
| 42 | 45 | * @return array |
| 43 | 46 | */ |
| 44 | 47 | public function get_data( $filters = array() ) { |
| 45 | - if ( empty( $filters ) ) { | |
| 48 | + if ( ! is_array( $filters ) || array() === $filters ) { | |
| 46 | 49 | return $this->data; |
| 47 | 50 | } |
| 48 | 51 | $data = array(); |
| 49 | 52 | foreach ( $filters as $key => $rule ) { |