Skip to content

Commit

Permalink
bump 1.1.0
Browse files Browse the repository at this point in the history
- Fixed: multisite target url.
- Added: src/Parser.php license header.
  • Loading branch information
nawawi committed Jul 12, 2021
1 parent c4ff2e5 commit 5a636f1
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 16 deletions.
Binary file modified bin/docket-cronwp.phar
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"vendor-dir": "includes/vendor",
"optimize-autoloader": true
}
}
}
2 changes: 1 addition & 1 deletion docket-cronwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'DOCKET_CRONWP',
[
'NAME' => 'Docket CronWP',
'VERSION' => '1.0.9',
'VERSION' => '1.1.0',
'ROOT' => __DIR__,
'SELF' => !empty($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : __FILE__,
]
Expand Down
23 changes: 18 additions & 5 deletions includes/src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ private function print_usage()
$this->output($text);
}

private function print_args()
private function print_args($site = null)
{
$text = $this->rowh($this->app()->name).': '.$this->app()->version.\PHP_EOL;
$text .= $this->rowh('Path').': '.$this->args['wpdir'].\PHP_EOL;
$text .= $this->rowh('Jobs').': '.$this->args['job'].\PHP_EOL;
if ($site) {
$text .= $this->rowh('Site').': '.$site.\PHP_EOL;
}
$text .= \PHP_EOL;
$this->output($text);
}
Expand Down Expand Up @@ -203,9 +206,19 @@ private function register_wpload()
$_SERVER['HTTP_USER_AGENT'] = '';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_URI'] = '/';

if (!empty($this->args['url'])) {
$_SERVER['HTTP_HOST'] = parse_url($this->args['url'], \PHP_URL_HOST);
$parts = parse_url($this->args['url']);
if (!empty($parts['host'])) {
$_SERVER['HTTP_HOST'] = $parts['host'];
}

if (!empty($parts['path'])) {
$_SERVER['REQUEST_URI'] = $parts['path'];
}

unset($parts);
}

\define('DOING_CRON', true);
Expand Down Expand Up @@ -249,8 +262,8 @@ private function crons_now($crons)

public function run()
{
$site = $this->strip_proto(get_home_url());
$this->key = $this->prefix.$this->get_hash($site);
$site = get_home_url();
$this->key = $this->prefix.$this->get_hash($this->strip_proto($site));

$lock_file = $this->lockpath().$this->key.'-data.php';
$stmp = time() + 3600;
Expand Down Expand Up @@ -306,7 +319,7 @@ function ($lockfile) use ($lock_file) {
}

if (!$this->args['quiet'] && $this->args['verbose']) {
$this->print_args();
$this->print_args($site);
}

$wp_get_schedules = wp_get_schedules();
Expand Down
36 changes: 31 additions & 5 deletions includes/src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,41 @@
* @see https://github.com/nawawi/docket-cronwp
*/

/**
* Credits:
* https://github.com/phalcon/cli-options-parser/blob/master/src/Parser.php.
*/

namespace Nawawi\DocketCronWP;

\defined('DOCKET_CRONWP') || exit;

/**
* Class Parser
* https://github.com/phalcon/cli-options-parser/blob/master/src/Parser.php.
*
* New BSD License
*
* Copyright (c) 2011-present, Phalcon Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Phalcon nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL PHALCON TEAM BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
trait Parser
{
private $bool_param = [
Expand Down
4 changes: 2 additions & 2 deletions includes/vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => 'f047d4e92596d699d0ebaf1b9749efd44408e56a',
'reference' => 'c4ff2e51296fa202f487eeba350193040f6434bb',
'name' => 'nawawi/docket-cronwp',
),
'versions' =>
Expand All @@ -41,7 +41,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => 'f047d4e92596d699d0ebaf1b9749efd44408e56a',
'reference' => 'c4ff2e51296fa202f487eeba350193040f6434bb',
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions includes/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => 'f047d4e92596d699d0ebaf1b9749efd44408e56a',
'reference' => 'c4ff2e51296fa202f487eeba350193040f6434bb',
'name' => 'nawawi/docket-cronwp',
),
'versions' =>
Expand All @@ -18,7 +18,7 @@
'aliases' =>
array (
),
'reference' => 'f047d4e92596d699d0ebaf1b9749efd44408e56a',
'reference' => 'c4ff2e51296fa202f487eeba350193040f6434bb',
),
),
);

0 comments on commit 5a636f1

Please sign in to comment.