]> BookStack Code Mirror - bookstack/commitdiff
Merge pull request #5491 from BookStackApp/deprecations
authorDan Brown <redacted>
Sun, 23 Feb 2025 11:23:35 +0000 (11:23 +0000)
committerGitHub <redacted>
Sun, 23 Feb 2025 11:23:35 +0000 (11:23 +0000)
Addressing PHP 8.4 Deprecations

app/Access/LdapService.php
app/Uploads/ImageResizer.php
resources/js/components/tri-layout.js
resources/sass/_mixins.scss
tests/Auth/LdapTest.php

index e5037ad2f95699243f495943fbb667b26d96d3a3..0f456efc24719796aa800f7f8e6cb324a02be1db 100644 (file)
@@ -112,10 +112,14 @@ class LdapService
             return null;
         }
 
-        $userCn = $this->getUserResponseProperty($user, 'cn', null);
+        $nameDefault = $this->getUserResponseProperty($user, 'cn', null);
+        if (is_null($nameDefault)) {
+            $nameDefault = ldap_explode_dn($user['dn'], 1)[0] ?? $user['dn'];
+        }
+
         $formatted = [
             'uid'   => $this->getUserResponseProperty($user, $idAttr, $user['dn']),
-            'name'  => $this->getUserDisplayName($user, $displayNameAttrs, $userCn),
+            'name'  => $this->getUserDisplayName($user, $displayNameAttrs, $nameDefault),
             'dn'    => $user['dn'],
             'email' => $this->getUserResponseProperty($user, $emailAttr, null),
             'avatar' => $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
index fa6b1cac2d447651af07f599e4618d422e85b3c2..5f095658f3fc49412245c4fa826d35cb8a86865b 100644 (file)
@@ -158,7 +158,10 @@ class ImageResizer
      */
     protected function interventionFromImageData(string $imageData, ?string $fileType): InterventionImage
     {
-        $manager = new ImageManager(new Driver());
+        $manager = new ImageManager(
+            new Driver(),
+            autoOrientation: false,
+        );
 
         // Ensure gif images are decoded natively instead of deferring to intervention GIF
         // handling since we don't need the added animation support.
index 8ccefb06c482b09da5c7c0d4103f3d8307b8ee12..be9388e8d4615f5919a81068ff57915bc9d52ae9 100644 (file)
@@ -27,7 +27,7 @@ export class TriLayout extends Component {
     updateLayout() {
         let newLayout = 'tablet';
         if (window.innerWidth <= 1000) newLayout = 'mobile';
-        if (window.innerWidth >= 1400) newLayout = 'desktop';
+        if (window.innerWidth > 1400) newLayout = 'desktop';
         if (newLayout === this.lastLayoutType) return;
 
         if (this.onDestroy) {
index 0a419c08abdeb1372e331277fcd157394d100918..fc50860083936d77902488b022b108dd6edf7a2c 100644 (file)
@@ -3,10 +3,10 @@
     @media screen and (max-width: $size) { @content; }
 }
 @mixin larger-than($size) {
-    @media screen and (min-width: $size) { @content; }
+    @media screen and (min-width: ($size + 1)) { @content; }
 }
 @mixin between($min, $max) {
-  @media screen and (min-width: $min) and (max-width: $max) { @content; }
+  @media screen and (min-width: ($min + 1)) and (max-width: $max) { @content; }
 }
 
 // Padding shorthand using logical operators to better support RTL.
index 9a00c983a50475ee70dbfedc2fe5ce53323555c8..d1f128a50d9ba7e918f573e98de4424e80dfa71b 100644 (file)
@@ -166,6 +166,26 @@ class LdapTest extends TestCase
         $this->assertDatabaseHas('users', ['email' => $this->mockUser->email, 'email_confirmed' => false, 'external_auth_id' => $ldapDn]);
     }
 
+    public function test_login_works_when_ldap_server_does_not_provide_a_cn_value()
+    {
+        $ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn');
+
+        $this->commonLdapMocks(1, 1, 1, 2, 1);
+        $this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
+            ->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
+            ->andReturn(['count' => 1, 0 => [
+                'dn'   => $ldapDn,
+                'mail' => [$this->mockUser->email],
+            ]]);
+
+        $resp = $this->mockUserLogin();
+        $resp->assertRedirect('/');
+        $this->assertDatabaseHas('users', [
+            'name' => 'test-user',
+            'email' => $this->mockUser->email,
+        ]);
+    }
+
     public function test_a_custom_uid_attribute_can_be_specified_and_is_used_properly()
     {
         config()->set(['services.ldap.id_attribute' => 'my_custom_id']);