Skip to content

Commit 8badc0f

Browse files
author
Benjamin Pick
committed
Revert "FIX: Remove test of removed shortcode"
This reverts commit c262477.
1 parent 2c0b08a commit 8badc0f

File tree

9 files changed

+73
-80
lines changed

9 files changed

+73
-80
lines changed

tests/test-legacy-api.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ function testTimezone()
5151
function testRegionName() {
5252
$record = geoip_detect_get_info_from_ip(GEOIP_DETECT_TEST_IP);
5353
$this->assertGreaterThan(1, strlen($record->region_name), 'Region Name: "' . $record->region_name);
54-
}
54+
}
55+
56+
function testShortcode() {
57+
add_filter('geoip_detect_get_external_ip_adress', [ $this, 'filter_set_test_ip' ], 101);
58+
$this->assertEquals(GEOIP_DETECT_TEST_IP, geoip_detect_get_external_ip_adress());
59+
60+
$string = do_shortcode('[geoip_detect property="country_name"]');
61+
$this->assertNotEmpty($string, '[geoip_detect property="country_name"]', "The Geolocation IP Detection shortcode did not generate any output");
62+
$this->assertNotEquals($string, '[geoip_detect property="country_name"]', "The Geolocation IP Detection shortcode does not seem to be called");
63+
$this->assertStringNotContainsString('<!--', $string, "Geolocation IP Detection shortcode threw an error: " . $string);
64+
65+
$string = do_shortcode('[geoip_detect property="INVALID"]');
66+
$this->assertStringContainsString('<!--', $string, "Geolocation IP Detection Shortcode threw no error in spite of invalid property name: " . $string);
67+
$string = do_shortcode('[geoip_detect property="INVALID" default="here"]');
68+
$this->assertStringContainsString('here', $string, "Geolocation IP Detection Shortcode does not contain default value: " . $string);
69+
}
5570
}
5671

vendor/autoload.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
echo $err;
1515
}
1616
}
17-
throw new RuntimeException($err);
17+
trigger_error(
18+
$err,
19+
E_USER_ERROR
20+
);
1821
}
1922

2023
require_once __DIR__ . '/composer/autoload_real.php';

vendor/composer/InstalledVersions.php

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,12 @@
2626
*/
2727
class InstalledVersions
2828
{
29-
/**
30-
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
31-
* @internal
32-
*/
33-
private static $selfDir = null;
34-
3529
/**
3630
* @var mixed[]|null
3731
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
3832
*/
3933
private static $installed;
4034

41-
/**
42-
* @var bool
43-
*/
44-
private static $installedIsLocalDir;
45-
4635
/**
4736
* @var bool|null
4837
*/
@@ -320,24 +309,6 @@ public static function reload($data)
320309
{
321310
self::$installed = $data;
322311
self::$installedByVendor = array();
323-
324-
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
325-
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
326-
// so we have to assume it does not, and that may result in duplicate data being returned when listing
327-
// all installed packages for example
328-
self::$installedIsLocalDir = false;
329-
}
330-
331-
/**
332-
* @return string
333-
*/
334-
private static function getSelfDir()
335-
{
336-
if (self::$selfDir === null) {
337-
self::$selfDir = strtr(__DIR__, '\\', '/');
338-
}
339-
340-
return self::$selfDir;
341312
}
342313

343314
/**
@@ -351,27 +322,19 @@ private static function getInstalled()
351322
}
352323

353324
$installed = array();
354-
$copiedLocalDir = false;
355325

356326
if (self::$canGetVendors) {
357-
$selfDir = self::getSelfDir();
358327
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
359-
$vendorDir = strtr($vendorDir, '\\', '/');
360328
if (isset(self::$installedByVendor[$vendorDir])) {
361329
$installed[] = self::$installedByVendor[$vendorDir];
362330
} elseif (is_file($vendorDir.'/composer/installed.php')) {
363331
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
364332
$required = require $vendorDir.'/composer/installed.php';
365-
self::$installedByVendor[$vendorDir] = $required;
366-
$installed[] = $required;
367-
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
368-
self::$installed = $required;
369-
self::$installedIsLocalDir = true;
333+
$installed[] = self::$installedByVendor[$vendorDir] = $required;
334+
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
335+
self::$installed = $installed[count($installed) - 1];
370336
}
371337
}
372-
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
373-
$copiedLocalDir = true;
374-
}
375338
}
376339
}
377340

@@ -387,7 +350,7 @@ private static function getInstalled()
387350
}
388351
}
389352

390-
if (self::$installed !== array() && !$copiedLocalDir) {
353+
if (self::$installed !== array()) {
391354
$installed[] = self::$installed;
392355
}
393356

vendor/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'yellowtree/geoip-detect',
44
'pretty_version' => 'dev-develop',
55
'version' => 'dev-develop',
6-
'reference' => '8f44e8dd505d5852c84953bd8fdb785452ee7114',
6+
'reference' => 'f6e98dc98217ce1d05e0cb4a073535700ceea690',
77
'type' => 'wordpress-plugin',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -439,7 +439,7 @@
439439
'yellowtree/geoip-detect' => array(
440440
'pretty_version' => 'dev-develop',
441441
'version' => 'dev-develop',
442-
'reference' => '8f44e8dd505d5852c84953bd8fdb785452ee7114',
442+
'reference' => 'f6e98dc98217ce1d05e0cb4a073535700ceea690',
443443
'type' => 'wordpress-plugin',
444444
'install_path' => __DIR__ . '/../../',
445445
'aliases' => array(),

vendor/geoip2/geoip2/src/Model/AbstractModel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public function __isset($attr)
6060
return $attr !== 'instance' && isset($this->$attr);
6161
}
6262

63+
// PHP 8.1 : jsonSerialize(): mixed
64+
#[\ReturnTypeWillChange]
6365
public function jsonSerialize()
6466
{
6567
return $this->raw;

vendor/geoip2/geoip2/src/Record/AbstractRecord.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private function validAttribute($attr)
5454
return \in_array($attr, $this->validAttributes, true);
5555
}
5656

57+
#[\ReturnTypeWillChange]
5758
public function jsonSerialize()
5859
{
5960
return $this->record;

vendor/symfony/polyfill-intl-grapheme/bootstrap80.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,32 @@
2121
define('GRAPHEME_EXTR_MAXCHARS', 2);
2222
}
2323

24+
/* Note YellowTree: In order to commit this to the plugin SVN of Wordpress, I needed to remove the return value typing */
25+
2426
if (!function_exists('grapheme_extract')) {
25-
function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); }
27+
function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null) { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); }
2628
}
2729
if (!function_exists('grapheme_stripos')) {
28-
function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); }
30+
function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0) { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); }
2931
}
3032
if (!function_exists('grapheme_stristr')) {
31-
function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
33+
function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false) { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
3234
}
3335
if (!function_exists('grapheme_strlen')) {
34-
function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); }
36+
function grapheme_strlen(?string $string) { return p\Grapheme::grapheme_strlen((string) $string); }
3537
}
3638
if (!function_exists('grapheme_strpos')) {
37-
function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); }
39+
function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0) { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); }
3840
}
3941
if (!function_exists('grapheme_strripos')) {
40-
function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); }
42+
function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0) { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); }
4143
}
4244
if (!function_exists('grapheme_strrpos')) {
43-
function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); }
45+
function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0) { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); }
4446
}
4547
if (!function_exists('grapheme_strstr')) {
46-
function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
48+
function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false) { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
4749
}
4850
if (!function_exists('grapheme_substr')) {
49-
function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); }
51+
function grapheme_substr(?string $string, ?int $offset, ?int $length = null) { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, (int) $length); }
5052
}

0 commit comments

Comments
 (0)