Merge "User: Avoid deprecated Linker::link()"
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 8514cc8..a412250 100644 (file)
@@ -593,7 +593,7 @@ class LocalFile extends File {
                if ( $upgrade ) {
                        $this->upgrading = true;
                        // Defer updates unless in auto-commit CLI mode
-                       DeferredUpdates::addCallableUpdate( function() {
+                       DeferredUpdates::addCallableUpdate( function () {
                                $this->upgrading = false; // avoid duplicate updates
                                try {
                                        $this->upgradeRow();
@@ -716,6 +716,11 @@ class LocalFile extends File {
         * @return int
         */
        public function getWidth( $page = 1 ) {
+               $page = (int)$page;
+               if ( $page < 1 ) {
+                       $page = 1;
+               }
+
                $this->load();
 
                if ( $this->isMultipage() ) {
@@ -743,6 +748,11 @@ class LocalFile extends File {
         * @return int
         */
        public function getHeight( $page = 1 ) {
+               $page = (int)$page;
+               if ( $page < 1 ) {
+                       $page = 1;
+               }
+
                $this->load();
 
                if ( $this->isMultipage() ) {
@@ -1202,9 +1212,11 @@ class LocalFile extends File {
                if ( $handler ) {
                        $metadata = MediaWiki\quietCall( 'unserialize', $props['metadata'] );
 
-                       $options['headers'] = $handler->getContentHeaders(
-                               $metadata, $props['width'], $props['height']
-                       );
+                       if ( !is_array( $metadata ) ) {
+                               $metadata = [];
+                       }
+
+                       $options['headers'] = $handler->getContentHeaders( $metadata );
                } else {
                        $options['headers'] = [];
                }