1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 00:37:02 +02:00
This commit is contained in:
Ryan Cramer
2022-08-26 12:19:06 -04:00
parent 866f91424f
commit e8219ba71a
8 changed files with 94 additions and 87 deletions

View File

@@ -430,11 +430,12 @@ abstract class DatabaseQuery extends WireData {
* Implied parameters (using "?") was added in 3.0.157.
*
* @param string $method
* @param array $args
* @param array $arguments
* @return $this
*
*/
public function __call($method, $args) {
public function __call($method, $arguments) {
$args = &$arguments;
// if(!$this->has($method)) return parent::__call($method, $args);
if(!isset($this->queryMethods[$method])) return parent::__call($method, $args);
@@ -443,11 +444,10 @@ abstract class DatabaseQuery extends WireData {
if(!is_array($curValue)) $curValue = array();
$value = $args[0];
if(is_object($value) && $value instanceof DatabaseQuery) {
if($value instanceof DatabaseQuery) {
// if we've been given another DatabaseQuery, load from its $method
// note that if using bindValues you should also copy them separately
// behavior deprecated in 3.l0.157+, please use the copyTo() method instead
/** @var DatabaseQuery $query */
$query = $value;
$value = $query->$method; // array
if(!is_array($value) || !count($value)) return $this; // nothing to import

View File

@@ -25,11 +25,11 @@
* @property array $limit
* @property string $comment Comments for query
*
* @method $this select($sql, array $params = array())
* @method $this select($sql, $params = array())
* @method $this from($sql)
* @method $this join($sql, array $params = array())
* @method $this leftjoin($sql, array $params = array())
* @method $this where($sql, array $params = array())
* @method $this join($sql, $params = array())
* @method $this leftjoin($sql, $params = array())
* @method $this where($sql, $params = array())
* @method $this groupby($sql)
* @method $this limit($sql)
*

View File

@@ -3,7 +3,7 @@
/**
* ProcessWire WireMail
*
* ProcessWire 3.x, Copyright 2021 by Ryan Cramer
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
* #pw-summary A module type that handles sending of email in ProcessWire
@@ -92,7 +92,7 @@ class WireMail extends WireData implements WireMailInterface {
'header' => array(),
'param' => array(),
'attachments' => array(),
);
);
/**
* Construct
@@ -148,6 +148,7 @@ class WireMail extends WireData implements WireMailInterface {
*
*/
protected function sanitizeEmail($email) {
$email = (string) $email;
if(!strlen($email)) return '';
$email = strtolower(trim($email));
if(strpos($email, ':') && preg_match('/^(.+):\d+$/', $email, $matches)) {
@@ -155,14 +156,15 @@ class WireMail extends WireData implements WireMailInterface {
// so remove trailing port, i.e. ':8888', if present since it will not validate
$email = $matches[1];
}
$clean = $this->wire('sanitizer')->email($email);
$sanitizer = $this->wire()->sanitizer;
$clean = $sanitizer->email($email);
if($email !== $clean) {
throw new WireException("Invalid email address: " . $this->wire('sanitizer')->entities($email));
throw new WireException("Invalid email address: " . $sanitizer->entities($email));
}
/** @var WireMailTools $mail */
$mail = $this->wire('mail');
if($mail && $mail->isBlacklistEmail($email)) {
throw new WireException("Email address not allowed: " . $this->wire('sanitizer')->entities($email));
throw new WireException("Email address not allowed: " . $sanitizer->entities($email));
}
return $clean;
}
@@ -176,8 +178,7 @@ class WireMail extends WireData implements WireMailInterface {
*
*/
protected function ___sanitizeHeaderName($name) {
/** @var Sanitizer $sanitizer */
$sanitizer = $this->wire('sanitizer');
$sanitizer = $this->wire()->sanitizer;
$name = $sanitizer->emailHeader($name, true);
// ensure consistent capitalization for header names
$name = ucwords(str_replace('-', ' ', $name));
@@ -194,7 +195,7 @@ class WireMail extends WireData implements WireMailInterface {
*
*/
protected function ___sanitizeHeaderValue($value) {
return $this->wire('sanitizer')->emailHeader($value);
return $this->wire()->sanitizer->emailHeader($value);
}
/**
@@ -219,6 +220,7 @@ class WireMail extends WireData implements WireMailInterface {
*/
protected function extractEmailAndName($email) {
$name = '';
$email = (string) $email;
if(strpos($email, '<') !== false && strpos($email, '>') !== false) {
// email has separate from name and email
if(preg_match('/^(.*?)<([^>]+)>.*$/', $email, $matches)) {
@@ -598,7 +600,7 @@ class WireMail extends WireData implements WireMailInterface {
}
// prep any additional PHP mail params
$param = $this->wire('config')->phpMailAdditionalParameters;
$param = $this->wire()->config->phpMailAdditionalParameters;
if(is_null($param)) $param = '';
foreach($this->param as $value) {
$param .= " $value";
@@ -629,12 +631,13 @@ class WireMail extends WireData implements WireMailInterface {
*/
protected function renderMailHeader() {
$settings = $this->wire()->config->wireMail;
$config = $this->wire()->config;
$settings = $config->wireMail;
$from = $this->from;
if(!strlen($from) && !empty($settings['from'])) $from = $settings['from'];
if(!strlen($from)) $from = $this->wire('config')->adminEmail;
if(!strlen($from)) $from = 'processwire@' . $this->wire('config')->httpHost;
if(!strlen($from)) $from = $config->adminEmail;
if(!strlen($from)) $from = 'processwire@' . $config->httpHost;
$header = "From: " . ($this->fromName ? $this->bundleEmailAndName($from, $this->fromName) : $from);
@@ -741,10 +744,11 @@ class WireMail extends WireData implements WireMailInterface {
protected function renderMailAttachments() {
$body = '';
$boundary = $this->multipartBoundary();
$sanitizer = $this->wire()->sanitizer;
foreach($this->attachments as $filename => $file) {
$filename = $this->wire('sanitizer')->text($filename, array(
$filename = $sanitizer->text($filename, array(
'maxLength' => 512,
'truncateTail' => false,
'stripSpace' => '-',
@@ -802,7 +806,7 @@ class WireMail extends WireData implements WireMailInterface {
*
*/
protected function ___htmlToText($html) {
$text = $this->wire('sanitizer')->getTextTools()->markupToText($html);
$text = $this->wire()->sanitizer->getTextTools()->markupToText($html);
$text = str_replace("\n", "\r\n", $text);
$text = $this->strReplace($text, $this->multipartBoundary());
return $text;