danielmarschall / oidplus

OIDplus 2.0 - An OpenSource online Registration Authority for OIDs and other Object Types
https://www.oidplus.com
Apache License 2.0
10 stars 6 forks source link

Object type X.500 DN #23

Closed danielmarschall closed 10 months ago

danielmarschall commented 10 months ago

If you work with ActiveDirectory, you might want to manage your tree, so you need to take care about all your O, OU, CN, etc. So, there should be such an object type

Disclaimer: I am not an expert in X.500 and ActiveDirectory, so I hope I implement useful use-cases.

danielmarschall commented 10 months ago

Helpful resources:

danielmarschall commented 10 months ago

Added in SVN Rev 1383

danielmarschall commented 10 months ago

Noch offen: "Multi-valued" DN /DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe

danielmarschall commented 10 months ago

Noch offen: RFC 2253 Escaping etc.

danielmarschall commented 10 months ago

Both fixed in SVN Rev 1385

wehowski commented 10 months ago

OIDplus Error Call to undefined function ViaThinkSoft\OIDplus\explode_with_escaping() Technical information about the problem:

Error at file .../plugins/viathinksoft/objectTypes/x500dn/OIDplusX500DN.class.php (line 45)

Fix: Just prepend the escape char:

@list($namespace, $identifier) = \explode_with_escaping(':', $node_id, 2);

line 45

danielmarschall commented 10 months ago

@wehowski I don't get any error message.

I never prepended the escape character to methods defined in functions.inc.php , uuid_utils.inc.php, oid_utils.inc.php, etc., and it always worked.

Can you please try to reproduce why it fails for you and not for me?

wehowski commented 10 months ago

Hello Daniel, I did not reproduce to NOT get the error yet, my guess is it could work with changing the PHP Version or suppressing the display_errors. Hint: Avoid to use "@", us try catch or validate before.

explode_with_escaping is a user defined function in the global namespace. When called in another namespace like here ViaThinkSoft\OIDplus, you MUST

danielmarschall commented 10 months ago

@wehowski I tried it with PHP 8.2 and got no error. Also PHPstan does not show any warning.

Look, in includes/functions.inc.php and vendor/danielmarschall/php_utils/*_utils.inc.php , I have douzends of methods in the global namespace.

Just an example: The method url_get_contents is defined in functions.inc.php . It is used 31 times throughout the whole system, without backslash prefix.

So I cannot believe that it the method explode_with_escaping shows a warning on your side. Please tell me more details. Why does it crash for you and not for me? Why does it only crash at explode_with_escaping and not with url_get_contents (or the douzends of other global namespace methods)?

If we would be forced to put a backslash in front of every global namespace method, we would need to have 95% of the source code of OIDplus. That would be horrible!

wehowski commented 10 months ago

So I cannot believe that it the method explode_with_escaping shows a warning on your side.

It happens during the update process when OIDplus was "half-updated".

I know that sometimes the error does not appear, but believe me or not, in my believing to not show an error in such a case is a PHP bug our ambiguous.

Would have to ask googl/phpc why!? [phpc}(https://phpc.social/@webfan)

Tut mir leid wenn meine Antwort nicht zufriedenstellend ist, die Antwort ist, es war keine Warnung sondern ein Fehler und der ist in meinen Augen logisch auch einleuchtend und nachvollziehbar. Warum er aber in 95% der Fälle nicht erscheint weiß ich schlicht und einfach nicht. Ist aber eine interessante Frage, die ich mich auch schon gefragt hab aber noch nicht an die Community gestellt oder gegoogelt hab. Würde ich mal an die PHP Profis zum Beispiel phpc.social oder php.net weiterleiten... ???

Viele Grüße Till

wehowski commented 10 months ago

...möglicherweise hat es was mit dem Autolader zu tun? Wenn man aber von Anfang an "qualifizierte" function und class names verwendet erübrigt sich die Frage vielleicht. Aber die Frage warum dieses Verhalten uneindeutig so ist sollte man stellen!

danielmarschall commented 10 months ago

@wehowski Kannst du bitte bei dir einmal den Backslash in Zeile 45 wieder entfernen und schauen, ob der Fehler wieder kommt?

Ich habe nämlich irgendwie die Vermutung, dass ein Update bei dir (vorübergehend) unvollständig war, oder irgendwelche Op-Caches waren nicht aktualisiert, etc, und die Funktion explode_with_escaping war deswegen in functions.inc.php für einen kurzen Moment nicht drin gestanden. Dann käme natürlich der Fehler, wenn OIDplusX500DN.class.php neu ist und functions.inc.php alt. Probiere also bitte nochmal die Änderung in Zeile 45, dann haben wir Gewissheit.

wehowski commented 10 months ago

Der Backslash ist entfernt und es funktioniert, allerdings war der fix auch den Backslash zu setzen und NICHT die functions zu includieren den das WAREN sie. Bitte stelle diese Frage and die Programmierer von PHP (siehe oben)!

danielmarschall commented 10 months ago

@wehowski Ich bin mir zu 99% sicher, dass es ein vorübergehendes Problem war, dass bei dir für einen kurzen Moment eine alte Version von functions.inc.php im Arbeitsspeicher war, in der die Funktion noch nicht drinstand, denn die Funktion ist erst gestern im Rahmen meiner vielen Commits hinzugekommen. Die Meldung ViaThinkSoft\OIDplus\explode_with_escaping ist wohl an der Stelle eher verwirrend, denn er guckt sich erst den eigenen Namespace an und dann die globalen Funktionen. Ist functions.inc.php inkompatibel, dann findet er beides nicht. Ich sehe also im Moment keinen Handlungsbedarf. Die Tatsache, dass es jetzt auch ohne Backslash bei dir funktioniert, bekräftigt meine Vermutung, dass der Fehler lediglich daraus bestand, dass eine alte Version von functions.inc.php geladen war.

wehowski commented 10 months ago

. Die Tatsache, dass es jetzt auch ohne Backslash bei dir funktioniert, bekräftigt meine Vermutung, dass der Fehler lediglich daraus bestand, dass eine alte Version von functions.inc.php geladen war. Yo! Damit hast Du wahrscheinlich recht! Die Funktion liegt ja nicht im Plugin, das die functions.php vl. nocht nicht upgedated war hatte ich nicht richtig mitbedacht, ABER: Als fix habe ich NUR den Backslash gesetzt und NICHT das Update (functions.inc.php) fortgesetzt. Fazit: Ich verstehe dann logisch dieses Verhalten von PHP dadurch überhaupt nicht!

Edit: Autoloader?

danielmarschall commented 10 months ago

@wehowski Vielleicht ist es "Zufall" dass du den Backslash hinzugefügt hast, und in der Zwischenzeit hatte ich das vorübergehende Problem mit der alten function.inc.php behoben. Vielleicht hätte 2-3 Minuten warten ausgereicht? Naja egal. :-)

wehowski commented 10 months ago

Kommissar Zufall 😃 Oder auch Gott wars 😃