Repository navigation
Every example ends with Find out more, and gives the tagged links it needs - #98
Merged
Merged
Conversation
Each package's tests run its examples in their own PHP, as someone runs them from a fresh clone: the on-premise examples with php.ini naming a free data file, and the cloud examples with no resource key. Each run must end with the Find out more section, and every 51degrees.com link it prints must carry utm_source=code, utm_medium=example, utm_campaign=51degrees-php, the example's file as utm_content and a utm_term. The Device Detection on-premise failure to match and manual data update examples must show an Enterprise only property as needing the Enterprise data file with the contact link, the match metrics example must print a full documentation address, and the cloud examples must give a configuration page link when no key is set.
Each package with an ExampleUtils or Constants class gets one helper that writes the Find out more section, as text for a console example and as a list for a web page, with the repositories as bare addresses and the 51degrees.com pages tagged utm_source=code, utm_medium=example, utm_campaign=51degrees-php, the example's file as utm_content and a utm_term. Every console example and web page ends with it, including an early end such as a cloud example run with no resource key. The pipeline core and 51Did examples, which have no such class, write their own. The IP Intelligence cloud examples now tag their configuration page link utm_source=code and name _51DEGREES_RESOURCE_KEY, the mixed console example and the 51Did creator context server give the configuration page link, and the two IP Intelligence cloud web pages link it too. The location index page says what the key is for instead of stopping with a fatal error. The Device Detection on-premise failure to match and manual data update examples show HardwareVendor, as needing the Enterprise data file on the Lite file, with the contact link. The match metrics example prints a full documentation address rather than a relative one. The readmes, the IP Intelligence CI notes and AGENTS.md name _51DEGREES_RESOURCE_KEY, the Device Detection on-premise readme gives a start command that works from a fresh clone, and AGENTS.md describes the examples' output and what CI runs as they are now. The examples still read resource_key when _51DEGREES_RESOURCE_KEY is not set, and exit statuses are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every example in this repository now ends with a "Find out more" section, gives the tagged links it needs when no resource key is set, and the readmes and AGENTS.md describe the examples as they are. This draft covers the examples gaps DX-php-20, DX-php-30, DX-php-31, DX-php-33, DX-php-34, DX-php-35, DX-php-36, DX-php-37, DX-php-38 and DX-php-39.
The problem
Each gap, with file and line at
rc6d95eeee.device-detection/onpremise/examples/onpremise/static/page.phpline 219,ip-intelligence/examples/cloud/web-mixed/index.phpline 262 andpipeline/did/examples/creator-context-web/page.htmlline 143).userAgentClientHints-Web.php, the Device Detection cloudstatic/page.phpanduserAgentClientHints-Web.php, the IP Intelligenceonpremise/web,onpremise/web-mixedandcloud/webpages, and the locationwebIntegration.php.utm_source=github(gettingstarted-console.phpline 34, and the same line ofmetadata-console.phpandgetallproperties-console.php).resource_key, although the code reads_51DEGREES_RESOURCE_KEYfirst: the four IP Intelligence cloud console examples (line 34 of each),cloud/web/index.phpline 118,cloud/web-mixed/index.phpline 70,location/readme.mdline 51,ip-intelligence/readme.mdline 158,ip-intelligence/ci/README.mdline 35,AGENTS.mdline 198, the comment atip-intelligence/ci/run-integration-tests.ps1line 9, and two skip messages and a comment inip-intelligence/tests(ExampleTests.phpline 113,IpIntelligenceCloudTests.phplines 175 and 185).location/examples/index.phplines 41 to 46 called$this->fail(...)at file scope when no key was set, which only works insidelocation/tests/ExampleTests.php. It is the page served as/by the web serverlocation/readme.mdstarts, and run with no key it stopped with "Uncaught Error: Using $this when not in object context", as the red run below shows.ip-intelligence/examples/cloud/mixed/gettingstarted-console.phpline 34 andpipeline/did/examples/creator-context-web/server.phplines 126 to 129 gave no link when no key was set, where every other cloud example links the configuration page.failureToMatch.phpandmanualDataUpdate.phpread onlyIsMobile, so on the Lite file they showed no Enterprise only property and gave no contact link./documentation/4.5/_device_detection__hash.html#...(classes/MatchMetrics.phplines 127 to 129), which a console reader cannot follow, andmatchMetrics.phplines 30 and 31 had two more in the doc comment.device-detection/onpremise/readme.mdlines 171 to 182 said to runcomposer installat the repository root and thenphp -S localhost:3000 gettingStartedWeb.phpfrom the examples folder. The script isexamples/onpremise/gettingStartedWeb.php, and the examples load the package's ownvendor/autoload.php(gettingStartedConsole.phpline 37), which the root install does not create (AGENTS.mdlines 203 to 206).ExamplesWithoutSettingsTestsrun the scripts in their own PHP, and lines 145 to 170 left out the Enterprise lines and said the missing IP Intelligence properties read(not available - ...), while the examples print "needs the Enterprise data file".What the specification says
The Device Detection required examples at c8128ca4, lines 20 to 23:
Lines 101 to 113:
Lines 115 to 117:
Lines 129 to 133, for the cloud examples:
The IP Intelligence required examples, lines 80 to 91, apply the same rules to the IP Intelligence examples. The specification does not define the Find out more section. That is 51Degrees' rule for every example, which ends with a clearly separated "Find out more" section listing the engine repositories as bare addresses and 51degrees.com pages tagged as above. This repository has no
.utm-lint.json, so common-ci's link lint decides the tag format, being "Exactly the five parameters above, in that order, each once", withutm_contentandutm_termas lowercase slugs and the term at most 60 characters (scripts/utm-lint.ps1lines 11 to 18 at 1c5c0e0b).What changed and why
One helper per package. Each package that has an examples helper class gets one set of methods for the section, so the examples all say the same thing and no example carries its own copy:
ExampleUtilsin Device Detection on-premise,ExampleUtilsin Device Detection cloud,ExampleUtilsin IP Intelligence andConstantsin location.getFindOutMoregives the section as text, a blank line, the heading "Find out more" underlined with hyphens, then onelabel: addressline per link.getFindOutMoreHtmlgives the same list for the foot of a web page, andprintFindOutMorewrites the text from the command line and the list from a web server. The repositories are bare addresses, being this repository's package folder and, for Device Detection on-premise and IP Intelligence, 51degrees-cxx and the data repository. The 51degrees.com pages are the product page (both products for IP Intelligence, whose mixed examples use device detection as well), the resource key documentation where the package has cloud examples, pricing and contact, each built bygetTaggedLinkwithutm_source=code&utm_medium=example&utm_campaign=51degrees-php, the example's path from its package folder asutm_content(for exampleexamples-onpremise-gettingstartedconsole.php, as the examples' existing links name it) and afind-out-more-...term. The two pipeline core examples and the two 51Did examples have no such class, so each writes its own short section. The hand-written sections indevice-detection/onpremise/examples/onpremise/static/page.phpandip-intelligence/examples/cloud/web-mixed/index.phpnow come from the helper too, andpipeline/did/examples/creator-context-web/page.htmlis unchanged.Every clean end prints it. Every console example ends with it, after its last result. A cloud example run with no resource key prints its message and the section before it stops, and the location examples print it at each early
returnas well (no key, no configuration file, no Device Detection package, missing properties). Web pages show it as their last visible section, also when the page shows an error box. The routes that answer/51Degrees.core.jsand/jsonget nothing added. In Device Detection cloud,ExampleUtils::logErrorAndExittakes the example's file as a new optional third argument and prints the section before it exits.ghev-to-http.phploadsExampleUtils.phpby itself, so it still needs nocomposer install.Links and names (DX-php-35, DX-php-36, DX-php-38). The four IP Intelligence cloud console examples name
_51DEGREES_RESOURCE_KEYand give the configuration page taggedutm_source=code&utm_medium=examplewith the example's path asutm_content, the mixed one included. The two IP Intelligence cloud web pages name_51DEGREES_RESOURCE_KEYin their error box and link the configuration page from it. The 51Did creator context server, given no key, still answers HTTP 500, now with a page that names_51DEGREES_RESOURCE_KEY, links the configuration page and ends with the section. The readmes,ip-intelligence/ci/README.md, the comment inip-intelligence/ci/run-integration-tests.ps1, two test skip messages, one test comment and AGENTS.md name_51DEGREES_RESOURCE_KEY. The code still readsresource_keywhen_51DEGREES_RESOURCE_KEYis unset or empty, as a deprecated name, because a patch release never removes a public name.The location index page (DX-php-37). With no key,
location/examples/index.phpsays that the page gets its JavaScript from the 51Degrees cloud service, which needs a resource key to know which properties to return, gives the tagged configuration page link, names_51DEGREES_RESOURCE_KEY, prints the section and returns.location/tests/ExampleTests.php, which includes the page with a key, now says the key is missing when the page gives no JavaScript, rather than reading an unset variable.Enterprise properties (DX-php-31). The on-premise
failureToMatch.phpandmanualDataUpdate.phpshowHardware Vendorafter each lookup through the existingExampleUtils::getEnterpriseValue, which reads it only when the data file has it and otherwise says "needs the Enterprise data file". On the Lite file each then prints the existing note, "Some of these properties need the Enterprise data file. Contact us for a copy at" and the tagged contact page, once.manualDataUpdate.php, whose purpose is updating the data file, also says that the Enterprise data file adds daily automatic updates, the wording the on-premise web page already uses.The match metrics link (DX-php-20).
classes/MatchMetrics.phpprintshttps://51degrees.com/documentation/_device_detection__hash.htmltagged as above, followed by#DeviceDetection_Hash_DataSetProduction, and the two links in the doc comment ofmatchMetrics.phpare full tagged addresses. Both pages answer and the page holds that anchor.The readme (DX-php-30).
device-detection/onpremise/readme.mdsays to runcomposer installindevice-detection/onpremise, because the examples load that package'svendor/autoload.phpand the root install does not create it, and then, from the same folder,php -S localhost:3000 examples/onpremise/gettingStartedWeb.phporphp examples/onpremise/gettingStartedConsole.php.AGENTS.md (DX-php-39). "Correct output" gives the Enterprise lines and the note for both getting started examples, says the IP Intelligence lines read "needs the Enterprise data file", and describes the Find out more section and its tags. "What CI does not test" is now "What CI tests", naming the tests that run the example scripts in their own PHP, what each checks, and when they do not run (no TAC file, no resource key for location, no on-premise build on Windows or PHP 7.4).
Not changed. Exit statuses are as they were, so the Device Detection and IP Intelligence cloud console examples given no key still exit with status 1 and the location ones with 0, because how a cloud example ends without a key is an open rule question for James. The Device Detection on-premise data file download and
hash-php.iare untouched. No package code under anysrcfolder changed.How it was tested
The tests. Each test runs an example in its own PHP, as someone runs it from a fresh clone, through a small helper in each package's tests,
tests/classes/ExampleRun.php(tests/ExampleRun.phpin 51Did). The helper starts PHP withproc_open, leaves out the environment variables it is given (the resource key names for a cloud example, and the data file names for the Device Detection on-premise examples and the IP Intelligence on-premise web pages), and for a web page sets the request variables PHP from the command line puts in$_SERVER, aGETfor/. Its checks are that the console output ends with the heading followed only bylabel: addresslines, or that a page shows nothing after the section's list, and that every link to51degrees.com,www.51degrees.comorconfigure.51degrees.comprinted to either stream carriesutm_source=code&utm_medium=example&utm_campaign=51degrees-php, autm_contentstartingexamples-and autm_termof at most 60 characters, in that order. Two kinds of link pass as they are, being a package's own message (utm_medium=commentwith autm_contentstartingsrc-) and the engine's own message, which carries its own repository's campaign, such as the no-value reason from the Device Detection engine thatfailureToMatch.phpprints (utm_campaign=51degrees-cxx). The exit status of a cloud example with no key is not checked.device-detection/onpremise/tests/ExamplesWithoutSettingsTests.phpruns all seven on-premise examples, the two web pages included, with php.ini naming the Lite file. It also checks the Enterprise property and the contact link infailureToMatch.phpandmanualDataUpdate.php, and the full documentation address inmatchMetrics.php.device-detection/cloud/tests/ExamplesWithoutKeyTests.php, in the Unit suite, runs the seven cloud examples with no key and checks for the configuration page link, and runsghev-to-http.php.tests/ExampleWebTests.php, which runs with a key, checks that the page has the section.ip-intelligence/tests/ExamplesWithoutKeyTests.php, in the Unit suite, runs the four cloud console examples and the two cloud web pages with no key and checks for the configuration page link and the name_51DEGREES_RESOURCE_KEY.WebExamplesWithoutSettingsTests.phprenders the two on-premise web pages with php.ini naming the Lite file, andExamplesWithoutSettingsTests.phpnow checks the section for every on-premise console example it already ran.location/tests/ExamplesWithoutKeyTests.phpruns the five location examples,index.phpincluded, with no key.pipeline/core/tests/ExampleTests.phpruns its two examples in their own PHP, andpipeline/did/tests/ExamplesTest.phprunsfodid_example.phpand the creator context server with no key.Red. Run 43537387948 on
tmp/fixer-ex-red9618922, which isrc6d95eee with the tests (3eb1df2) and a throwaway workflow, on Ubuntu with PHP 8.0, 8.3 and 8.5, Windows with PHP 8.3 and Ubuntu with PHP 7.4. Every new check failed, for the reasons the fix addresses:testGettingStartedWebpassed, because that page already had the section, which now comes from the helper.testMixed, which needs the Device Detection extension as well).resource_keyrather than_51DEGREES_RESOURCE_KEY.index.phpstopped with "PHP Fatal error: Uncaught Error: Using $this when not in object context in .../location/examples/index.php:42", and the 51Did server printed only "Set _51DEGREES_RESOURCE_KEY to the resource key of the page."Green. Run 43537387550 on
tmp/fixer-ex-greene7d7fba, which is ceba24c, this draft's change beforercwas merged in, with the same workflow, passed in all six jobs. On each of PHP 8.0, 8.3 and 8.5 on Ubuntu, Device Detection on-premise "OK (7 tests, 112 assertions)", IP Intelligence on-premise "Tests: 10, Assertions: 158, Skipped: 1.", IP Intelligence cloud "OK (6 tests, 102 assertions)", Device Detection cloud "OK (8 tests, 119 assertions)", location "OK (5 tests, 71 assertions)" and pipeline core "OK (4 tests, 19 assertions)", with 51Did, which needs PHP 8.1, "OK (2 tests, 19 assertions)" on 8.3 and 8.5. The Windows PHP 8.3 job gave the same for Device Detection cloud, location, pipeline core and 51Did, and the Ubuntu PHP 7.4 job the same for Device Detection cloud, location and pipeline core. Its readme job followed the newdevice-detection/onpremise/readme.mdfrom a checkout, building the extension and naming the Lite file in php.ini as the readme says, thencomposer installindevice-detection/onpremisefrom Packagist,php examples/onpremise/gettingStartedConsole.php, which ended with Find out more, andphp -S localhost:3001 examples/onpremise/gettingStartedWeb.php, which answered HTTP 200 with the section. The command the readme gave before, from theexamplesfolder, answered HTTP 500.The rc merge.
rcat 70424ea5, which now holds #88 and #89, is merged in with a merge commit, 813e23a, with no conflicts. Its tree is the onegit merge-treegives for ceba24c and 70424ea, so nothing was edited in the merge. The links into files above are at ceba24c, the commit that made the change.Full build. Run 43554832737 on
tmp/pr-matrix-98-c, common-ci's pull request build of this draft fromrc70424ea with merging turned off, passed in all eight legs, Ubuntu with PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5 and Windows with PHP 8.3. All nine "Setting 'PullRequestSha'" lines name this head, 813e23a, and Configure printed "Left out 5 macOS entries". On Ubuntu with PHP 8.3 the Device Detection on-premise unit suite gave "OK (72 tests, 312 assertions)", the IP Intelligence unit suite "OK (42 tests, 203 assertions)" and its integration suite, which now holds #88'sMixedExamplesTests, "OK (71 tests, 944 assertions)", the Device Detection cloud unit suite "OK (29 tests, 203 assertions)", location "OK (16 tests, 124 assertions)", pipeline core "Tests: 509, Assertions: 4205, Skipped: 1.", 51Did "OK (192 tests, 2641 assertions)" and #89's derived property suite "OK (52 tests, 140 assertions)". Run 43552264429 built ceba24c the same way, fromrc6d95eee, and passed too.macOS was left out of this draft's full build under the 9 November decision. The rc head is built with macOS before it merges into main.
The draft's own checks are green on this head (link lint, environment variable names and only rc into main).
What remains
rcand merged in here. ItsMixedExamplesTestschecks the two mixed examples with both extensions loaded but not their Find out more section, and hereonpremise/web-mixed/index.phpis rendered only with the Device Detection extension missing. #101 adds that check toMixedExamplesTests.ExampleWebTests.php.device-detection/onpremise/readme.mdthat this draft also changes. Start PHP with no Device Detection data file, and run the on-premise examples with nothing set #91 merges after this draft and takesrcthen.hash-php.iis not touched here.gettingStartedWeb.phpexamples still link the JavaScriptBuilderElement reference with a relative/documentation/4.5/apis/...address, which is not printed. The 51Did creator context server's comment says to runcomposer installat the repository root, while the server loadspipeline/did/vendor/autoload.php, which that install does not create.tmp/fixer-ex-red,tmp/fixer-ex-green,tmp/pr-matrix-98,tmp/pr-matrix-98-bandtmp/pr-matrix-98-care deleted now that this description cites their runs.